highmaps.src.js 2.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652
  1. /**
  2. * @license Highmaps JS v9.1.0 (2021-05-04)
  3. *
  4. * (c) 2011-2021 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (root, factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = root.document ?
  13. factory(root) :
  14. factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/highmaps', function () {
  17. return factory(root);
  18. });
  19. } else {
  20. if (root.Highcharts) {
  21. root.Highcharts.error(16, true);
  22. }
  23. root.Highcharts = factory(root);
  24. }
  25. }(typeof window !== 'undefined' ? window : this, function (win) {
  26. var _modules = {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Core/Globals.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2021 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. /* *
  43. *
  44. * Constants
  45. *
  46. * */
  47. /**
  48. * @private
  49. * @deprecated
  50. * @todo Rename UMD argument `win` to `window`; move code to `Globals.win`
  51. */
  52. var w = (typeof win !== 'undefined' ?
  53. win :
  54. typeof window !== 'undefined' ?
  55. window :
  56. {}
  57. // eslint-disable-next-line node/no-unsupported-features/es-builtins
  58. );
  59. /* *
  60. *
  61. * Namespace
  62. *
  63. * */
  64. /**
  65. * Shared Highcharts properties.
  66. */
  67. var Globals;
  68. (function (Globals) {
  69. /* *
  70. *
  71. * Constants
  72. *
  73. * */
  74. Globals.SVG_NS = 'http://www.w3.org/2000/svg', Globals.product = 'Highcharts', Globals.version = '9.1.0', Globals.win = w, Globals.doc = Globals.win.document, Globals.svg = (Globals.doc &&
  75. Globals.doc.createElementNS &&
  76. !!Globals.doc.createElementNS(Globals.SVG_NS, 'svg').createSVGRect), Globals.userAgent = (Globals.win.navigator && Globals.win.navigator.userAgent) || '', Globals.isChrome = Globals.userAgent.indexOf('Chrome') !== -1, Globals.isFirefox = Globals.userAgent.indexOf('Firefox') !== -1, Globals.isMS = /(edge|msie|trident)/i.test(Globals.userAgent) && !Globals.win.opera, Globals.isSafari = !Globals.isChrome && Globals.userAgent.indexOf('Safari') !== -1, Globals.isTouchDevice = /(Mobile|Android|Windows Phone)/.test(Globals.userAgent), Globals.isWebKit = Globals.userAgent.indexOf('AppleWebKit') !== -1, Globals.deg2rad = Math.PI * 2 / 360, Globals.hasBidiBug = (Globals.isFirefox &&
  77. parseInt(Globals.userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  78. ), Globals.hasTouch = !!Globals.win.TouchEvent, Globals.marginNames = [
  79. 'plotTop',
  80. 'marginRight',
  81. 'marginBottom',
  82. 'plotLeft'
  83. ], Globals.noop = function () { }, Globals.supportsPassiveEvents = (function () {
  84. // Checks whether the browser supports passive events, (#11353).
  85. var supportsPassive = false;
  86. // Object.defineProperty doesn't work on IE as well as passive
  87. // events - instead of using polyfill, we can exclude IE totally.
  88. if (!Globals.isMS) {
  89. var opts = Object.defineProperty({}, 'passive', {
  90. get: function () {
  91. supportsPassive = true;
  92. }
  93. });
  94. if (Globals.win.addEventListener && Globals.win.removeEventListener) {
  95. Globals.win.addEventListener('testPassive', Globals.noop, opts);
  96. Globals.win.removeEventListener('testPassive', Globals.noop, opts);
  97. }
  98. }
  99. return supportsPassive;
  100. }());
  101. /**
  102. * An array containing the current chart objects in the page. A chart's
  103. * position in the array is preserved throughout the page's lifetime. When
  104. * a chart is destroyed, the array item becomes `undefined`.
  105. *
  106. * @name Highcharts.charts
  107. * @type {Array<Highcharts.Chart|undefined>}
  108. */
  109. Globals.charts = [];
  110. /**
  111. * A hook for defining additional date format specifiers. New
  112. * specifiers are defined as key-value pairs by using the
  113. * specifier as key, and a function which takes the timestamp as
  114. * value. This function returns the formatted portion of the
  115. * date.
  116. *
  117. * @sample highcharts/global/dateformats/
  118. * Adding support for week number
  119. *
  120. * @name Highcharts.dateFormats
  121. * @type {Record<string, Highcharts.TimeFormatCallbackFunction>}
  122. */
  123. Globals.dateFormats = {};
  124. /**
  125. * @private
  126. * @deprecated
  127. * @todo Use only `Core/Series/SeriesRegistry.seriesTypes`
  128. */
  129. Globals.seriesTypes = {};
  130. /**
  131. * @private
  132. */
  133. Globals.symbolSizes = {};
  134. })(Globals || (Globals = {}));
  135. /* *
  136. *
  137. * Default Export
  138. *
  139. * */
  140. return Globals;
  141. });
  142. _registerModule(_modules, 'Core/Utilities.js', [_modules['Core/Globals.js']], function (H) {
  143. /* *
  144. *
  145. * (c) 2010-2021 Torstein Honsi
  146. *
  147. * License: www.highcharts.com/license
  148. *
  149. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  150. *
  151. * */
  152. var charts = H.charts,
  153. doc = H.doc,
  154. win = H.win;
  155. /**
  156. * An animation configuration. Animation configurations can also be defined as
  157. * booleans, where `false` turns off animation and `true` defaults to a duration
  158. * of 500ms and defer of 0ms.
  159. *
  160. * @interface Highcharts.AnimationOptionsObject
  161. */ /**
  162. * A callback function to exectute when the animation finishes.
  163. * @name Highcharts.AnimationOptionsObject#complete
  164. * @type {Function|undefined}
  165. */ /**
  166. * The animation defer in milliseconds.
  167. * @name Highcharts.AnimationOptionsObject#defer
  168. * @type {number|undefined}
  169. */ /**
  170. * The animation duration in milliseconds.
  171. * @name Highcharts.AnimationOptionsObject#duration
  172. * @type {number|undefined}
  173. */ /**
  174. * The name of an easing function as defined on the `Math` object.
  175. * @name Highcharts.AnimationOptionsObject#easing
  176. * @type {string|Function|undefined}
  177. */ /**
  178. * A callback function to execute on each step of each attribute or CSS property
  179. * that's being animated. The first argument contains information about the
  180. * animation and progress.
  181. * @name Highcharts.AnimationOptionsObject#step
  182. * @type {Function|undefined}
  183. */
  184. /**
  185. * Creates a frame for the animated SVG element.
  186. *
  187. * @callback Highcharts.AnimationStepCallbackFunction
  188. *
  189. * @param {Highcharts.SVGElement} this
  190. * The SVG element to animate.
  191. *
  192. * @return {void}
  193. */
  194. /**
  195. * Interface description for a class.
  196. *
  197. * @interface Highcharts.Class<T>
  198. * @extends Function
  199. */ /**
  200. * Class costructor.
  201. * @function Highcharts.Class<T>#new
  202. * @param {...Array<*>} args
  203. * Constructor arguments.
  204. * @return {T}
  205. * Class instance.
  206. */
  207. /**
  208. * A style object with camel case property names to define visual appearance of
  209. * a SVG element or HTML element. The properties can be whatever styles are
  210. * supported on the given SVG or HTML element.
  211. *
  212. * @example
  213. * {
  214. * fontFamily: 'monospace',
  215. * fontSize: '1.2em'
  216. * }
  217. *
  218. * @interface Highcharts.CSSObject
  219. */ /**
  220. * @name Highcharts.CSSObject#[key:string]
  221. * @type {boolean|number|string|undefined}
  222. */ /**
  223. * Background style for the element.
  224. * @name Highcharts.CSSObject#background
  225. * @type {string|undefined}
  226. */ /**
  227. * Background color of the element.
  228. * @name Highcharts.CSSObject#backgroundColor
  229. * @type {Highcharts.ColorString|undefined}
  230. */ /**
  231. * Border style for the element.
  232. * @name Highcharts.CSSObject#border
  233. * @type {string|undefined}
  234. */ /**
  235. * Radius of the element border.
  236. * @name Highcharts.CSSObject#borderRadius
  237. * @type {number|undefined}
  238. */ /**
  239. * Color used in the element. The 'contrast' option is a Highcharts custom
  240. * property that results in black or white, depending on the background of the
  241. * element.
  242. * @name Highcharts.CSSObject#color
  243. * @type {'contrast'|Highcharts.ColorString|undefined}
  244. */ /**
  245. * Style of the mouse cursor when resting over the element.
  246. * @name Highcharts.CSSObject#cursor
  247. * @type {Highcharts.CursorValue|undefined}
  248. */ /**
  249. * Font family of the element text. Multiple values have to be in decreasing
  250. * preference order and separated by comma.
  251. * @name Highcharts.CSSObject#fontFamily
  252. * @type {string|undefined}
  253. */ /**
  254. * Font size of the element text.
  255. * @name Highcharts.CSSObject#fontSize
  256. * @type {string|undefined}
  257. */ /**
  258. * Font weight of the element text.
  259. * @name Highcharts.CSSObject#fontWeight
  260. * @type {string|undefined}
  261. */ /**
  262. * Height of the element.
  263. * @name Highcharts.CSSObject#height
  264. * @type {number|undefined}
  265. */ /**
  266. * Width of the element border.
  267. * @name Highcharts.CSSObject#lineWidth
  268. * @type {number|undefined}
  269. */ /**
  270. * Opacity of the element.
  271. * @name Highcharts.CSSObject#opacity
  272. * @type {number|undefined}
  273. */ /**
  274. * Space around the element content.
  275. * @name Highcharts.CSSObject#padding
  276. * @type {string|undefined}
  277. */ /**
  278. * Behaviour of the element when the mouse cursor rests over it.
  279. * @name Highcharts.CSSObject#pointerEvents
  280. * @type {string|undefined}
  281. */ /**
  282. * Positioning of the element.
  283. * @name Highcharts.CSSObject#position
  284. * @type {string|undefined}
  285. */ /**
  286. * Alignment of the element text.
  287. * @name Highcharts.CSSObject#textAlign
  288. * @type {string|undefined}
  289. */ /**
  290. * Additional decoration of the element text.
  291. * @name Highcharts.CSSObject#textDecoration
  292. * @type {string|undefined}
  293. */ /**
  294. * Outline style of the element text.
  295. * @name Highcharts.CSSObject#textOutline
  296. * @type {string|undefined}
  297. */ /**
  298. * Line break style of the element text. Highcharts SVG elements support
  299. * `ellipsis` when a `width` is set.
  300. * @name Highcharts.CSSObject#textOverflow
  301. * @type {string|undefined}
  302. */ /**
  303. * Top spacing of the element relative to the parent element.
  304. * @name Highcharts.CSSObject#top
  305. * @type {string|undefined}
  306. */ /**
  307. * Animated transition of selected element properties.
  308. * @name Highcharts.CSSObject#transition
  309. * @type {string|undefined}
  310. */ /**
  311. * Line break style of the element text.
  312. * @name Highcharts.CSSObject#whiteSpace
  313. * @type {string|undefined}
  314. */ /**
  315. * Width of the element.
  316. * @name Highcharts.CSSObject#width
  317. * @type {number|undefined}
  318. */
  319. /**
  320. * All possible cursor styles.
  321. *
  322. * @typedef {'alias'|'all-scroll'|'auto'|'cell'|'col-resize'|'context-menu'|'copy'|'crosshair'|'default'|'e-resize'|'ew-resize'|'grab'|'grabbing'|'help'|'move'|'n-resize'|'ne-resize'|'nesw-resize'|'no-drop'|'none'|'not-allowed'|'ns-resize'|'nw-resize'|'nwse-resize'|'pointer'|'progress'|'row-resize'|'s-resize'|'se-resize'|'sw-resize'|'text'|'vertical-text'|'w-resize'|'wait'|'zoom-in'|'zoom-out'} Highcharts.CursorValue
  323. */
  324. /**
  325. * All possible dash styles.
  326. *
  327. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  328. */
  329. /**
  330. * Generic dictionary in TypeScript notation.
  331. * Use the native `AnyRecord` instead.
  332. *
  333. * @deprecated
  334. * @interface Highcharts.Dictionary<T>
  335. */ /**
  336. * @name Highcharts.Dictionary<T>#[key:string]
  337. * @type {T}
  338. */
  339. /**
  340. * The function callback to execute when the event is fired. The `this` context
  341. * contains the instance, that fired the event.
  342. *
  343. * @callback Highcharts.EventCallbackFunction<T>
  344. *
  345. * @param {T} this
  346. *
  347. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  348. * Event arguments.
  349. *
  350. * @return {boolean|void}
  351. */
  352. /**
  353. * The event options for adding function callback.
  354. *
  355. * @interface Highcharts.EventOptionsObject
  356. */ /**
  357. * The order the event handler should be called. This opens for having one
  358. * handler be called before another, independent of in which order they were
  359. * added.
  360. * @name Highcharts.EventOptionsObject#order
  361. * @type {number}
  362. */ /**
  363. * Whether an event should be passive or not.
  364. * When set to `true`, the function specified by listener will never call
  365. * `preventDefault()`.
  366. * @name Highcharts.EventOptionsObject#passive
  367. * @type boolean
  368. */
  369. /**
  370. * Formats data as a string. Usually the data is accessible throught the `this`
  371. * keyword.
  372. *
  373. * @callback Highcharts.FormatterCallbackFunction<T>
  374. *
  375. * @param {T} this
  376. * Context to format
  377. *
  378. * @return {string}
  379. * Formatted text
  380. */
  381. /**
  382. * An object of key-value pairs for HTML attributes.
  383. *
  384. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  385. */
  386. /**
  387. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  388. * the global scope.
  389. *
  390. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  391. *
  392. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  393. */
  394. /**
  395. * The iterator callback.
  396. *
  397. * @callback Highcharts.ObjectEachCallbackFunction<T>
  398. *
  399. * @param {T} this
  400. * The context.
  401. *
  402. * @param {*} value
  403. * The property value.
  404. *
  405. * @param {string} key
  406. * The property key.
  407. *
  408. * @param {*} obj
  409. * The object that objectEach is being applied to.
  410. */
  411. /**
  412. * An object containing `left` and `top` properties for the position in the
  413. * page.
  414. *
  415. * @interface Highcharts.OffsetObject
  416. */ /**
  417. * Left distance to the page border.
  418. * @name Highcharts.OffsetObject#left
  419. * @type {number}
  420. */ /**
  421. * Top distance to the page border.
  422. * @name Highcharts.OffsetObject#top
  423. * @type {number}
  424. */
  425. /**
  426. * Describes a range.
  427. *
  428. * @interface Highcharts.RangeObject
  429. */ /**
  430. * Maximum number of the range.
  431. * @name Highcharts.RangeObject#max
  432. * @type {number}
  433. */ /**
  434. * Minimum number of the range.
  435. * @name Highcharts.RangeObject#min
  436. * @type {number}
  437. */
  438. /**
  439. * If a number is given, it defines the pixel length. If a percentage string is
  440. * given, like for example `'50%'`, the setting defines a length relative to a
  441. * base size, for example the size of a container.
  442. *
  443. * @typedef {number|string} Highcharts.RelativeSize
  444. */
  445. /**
  446. * Proceed function to call original (wrapped) function.
  447. *
  448. * @callback Highcharts.WrapProceedFunction
  449. *
  450. * @param {*} [arg1]
  451. * Optional argument. Without any arguments defaults to first argument of
  452. * the wrapping function.
  453. *
  454. * @param {*} [arg2]
  455. * Optional argument. Without any arguments defaults to second argument
  456. * of the wrapping function.
  457. *
  458. * @param {*} [arg3]
  459. * Optional argument. Without any arguments defaults to third argument of
  460. * the wrapping function.
  461. *
  462. * @return {*}
  463. * Return value of the original function.
  464. */
  465. /**
  466. * The Highcharts object is the placeholder for all other members, and various
  467. * utility functions. The most important member of the namespace would be the
  468. * chart constructor.
  469. *
  470. * @example
  471. * let chart = Highcharts.chart('container', { ... });
  472. *
  473. * @namespace Highcharts
  474. */
  475. ''; // detach doclets above
  476. /**
  477. * Provide error messages for debugging, with links to online explanation. This
  478. * function can be overridden to provide custom error handling.
  479. *
  480. * @sample highcharts/chart/highcharts-error/
  481. * Custom error handler
  482. *
  483. * @function Highcharts.error
  484. *
  485. * @param {number|string} code
  486. * The error code. See
  487. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  488. * for available codes. If it is a string, the error message is printed
  489. * directly in the console.
  490. *
  491. * @param {boolean} [stop=false]
  492. * Whether to throw an error or just log a warning in the console.
  493. *
  494. * @param {Highcharts.Chart} [chart]
  495. * Reference to the chart that causes the error. Used in 'debugger'
  496. * module to display errors directly on the chart.
  497. * Important note: This argument is undefined for errors that lack
  498. * access to the Chart instance. In such case, the error will be
  499. * displayed on the last created chart.
  500. *
  501. * @param {Highcharts.Dictionary<string>} [params]
  502. * Additional parameters for the generated message.
  503. *
  504. * @return {void}
  505. */
  506. function error(code, stop, chart, params) {
  507. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  508. if (code === 32) {
  509. code = severity + ": Deprecated member";
  510. }
  511. var isCode = isNumber(code);
  512. var message = isCode ?
  513. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  514. code.toString();
  515. var defaultHandler = function () {
  516. if (stop) {
  517. throw new Error(message);
  518. }
  519. // else ...
  520. if (win.console &&
  521. error.messages.indexOf(message) === -1 // prevent console flooting
  522. ) {
  523. console.warn(message); // eslint-disable-line no-console
  524. }
  525. };
  526. if (typeof params !== 'undefined') {
  527. var additionalMessages_1 = '';
  528. if (isCode) {
  529. message += '?';
  530. }
  531. objectEach(params, function (value, key) {
  532. additionalMessages_1 += "\n - " + key + ": " + value;
  533. if (isCode) {
  534. message += encodeURI(key) + '=' + encodeURI(value);
  535. }
  536. });
  537. message += additionalMessages_1;
  538. }
  539. fireEvent(Highcharts, 'displayError', { chart: chart, code: code, message: message, params: params }, defaultHandler);
  540. error.messages.push(message);
  541. }
  542. (function (error) {
  543. error.messages = [];
  544. })(error || (error = {}));
  545. /* eslint-disable valid-jsdoc */
  546. /**
  547. * Utility function to deep merge two or more objects and return a third object.
  548. * If the first argument is true, the contents of the second object is copied
  549. * into the first object. The merge function can also be used with a single
  550. * object argument to create a deep copy of an object.
  551. *
  552. * @function Highcharts.merge<T>
  553. *
  554. * @param {boolean} extend
  555. * Whether to extend the left-side object (a) or return a whole new
  556. * object.
  557. *
  558. * @param {T|undefined} a
  559. * The first object to extend. When only this is given, the function
  560. * returns a deep copy.
  561. *
  562. * @param {...Array<object|undefined>} [n]
  563. * An object to merge into the previous one.
  564. *
  565. * @return {T}
  566. * The merged object. If the first argument is true, the return is the
  567. * same as the second argument.
  568. */ /**
  569. * Utility function to deep merge two or more objects and return a third object.
  570. * The merge function can also be used with a single object argument to create a
  571. * deep copy of an object.
  572. *
  573. * @function Highcharts.merge<T>
  574. *
  575. * @param {T|undefined} a
  576. * The first object to extend. When only this is given, the function
  577. * returns a deep copy.
  578. *
  579. * @param {...Array<object|undefined>} [n]
  580. * An object to merge into the previous one.
  581. *
  582. * @return {T}
  583. * The merged object. If the first argument is true, the return is the
  584. * same as the second argument.
  585. */
  586. function merge() {
  587. /* eslint-enable valid-jsdoc */
  588. var i,
  589. args = arguments,
  590. ret = {};
  591. var doCopy = function (copy,
  592. original) {
  593. // An object is replacing a primitive
  594. if (typeof copy !== 'object') {
  595. copy = {};
  596. }
  597. objectEach(original, function (value, key) {
  598. // Prototype pollution (#14883)
  599. if (key === '__proto__' || key === 'constructor') {
  600. return;
  601. }
  602. // Copy the contents of objects, but not arrays or DOM nodes
  603. if (isObject(value, true) &&
  604. !isClass(value) &&
  605. !isDOMElement(value)) {
  606. copy[key] = doCopy(copy[key] || {}, value);
  607. // Primitives and arrays are copied over directly
  608. }
  609. else {
  610. copy[key] = original[key];
  611. }
  612. });
  613. return copy;
  614. };
  615. // If first argument is true, copy into the existing object. Used in
  616. // setOptions.
  617. if (args[0] === true) {
  618. ret = args[1];
  619. args = Array.prototype.slice.call(args, 2);
  620. }
  621. // For each argument, extend the return
  622. var len = args.length;
  623. for (i = 0; i < len; i++) {
  624. ret = doCopy(ret, args[i]);
  625. }
  626. return ret;
  627. }
  628. /**
  629. * Constrain a value to within a lower and upper threshold.
  630. *
  631. * @private
  632. * @param {number} value The initial value
  633. * @param {number} min The lower threshold
  634. * @param {number} max The upper threshold
  635. * @return {number} Returns a number value within min and max.
  636. */
  637. function clamp(value, min, max) {
  638. return value > min ? value < max ? value : max : min;
  639. }
  640. // eslint-disable-next-line valid-jsdoc
  641. /**
  642. * Remove settings that have not changed, to avoid unnecessary rendering or
  643. * computing (#9197).
  644. * @private
  645. */
  646. function cleanRecursively(newer, older) {
  647. var result = {};
  648. objectEach(newer, function (_val, key) {
  649. var ob;
  650. // Dive into objects (except DOM nodes)
  651. if (isObject(newer[key], true) &&
  652. !newer.nodeType && // #10044
  653. older[key]) {
  654. ob = cleanRecursively(newer[key], older[key]);
  655. if (Object.keys(ob).length) {
  656. result[key] = ob;
  657. }
  658. // Arrays, primitives and DOM nodes are copied directly
  659. }
  660. else if (isObject(newer[key]) ||
  661. newer[key] !== older[key]) {
  662. result[key] = newer[key];
  663. }
  664. });
  665. return result;
  666. }
  667. /**
  668. * Shortcut for parseInt
  669. *
  670. * @private
  671. * @function Highcharts.pInt
  672. *
  673. * @param {*} s
  674. * any
  675. *
  676. * @param {number} [mag]
  677. * Magnitude
  678. *
  679. * @return {number}
  680. * number
  681. */
  682. function pInt(s, mag) {
  683. return parseInt(s, mag || 10);
  684. }
  685. /**
  686. * Utility function to check for string type.
  687. *
  688. * @function Highcharts.isString
  689. *
  690. * @param {*} s
  691. * The item to check.
  692. *
  693. * @return {boolean}
  694. * True if the argument is a string.
  695. */
  696. function isString(s) {
  697. return typeof s === 'string';
  698. }
  699. /**
  700. * Utility function to check if an item is an array.
  701. *
  702. * @function Highcharts.isArray
  703. *
  704. * @param {*} obj
  705. * The item to check.
  706. *
  707. * @return {boolean}
  708. * True if the argument is an array.
  709. */
  710. function isArray(obj) {
  711. var str = Object.prototype.toString.call(obj);
  712. return str === '[object Array]' || str === '[object Array Iterator]';
  713. }
  714. /**
  715. * Utility function to check if an item is of type object.
  716. *
  717. * @function Highcharts.isObject
  718. *
  719. * @param {*} obj
  720. * The item to check.
  721. *
  722. * @param {boolean} [strict=false]
  723. * Also checks that the object is not an array.
  724. *
  725. * @return {boolean}
  726. * True if the argument is an object.
  727. */
  728. function isObject(obj, strict) {
  729. return (!!obj &&
  730. typeof obj === 'object' &&
  731. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  732. }
  733. /**
  734. * Utility function to check if an Object is a HTML Element.
  735. *
  736. * @function Highcharts.isDOMElement
  737. *
  738. * @param {*} obj
  739. * The item to check.
  740. *
  741. * @return {boolean}
  742. * True if the argument is a HTML Element.
  743. */
  744. function isDOMElement(obj) {
  745. return isObject(obj) && typeof obj.nodeType === 'number';
  746. }
  747. /**
  748. * Utility function to check if an Object is a class.
  749. *
  750. * @function Highcharts.isClass
  751. *
  752. * @param {object|undefined} obj
  753. * The item to check.
  754. *
  755. * @return {boolean}
  756. * True if the argument is a class.
  757. */
  758. function isClass(obj) {
  759. var c = obj && obj.constructor;
  760. return !!(isObject(obj, true) &&
  761. !isDOMElement(obj) &&
  762. (c && c.name && c.name !== 'Object'));
  763. }
  764. /**
  765. * Utility function to check if an item is a number and it is finite (not NaN,
  766. * Infinity or -Infinity).
  767. *
  768. * @function Highcharts.isNumber
  769. *
  770. * @param {*} n
  771. * The item to check.
  772. *
  773. * @return {boolean}
  774. * True if the item is a finite number
  775. */
  776. function isNumber(n) {
  777. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  778. }
  779. /**
  780. * Remove the last occurence of an item from an array.
  781. *
  782. * @function Highcharts.erase
  783. *
  784. * @param {Array<*>} arr
  785. * The array.
  786. *
  787. * @param {*} item
  788. * The item to remove.
  789. *
  790. * @return {void}
  791. */
  792. function erase(arr, item) {
  793. var i = arr.length;
  794. while (i--) {
  795. if (arr[i] === item) {
  796. arr.splice(i, 1);
  797. break;
  798. }
  799. }
  800. }
  801. /**
  802. * Check if an object is null or undefined.
  803. *
  804. * @function Highcharts.defined
  805. *
  806. * @param {*} obj
  807. * The object to check.
  808. *
  809. * @return {boolean}
  810. * False if the object is null or undefined, otherwise true.
  811. */
  812. function defined(obj) {
  813. return typeof obj !== 'undefined' && obj !== null;
  814. }
  815. /**
  816. * Set or get an attribute or an object of attributes. To use as a setter, pass
  817. * a key and a value, or let the second argument be a collection of keys and
  818. * values. To use as a getter, pass only a string as the second argument.
  819. *
  820. * @function Highcharts.attr
  821. *
  822. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  823. * The DOM element to receive the attribute(s).
  824. *
  825. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  826. * The property or an object of key-value pairs.
  827. *
  828. * @param {number|string} [value]
  829. * The value if a single property is set.
  830. *
  831. * @return {string|null|undefined}
  832. * When used as a getter, return the value.
  833. */
  834. function attr(elem, prop, value) {
  835. var ret;
  836. // if the prop is a string
  837. if (isString(prop)) {
  838. // set the value
  839. if (defined(value)) {
  840. elem.setAttribute(prop, value);
  841. // get the value
  842. }
  843. else if (elem && elem.getAttribute) {
  844. ret = elem.getAttribute(prop);
  845. // IE7 and below cannot get class through getAttribute (#7850)
  846. if (!ret && prop === 'class') {
  847. ret = elem.getAttribute(prop + 'Name');
  848. }
  849. }
  850. // else if prop is defined, it is a hash of key/value pairs
  851. }
  852. else {
  853. objectEach(prop, function (val, key) {
  854. elem.setAttribute(key, val);
  855. });
  856. }
  857. return ret;
  858. }
  859. /**
  860. * Check if an element is an array, and if not, make it into an array.
  861. *
  862. * @function Highcharts.splat
  863. *
  864. * @param {*} obj
  865. * The object to splat.
  866. *
  867. * @return {Array}
  868. * The produced or original array.
  869. */
  870. function splat(obj) {
  871. return isArray(obj) ? obj : [obj];
  872. }
  873. /**
  874. * Set a timeout if the delay is given, otherwise perform the function
  875. * synchronously.
  876. *
  877. * @function Highcharts.syncTimeout
  878. *
  879. * @param {Function} fn
  880. * The function callback.
  881. *
  882. * @param {number} delay
  883. * Delay in milliseconds.
  884. *
  885. * @param {*} [context]
  886. * An optional context to send to the function callback.
  887. *
  888. * @return {number}
  889. * An identifier for the timeout that can later be cleared with
  890. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  891. */
  892. function syncTimeout(fn, delay, context) {
  893. if (delay > 0) {
  894. return setTimeout(fn, delay, context);
  895. }
  896. fn.call(0, context);
  897. return -1;
  898. }
  899. /**
  900. * Internal clear timeout. The function checks that the `id` was not removed
  901. * (e.g. by `chart.destroy()`). For the details see
  902. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  903. *
  904. * @function Highcharts.clearTimeout
  905. *
  906. * @param {number} id
  907. * Id of a timeout.
  908. *
  909. * @return {void}
  910. */
  911. function internalClearTimeout(id) {
  912. if (defined(id)) {
  913. clearTimeout(id);
  914. }
  915. }
  916. /* eslint-disable valid-jsdoc */
  917. /**
  918. * Utility function to extend an object with the members of another.
  919. *
  920. * @function Highcharts.extend<T>
  921. *
  922. * @param {T|undefined} a
  923. * The object to be extended.
  924. *
  925. * @param {Partial<T>} b
  926. * The object to add to the first one.
  927. *
  928. * @return {T}
  929. * Object a, the original object.
  930. */
  931. function extend(a, b) {
  932. /* eslint-enable valid-jsdoc */
  933. var n;
  934. if (!a) {
  935. a = {};
  936. }
  937. for (n in b) { // eslint-disable-line guard-for-in
  938. a[n] = b[n];
  939. }
  940. return a;
  941. }
  942. /* eslint-disable valid-jsdoc */
  943. /**
  944. * Return the first value that is not null or undefined.
  945. *
  946. * @function Highcharts.pick<T>
  947. *
  948. * @param {...Array<T|null|undefined>} items
  949. * Variable number of arguments to inspect.
  950. *
  951. * @return {T}
  952. * The value of the first argument that is not null or undefined.
  953. */
  954. function pick() {
  955. var args = arguments;
  956. var length = args.length;
  957. for (var i = 0; i < length; i++) {
  958. var arg = args[i];
  959. if (typeof arg !== 'undefined' && arg !== null) {
  960. return arg;
  961. }
  962. }
  963. }
  964. /**
  965. * Set CSS on a given element.
  966. *
  967. * @function Highcharts.css
  968. *
  969. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  970. * An HTML DOM element.
  971. *
  972. * @param {Highcharts.CSSObject} styles
  973. * Style object with camel case property names.
  974. *
  975. * @return {void}
  976. */
  977. function css(el, styles) {
  978. if (H.isMS && !H.svg) { // #2686
  979. if (styles && typeof styles.opacity !== 'undefined') {
  980. styles.filter =
  981. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  982. }
  983. }
  984. extend(el.style, styles);
  985. }
  986. /**
  987. * Utility function to create an HTML element with attributes and styles.
  988. *
  989. * @function Highcharts.createElement
  990. *
  991. * @param {string} tag
  992. * The HTML tag.
  993. *
  994. * @param {Highcharts.HTMLAttributes} [attribs]
  995. * Attributes as an object of key-value pairs.
  996. *
  997. * @param {Highcharts.CSSObject} [styles]
  998. * Styles as an object of key-value pairs.
  999. *
  1000. * @param {Highcharts.HTMLDOMElement} [parent]
  1001. * The parent HTML object.
  1002. *
  1003. * @param {boolean} [nopad=false]
  1004. * If true, remove all padding, border and margin.
  1005. *
  1006. * @return {Highcharts.HTMLDOMElement}
  1007. * The created DOM element.
  1008. */
  1009. function createElement(tag, attribs, styles, parent, nopad) {
  1010. var el = doc.createElement(tag);
  1011. if (attribs) {
  1012. extend(el, attribs);
  1013. }
  1014. if (nopad) {
  1015. css(el, { padding: '0', border: 'none', margin: '0' });
  1016. }
  1017. if (styles) {
  1018. css(el, styles);
  1019. }
  1020. if (parent) {
  1021. parent.appendChild(el);
  1022. }
  1023. return el;
  1024. }
  1025. // eslint-disable-next-line valid-jsdoc
  1026. /**
  1027. * Extend a prototyped class by new members.
  1028. *
  1029. * @function Highcharts.extendClass<T>
  1030. *
  1031. * @param {Highcharts.Class<T>} parent
  1032. * The parent prototype to inherit.
  1033. *
  1034. * @param {Highcharts.Dictionary<*>} members
  1035. * A collection of prototype members to add or override compared to the
  1036. * parent prototype.
  1037. *
  1038. * @return {Highcharts.Class<T>}
  1039. * A new prototype.
  1040. */
  1041. function extendClass(parent, members) {
  1042. var obj = (function () { });
  1043. obj.prototype = new parent(); // eslint-disable-line new-cap
  1044. extend(obj.prototype, members);
  1045. return obj;
  1046. }
  1047. /**
  1048. * Left-pad a string to a given length by adding a character repetetively.
  1049. *
  1050. * @function Highcharts.pad
  1051. *
  1052. * @param {number} number
  1053. * The input string or number.
  1054. *
  1055. * @param {number} [length]
  1056. * The desired string length.
  1057. *
  1058. * @param {string} [padder=0]
  1059. * The character to pad with.
  1060. *
  1061. * @return {string}
  1062. * The padded string.
  1063. */
  1064. function pad(number, length, padder) {
  1065. return new Array((length || 2) +
  1066. 1 -
  1067. String(number)
  1068. .replace('-', '')
  1069. .length).join(padder || '0') + number;
  1070. }
  1071. /**
  1072. * Return a length based on either the integer value, or a percentage of a base.
  1073. *
  1074. * @function Highcharts.relativeLength
  1075. *
  1076. * @param {Highcharts.RelativeSize} value
  1077. * A percentage string or a number.
  1078. *
  1079. * @param {number} base
  1080. * The full length that represents 100%.
  1081. *
  1082. * @param {number} [offset=0]
  1083. * A pixel offset to apply for percentage values. Used internally in
  1084. * axis positioning.
  1085. *
  1086. * @return {number}
  1087. * The computed length.
  1088. */
  1089. function relativeLength(value, base, offset) {
  1090. return (/%$/).test(value) ?
  1091. (base * parseFloat(value) / 100) + (offset || 0) :
  1092. parseFloat(value);
  1093. }
  1094. /**
  1095. * Wrap a method with extended functionality, preserving the original function.
  1096. *
  1097. * @function Highcharts.wrap
  1098. *
  1099. * @param {*} obj
  1100. * The context object that the method belongs to. In real cases, this is
  1101. * often a prototype.
  1102. *
  1103. * @param {string} method
  1104. * The name of the method to extend.
  1105. *
  1106. * @param {Highcharts.WrapProceedFunction} func
  1107. * A wrapper function callback. This function is called with the same
  1108. * arguments as the original function, except that the original function
  1109. * is unshifted and passed as the first argument.
  1110. */
  1111. function wrap(obj, method, func) {
  1112. var proceed = obj[method];
  1113. obj[method] = function () {
  1114. var args = Array.prototype.slice.call(arguments),
  1115. outerArgs = arguments,
  1116. ctx = this;
  1117. ctx.proceed = function () {
  1118. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1119. };
  1120. args.unshift(proceed);
  1121. var ret = func.apply(this,
  1122. args);
  1123. ctx.proceed = null;
  1124. return ret;
  1125. };
  1126. }
  1127. /**
  1128. * Get the magnitude of a number.
  1129. *
  1130. * @function Highcharts.getMagnitude
  1131. *
  1132. * @param {number} num
  1133. * The number.
  1134. *
  1135. * @return {number}
  1136. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1137. */
  1138. function getMagnitude(num) {
  1139. return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
  1140. }
  1141. /**
  1142. * Take an interval and normalize it to multiples of round numbers.
  1143. *
  1144. * @deprecated
  1145. * @function Highcharts.normalizeTickInterval
  1146. *
  1147. * @param {number} interval
  1148. * The raw, un-rounded interval.
  1149. *
  1150. * @param {Array<*>} [multiples]
  1151. * Allowed multiples.
  1152. *
  1153. * @param {number} [magnitude]
  1154. * The magnitude of the number.
  1155. *
  1156. * @param {boolean} [allowDecimals]
  1157. * Whether to allow decimals.
  1158. *
  1159. * @param {boolean} [hasTickAmount]
  1160. * If it has tickAmount, avoid landing on tick intervals lower than
  1161. * original.
  1162. *
  1163. * @return {number}
  1164. * The normalized interval.
  1165. *
  1166. * @todo
  1167. * Move this function to the Axis prototype. It is here only for historical
  1168. * reasons.
  1169. */
  1170. function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) {
  1171. var i,
  1172. retInterval = interval;
  1173. // round to a tenfold of 1, 2, 2.5 or 5
  1174. magnitude = pick(magnitude, 1);
  1175. var normalized = interval / magnitude;
  1176. // multiples for a linear scale
  1177. if (!multiples) {
  1178. multiples = hasTickAmount ?
  1179. // Finer grained ticks when the tick amount is hard set, including
  1180. // when alignTicks is true on multiple axes (#4580).
  1181. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1182. // Else, let ticks fall on rounder numbers
  1183. [1, 2, 2.5, 5, 10];
  1184. // the allowDecimals option
  1185. if (allowDecimals === false) {
  1186. if (magnitude === 1) {
  1187. multiples = multiples.filter(function (num) {
  1188. return num % 1 === 0;
  1189. });
  1190. }
  1191. else if (magnitude <= 0.1) {
  1192. multiples = [1 / magnitude];
  1193. }
  1194. }
  1195. }
  1196. // normalize the interval to the nearest multiple
  1197. for (i = 0; i < multiples.length; i++) {
  1198. retInterval = multiples[i];
  1199. // only allow tick amounts smaller than natural
  1200. if ((hasTickAmount &&
  1201. retInterval * magnitude >= interval) ||
  1202. (!hasTickAmount &&
  1203. (normalized <=
  1204. (multiples[i] +
  1205. (multiples[i + 1] || multiples[i])) / 2))) {
  1206. break;
  1207. }
  1208. }
  1209. // Multiply back to the correct magnitude. Correct floats to appropriate
  1210. // precision (#6085).
  1211. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1212. return retInterval;
  1213. }
  1214. /**
  1215. * Sort an object array and keep the order of equal items. The ECMAScript
  1216. * standard does not specify the behaviour when items are equal.
  1217. *
  1218. * @function Highcharts.stableSort
  1219. *
  1220. * @param {Array<*>} arr
  1221. * The array to sort.
  1222. *
  1223. * @param {Function} sortFunction
  1224. * The function to sort it with, like with regular Array.prototype.sort.
  1225. *
  1226. * @return {void}
  1227. */
  1228. function stableSort(arr, sortFunction) {
  1229. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1230. // plus all other browsers do it, so over time we may be able to remove this
  1231. // function
  1232. var length = arr.length;
  1233. var sortValue,
  1234. i;
  1235. // Add index to each item
  1236. for (i = 0; i < length; i++) {
  1237. arr[i].safeI = i; // stable sort index
  1238. }
  1239. arr.sort(function (a, b) {
  1240. sortValue = sortFunction(a, b);
  1241. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1242. });
  1243. // Remove index from items
  1244. for (i = 0; i < length; i++) {
  1245. delete arr[i].safeI; // stable sort index
  1246. }
  1247. }
  1248. /**
  1249. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1250. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1251. * than 150.000 points. This method is slightly slower, but safe.
  1252. *
  1253. * @function Highcharts.arrayMin
  1254. *
  1255. * @param {Array<*>} data
  1256. * An array of numbers.
  1257. *
  1258. * @return {number}
  1259. * The lowest number.
  1260. */
  1261. function arrayMin(data) {
  1262. var i = data.length,
  1263. min = data[0];
  1264. while (i--) {
  1265. if (data[i] < min) {
  1266. min = data[i];
  1267. }
  1268. }
  1269. return min;
  1270. }
  1271. /**
  1272. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1273. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1274. * than 150.000 points. This method is slightly slower, but safe.
  1275. *
  1276. * @function Highcharts.arrayMax
  1277. *
  1278. * @param {Array<*>} data
  1279. * An array of numbers.
  1280. *
  1281. * @return {number}
  1282. * The highest number.
  1283. */
  1284. function arrayMax(data) {
  1285. var i = data.length,
  1286. max = data[0];
  1287. while (i--) {
  1288. if (data[i] > max) {
  1289. max = data[i];
  1290. }
  1291. }
  1292. return max;
  1293. }
  1294. /**
  1295. * Utility method that destroys any SVGElement instances that are properties on
  1296. * the given object. It loops all properties and invokes destroy if there is a
  1297. * destroy method. The property is then delete.
  1298. *
  1299. * @function Highcharts.destroyObjectProperties
  1300. *
  1301. * @param {*} obj
  1302. * The object to destroy properties on.
  1303. *
  1304. * @param {*} [except]
  1305. * Exception, do not destroy this property, only delete it.
  1306. */
  1307. function destroyObjectProperties(obj, except) {
  1308. objectEach(obj, function (val, n) {
  1309. // If the object is non-null and destroy is defined
  1310. if (val && val !== except && val.destroy) {
  1311. // Invoke the destroy
  1312. val.destroy();
  1313. }
  1314. // Delete the property from the object.
  1315. delete obj[n];
  1316. });
  1317. }
  1318. /**
  1319. * Discard a HTML element by moving it to the bin and delete.
  1320. *
  1321. * @function Highcharts.discardElement
  1322. *
  1323. * @param {Highcharts.HTMLDOMElement} element
  1324. * The HTML node to discard.
  1325. */
  1326. function discardElement(element) {
  1327. // create a garbage bin element, not part of the DOM
  1328. if (!garbageBin) {
  1329. garbageBin = createElement('div');
  1330. }
  1331. // move the node and empty bin
  1332. if (element) {
  1333. garbageBin.appendChild(element);
  1334. }
  1335. garbageBin.innerHTML = '';
  1336. }
  1337. var garbageBin;
  1338. /**
  1339. * Fix JS round off float errors.
  1340. *
  1341. * @function Highcharts.correctFloat
  1342. *
  1343. * @param {number} num
  1344. * A float number to fix.
  1345. *
  1346. * @param {number} [prec=14]
  1347. * The precision.
  1348. *
  1349. * @return {number}
  1350. * The corrected float number.
  1351. */
  1352. function correctFloat(num, prec) {
  1353. return parseFloat(num.toPrecision(prec || 14));
  1354. }
  1355. /**
  1356. * The time unit lookup
  1357. *
  1358. * @ignore
  1359. */
  1360. var timeUnits = {
  1361. millisecond: 1,
  1362. second: 1000,
  1363. minute: 60000,
  1364. hour: 3600000,
  1365. day: 24 * 3600000,
  1366. week: 7 * 24 * 3600000,
  1367. month: 28 * 24 * 3600000,
  1368. year: 364 * 24 * 3600000
  1369. };
  1370. /**
  1371. * Easing definition
  1372. *
  1373. * @private
  1374. * @function Math.easeInOutSine
  1375. *
  1376. * @param {number} pos
  1377. * Current position, ranging from 0 to 1.
  1378. *
  1379. * @return {number}
  1380. * Ease result
  1381. */
  1382. Math.easeInOutSine = function (pos) {
  1383. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1384. };
  1385. /**
  1386. * Returns the value of a property path on a given object.
  1387. *
  1388. * @private
  1389. * @function getNestedProperty
  1390. *
  1391. * @param {string} path
  1392. * Path to the property, for example `custom.myValue`.
  1393. *
  1394. * @param {unknown} obj
  1395. * Instance containing the property on the specific path.
  1396. *
  1397. * @return {unknown}
  1398. * The unknown property value.
  1399. */
  1400. function getNestedProperty(path, parent) {
  1401. var pathElements = path.split('.');
  1402. while (pathElements.length && defined(parent)) {
  1403. var pathElement = pathElements.shift();
  1404. // Filter on the key
  1405. if (typeof pathElement === 'undefined' ||
  1406. pathElement === '__proto__') {
  1407. return; // undefined
  1408. }
  1409. var child = parent[pathElement];
  1410. // Filter on the child
  1411. if (!defined(child) ||
  1412. typeof child === 'function' ||
  1413. typeof child.nodeType === 'number' ||
  1414. child === win) {
  1415. return; // undefined
  1416. }
  1417. // Else, proceed
  1418. parent = child;
  1419. }
  1420. return parent;
  1421. }
  1422. /**
  1423. * Get the computed CSS value for given element and property, only for numerical
  1424. * properties. For width and height, the dimension of the inner box (excluding
  1425. * padding) is returned. Used for fitting the chart within the container.
  1426. *
  1427. * @function Highcharts.getStyle
  1428. *
  1429. * @param {Highcharts.HTMLDOMElement} el
  1430. * An HTML element.
  1431. *
  1432. * @param {string} prop
  1433. * The property name.
  1434. *
  1435. * @param {boolean} [toInt=true]
  1436. * Parse to integer.
  1437. *
  1438. * @return {number|string|undefined}
  1439. * The style value.
  1440. */
  1441. function getStyle(el, prop, toInt) {
  1442. var customGetStyle = (H.getStyle || // oldie getStyle
  1443. getStyle);
  1444. var style;
  1445. // For width and height, return the actual inner pixel size (#4913)
  1446. if (prop === 'width') {
  1447. var offsetWidth = Math.min(el.offsetWidth,
  1448. el.scrollWidth);
  1449. // In flex boxes, we need to use getBoundingClientRect and floor it,
  1450. // because scrollWidth doesn't support subpixel precision (#6427) ...
  1451. var boundingClientRectWidth = el.getBoundingClientRect &&
  1452. el.getBoundingClientRect().width;
  1453. // ...unless if the containing div or its parents are transform-scaled
  1454. // down, in which case the boundingClientRect can't be used as it is
  1455. // also scaled down (#9871, #10498).
  1456. if (boundingClientRectWidth < offsetWidth &&
  1457. boundingClientRectWidth >= offsetWidth - 1) {
  1458. offsetWidth = Math.floor(boundingClientRectWidth);
  1459. }
  1460. return Math.max(0, // #8377
  1461. (offsetWidth -
  1462. (customGetStyle(el, 'padding-left', true) || 0) -
  1463. (customGetStyle(el, 'padding-right', true) || 0)));
  1464. }
  1465. if (prop === 'height') {
  1466. return Math.max(0, // #8377
  1467. (Math.min(el.offsetHeight, el.scrollHeight) -
  1468. (customGetStyle(el, 'padding-top', true) || 0) -
  1469. (customGetStyle(el, 'padding-bottom', true) || 0)));
  1470. }
  1471. if (!win.getComputedStyle) {
  1472. // SVG not supported, forgot to load oldie.js?
  1473. error(27, true);
  1474. }
  1475. // Otherwise, get the computed style
  1476. var css = win.getComputedStyle(el,
  1477. undefined); // eslint-disable-line no-undefined
  1478. if (css) {
  1479. style = css.getPropertyValue(prop);
  1480. if (pick(toInt, prop !== 'opacity')) {
  1481. style = pInt(style);
  1482. }
  1483. }
  1484. return style;
  1485. }
  1486. /**
  1487. * Search for an item in an array.
  1488. *
  1489. * @function Highcharts.inArray
  1490. *
  1491. * @deprecated
  1492. *
  1493. * @param {*} item
  1494. * The item to search for.
  1495. *
  1496. * @param {Array<*>} arr
  1497. * The array or node collection to search in.
  1498. *
  1499. * @param {number} [fromIndex=0]
  1500. * The index to start searching from.
  1501. *
  1502. * @return {number}
  1503. * The index within the array, or -1 if not found.
  1504. */
  1505. function inArray(item, arr, fromIndex) {
  1506. error(32, false, void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  1507. return arr.indexOf(item, fromIndex);
  1508. }
  1509. /* eslint-disable valid-jsdoc */
  1510. /**
  1511. * Return the value of the first element in the array that satisfies the
  1512. * provided testing function.
  1513. *
  1514. * @function Highcharts.find<T>
  1515. *
  1516. * @param {Array<T>} arr
  1517. * The array to test.
  1518. *
  1519. * @param {Function} callback
  1520. * The callback function. The function receives the item as the first
  1521. * argument. Return `true` if this item satisfies the condition.
  1522. *
  1523. * @return {T|undefined}
  1524. * The value of the element.
  1525. */
  1526. var find = Array.prototype.find ?
  1527. /* eslint-enable valid-jsdoc */
  1528. function (arr,
  1529. callback) {
  1530. return arr.find(callback);
  1531. } :
  1532. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1533. function (arr, callback) {
  1534. var i;
  1535. var length = arr.length;
  1536. for (i = 0; i < length; i++) {
  1537. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1538. return arr[i];
  1539. }
  1540. }
  1541. };
  1542. /**
  1543. * Returns an array of a given object's own properties.
  1544. *
  1545. * @function Highcharts.keys
  1546. * @deprecated
  1547. *
  1548. * @param {*} obj
  1549. * The object of which the properties are to be returned.
  1550. *
  1551. * @return {Array<string>}
  1552. * An array of strings that represents all the properties.
  1553. */
  1554. function keys(obj) {
  1555. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1556. return Object.keys(obj);
  1557. }
  1558. /**
  1559. * Get the element's offset position, corrected for `overflow: auto`.
  1560. *
  1561. * @function Highcharts.offset
  1562. *
  1563. * @param {global.Element} el
  1564. * The DOM element.
  1565. *
  1566. * @return {Highcharts.OffsetObject}
  1567. * An object containing `left` and `top` properties for the position in
  1568. * the page.
  1569. */
  1570. function offset(el) {
  1571. var docElem = doc.documentElement,
  1572. box = (el.parentElement || el.parentNode) ?
  1573. el.getBoundingClientRect() :
  1574. { top: 0,
  1575. left: 0,
  1576. width: 0,
  1577. height: 0 };
  1578. return {
  1579. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1580. (docElem.clientTop || 0),
  1581. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1582. (docElem.clientLeft || 0),
  1583. width: box.width,
  1584. height: box.height
  1585. };
  1586. }
  1587. /* eslint-disable valid-jsdoc */
  1588. /**
  1589. * Iterate over object key pairs in an object.
  1590. *
  1591. * @function Highcharts.objectEach<T>
  1592. *
  1593. * @param {*} obj
  1594. * The object to iterate over.
  1595. *
  1596. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1597. * The iterator callback. It passes three arguments:
  1598. * * value - The property value.
  1599. * * key - The property key.
  1600. * * obj - The object that objectEach is being applied to.
  1601. *
  1602. * @param {T} [ctx]
  1603. * The context.
  1604. *
  1605. * @return {void}
  1606. */
  1607. function objectEach(obj, fn, ctx) {
  1608. /* eslint-enable valid-jsdoc */
  1609. for (var key in obj) {
  1610. if (Object.hasOwnProperty.call(obj, key)) {
  1611. fn.call(ctx || obj[key], obj[key], key, obj);
  1612. }
  1613. }
  1614. }
  1615. /**
  1616. * Iterate over an array.
  1617. *
  1618. * @deprecated
  1619. * @function Highcharts.each
  1620. *
  1621. * @param {Array<*>} arr
  1622. * The array to iterate over.
  1623. *
  1624. * @param {Function} fn
  1625. * The iterator callback. It passes three arguments:
  1626. * - `item`: The array item.
  1627. * - `index`: The item's index in the array.
  1628. * - `arr`: The array that each is being applied to.
  1629. *
  1630. * @param {*} [ctx]
  1631. * The context.
  1632. *
  1633. * @return {void}
  1634. */
  1635. /**
  1636. * Filter an array by a callback.
  1637. *
  1638. * @deprecated
  1639. * @function Highcharts.grep
  1640. *
  1641. * @param {Array<*>} arr
  1642. * The array to filter.
  1643. *
  1644. * @param {Function} callback
  1645. * The callback function. The function receives the item as the first
  1646. * argument. Return `true` if the item is to be preserved.
  1647. *
  1648. * @return {Array<*>}
  1649. * A new, filtered array.
  1650. */
  1651. /**
  1652. * Map an array by a callback.
  1653. *
  1654. * @deprecated
  1655. * @function Highcharts.map
  1656. *
  1657. * @param {Array<*>} arr
  1658. * The array to map.
  1659. *
  1660. * @param {Function} fn
  1661. * The callback function. Return the new value for the new array.
  1662. *
  1663. * @return {Array<*>}
  1664. * A new array item with modified items.
  1665. */
  1666. /**
  1667. * Reduce an array to a single value.
  1668. *
  1669. * @deprecated
  1670. * @function Highcharts.reduce
  1671. *
  1672. * @param {Array<*>} arr
  1673. * The array to reduce.
  1674. *
  1675. * @param {Function} fn
  1676. * The callback function. Return the reduced value. Receives 4
  1677. * arguments: Accumulated/reduced value, current value, current array
  1678. * index, and the array.
  1679. *
  1680. * @param {*} initialValue
  1681. * The initial value of the accumulator.
  1682. *
  1683. * @return {*}
  1684. * The reduced value.
  1685. */
  1686. /**
  1687. * Test whether at least one element in the array passes the test implemented by
  1688. * the provided function.
  1689. *
  1690. * @deprecated
  1691. * @function Highcharts.some
  1692. *
  1693. * @param {Array<*>} arr
  1694. * The array to test
  1695. *
  1696. * @param {Function} fn
  1697. * The function to run on each item. Return truty to pass the test.
  1698. * Receives arguments `currentValue`, `index` and `array`.
  1699. *
  1700. * @param {*} ctx
  1701. * The context.
  1702. *
  1703. * @return {boolean}
  1704. */
  1705. objectEach({
  1706. map: 'map',
  1707. each: 'forEach',
  1708. grep: 'filter',
  1709. reduce: 'reduce',
  1710. some: 'some'
  1711. }, function (val, key) {
  1712. H[key] = function (arr) {
  1713. var _a;
  1714. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1715. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1716. };
  1717. });
  1718. /* eslint-disable valid-jsdoc */
  1719. /**
  1720. * Add an event listener.
  1721. *
  1722. * @function Highcharts.addEvent<T>
  1723. *
  1724. * @param {Highcharts.Class<T>|T} el
  1725. * The element or object to add a listener to. It can be a
  1726. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1727. *
  1728. * @param {string} type
  1729. * The event type.
  1730. *
  1731. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1732. * The function callback to execute when the event is fired.
  1733. *
  1734. * @param {Highcharts.EventOptionsObject} [options]
  1735. * Options for adding the event.
  1736. *
  1737. * @return {Function}
  1738. * A callback function to remove the added event.
  1739. */
  1740. function addEvent(el, type, fn, options) {
  1741. /* eslint-enable valid-jsdoc */
  1742. if (options === void 0) { options = {}; }
  1743. // Add hcEvents to either the prototype (in case we're running addEvent on a
  1744. // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
  1745. // inherited down the prototype chain, in which case we need to set the
  1746. // property on this instance (which may itself be a prototype).
  1747. var owner = typeof el === 'function' && el.prototype || el;
  1748. if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1749. owner.hcEvents = {};
  1750. }
  1751. var events = owner.hcEvents;
  1752. // Allow click events added to points, otherwise they will be prevented by
  1753. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1754. if (H.Point && // without H a dependency loop occurs
  1755. el instanceof H.Point &&
  1756. el.series &&
  1757. el.series.chart) {
  1758. el.series.chart.runTrackerClick = true;
  1759. }
  1760. // Handle DOM events
  1761. // If the browser supports passive events, add it to improve performance
  1762. // on touch events (#11353).
  1763. var addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1764. if (addEventListener) {
  1765. addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
  1766. passive: options.passive === void 0 ?
  1767. type.indexOf('touch') !== -1 : options.passive,
  1768. capture: false
  1769. } : false);
  1770. }
  1771. if (!events[type]) {
  1772. events[type] = [];
  1773. }
  1774. var eventObject = {
  1775. fn: fn,
  1776. order: typeof options.order === 'number' ? options.order : Infinity
  1777. };
  1778. events[type].push(eventObject);
  1779. // Order the calls
  1780. events[type].sort(function (a, b) { return a.order - b.order; });
  1781. // Return a function that can be called to remove this event.
  1782. return function () {
  1783. removeEvent(el, type, fn);
  1784. };
  1785. }
  1786. /* eslint-disable valid-jsdoc */
  1787. /**
  1788. * Remove an event that was added with {@link Highcharts#addEvent}.
  1789. *
  1790. * @function Highcharts.removeEvent<T>
  1791. *
  1792. * @param {Highcharts.Class<T>|T} el
  1793. * The element to remove events on.
  1794. *
  1795. * @param {string} [type]
  1796. * The type of events to remove. If undefined, all events are removed
  1797. * from the element.
  1798. *
  1799. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1800. * The specific callback to remove. If undefined, all events that match
  1801. * the element and optionally the type are removed.
  1802. *
  1803. * @return {void}
  1804. */
  1805. function removeEvent(el, type, fn) {
  1806. /* eslint-enable valid-jsdoc */
  1807. /**
  1808. * @private
  1809. * @param {string} type - event type
  1810. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1811. * @return {void}
  1812. */
  1813. function removeOneEvent(type, fn) {
  1814. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1815. if (removeEventListener) {
  1816. removeEventListener.call(el, type, fn, false);
  1817. }
  1818. }
  1819. /**
  1820. * @private
  1821. * @param {any} eventCollection - collection
  1822. * @return {void}
  1823. */
  1824. function removeAllEvents(eventCollection) {
  1825. var types,
  1826. len;
  1827. if (!el.nodeName) {
  1828. return; // break on non-DOM events
  1829. }
  1830. if (type) {
  1831. types = {};
  1832. types[type] = true;
  1833. }
  1834. else {
  1835. types = eventCollection;
  1836. }
  1837. objectEach(types, function (_val, n) {
  1838. if (eventCollection[n]) {
  1839. len = eventCollection[n].length;
  1840. while (len--) {
  1841. removeOneEvent(n, eventCollection[n][len].fn);
  1842. }
  1843. }
  1844. });
  1845. }
  1846. var owner = typeof el === 'function' && el.prototype || el;
  1847. if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1848. var events = owner.hcEvents;
  1849. if (type) {
  1850. var typeEvents = (events[type] || []);
  1851. if (fn) {
  1852. events[type] = typeEvents.filter(function (obj) {
  1853. return fn !== obj.fn;
  1854. });
  1855. removeOneEvent(type, fn);
  1856. }
  1857. else {
  1858. removeAllEvents(events);
  1859. events[type] = [];
  1860. }
  1861. }
  1862. else {
  1863. removeAllEvents(events);
  1864. delete owner.hcEvents;
  1865. }
  1866. }
  1867. }
  1868. /* eslint-disable valid-jsdoc */
  1869. /**
  1870. * Fire an event that was registered with {@link Highcharts#addEvent}.
  1871. *
  1872. * @function Highcharts.fireEvent<T>
  1873. *
  1874. * @param {T} el
  1875. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  1876. * an {@link SVGElement} or any other object.
  1877. *
  1878. * @param {string} type
  1879. * The type of event.
  1880. *
  1881. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  1882. * Custom event arguments that are passed on as an argument to the event
  1883. * handler.
  1884. *
  1885. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  1886. * The default function to execute if the other listeners haven't
  1887. * returned false.
  1888. *
  1889. * @return {void}
  1890. */
  1891. function fireEvent(el, type, eventArguments, defaultFunction) {
  1892. /* eslint-enable valid-jsdoc */
  1893. var e,
  1894. i;
  1895. eventArguments = eventArguments || {};
  1896. if (doc.createEvent &&
  1897. (el.dispatchEvent ||
  1898. (el.fireEvent &&
  1899. // Enable firing events on Highcharts instance.
  1900. el !== H))) {
  1901. e = doc.createEvent('Events');
  1902. e.initEvent(type, true, true);
  1903. eventArguments = extend(e, eventArguments);
  1904. if (el.dispatchEvent) {
  1905. el.dispatchEvent(eventArguments);
  1906. }
  1907. else {
  1908. el.fireEvent(type, eventArguments);
  1909. }
  1910. }
  1911. else if (el.hcEvents) {
  1912. if (!eventArguments.target) {
  1913. // We're running a custom event
  1914. extend(eventArguments, {
  1915. // Attach a simple preventDefault function to skip
  1916. // default handler if called. The built-in
  1917. // defaultPrevented property is not overwritable (#5112)
  1918. preventDefault: function () {
  1919. eventArguments.defaultPrevented = true;
  1920. },
  1921. // Setting target to native events fails with clicking
  1922. // the zoom-out button in Chrome.
  1923. target: el,
  1924. // If the type is not set, we're running a custom event
  1925. // (#2297). If it is set, we're running a browser event,
  1926. // and setting it will cause en error in IE8 (#2465).
  1927. type: type
  1928. });
  1929. }
  1930. var events = [];
  1931. var object = el;
  1932. var multilevel = false;
  1933. // Recurse up the inheritance chain and collect hcEvents set as own
  1934. // objects on the prototypes.
  1935. while (object.hcEvents) {
  1936. if (Object.hasOwnProperty.call(object, 'hcEvents') &&
  1937. object.hcEvents[type]) {
  1938. if (events.length) {
  1939. multilevel = true;
  1940. }
  1941. events.unshift.apply(events, object.hcEvents[type]);
  1942. }
  1943. object = Object.getPrototypeOf(object);
  1944. }
  1945. // For performance reasons, only sort the event handlers in case we are
  1946. // dealing with multiple levels in the prototype chain. Otherwise, the
  1947. // events are already sorted in the addEvent function.
  1948. if (multilevel) {
  1949. // Order the calls
  1950. events.sort(function (a, b) { return a.order - b.order; });
  1951. }
  1952. // Call the collected event handlers
  1953. events.forEach(function (obj) {
  1954. // If the event handler returns false, prevent the default handler
  1955. // from executing
  1956. if (obj.fn.call(el, eventArguments) === false) {
  1957. eventArguments.preventDefault();
  1958. }
  1959. });
  1960. }
  1961. // Run the default if not prevented
  1962. if (defaultFunction && !eventArguments.defaultPrevented) {
  1963. defaultFunction.call(el, eventArguments);
  1964. }
  1965. }
  1966. var serialMode;
  1967. /**
  1968. * Get a unique key for using in internal element id's and pointers. The key is
  1969. * composed of a random hash specific to this Highcharts instance, and a
  1970. * counter.
  1971. *
  1972. * @example
  1973. * let id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  1974. *
  1975. * @function Highcharts.uniqueKey
  1976. *
  1977. * @return {string}
  1978. * A unique key.
  1979. */
  1980. var uniqueKey = (function () {
  1981. var hash = Math.random().toString(36).substring(2, 9) + '-';
  1982. var id = 0;
  1983. return function () {
  1984. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  1985. };
  1986. }());
  1987. /**
  1988. * Activates a serial mode for element IDs provided by
  1989. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  1990. * a simple comparison of two rendered SVG graphics is needed.
  1991. *
  1992. * **Note:** This is only for testing purposes and will break functionality in
  1993. * webpages with multiple charts.
  1994. *
  1995. * @example
  1996. * if (
  1997. * process &&
  1998. * process.env.NODE_ENV === 'development'
  1999. * ) {
  2000. * Highcharts.useSerialIds(true);
  2001. * }
  2002. *
  2003. * @function Highcharts.useSerialIds
  2004. *
  2005. * @param {boolean} [mode]
  2006. * Changes the state of serial mode.
  2007. *
  2008. * @return {boolean|undefined}
  2009. * State of the serial mode.
  2010. */
  2011. function useSerialIds(mode) {
  2012. return (serialMode = pick(mode, serialMode));
  2013. }
  2014. function isFunction(obj) {
  2015. return typeof obj === 'function';
  2016. }
  2017. // Register Highcharts as a plugin in jQuery
  2018. if (win.jQuery) {
  2019. /**
  2020. * Highcharts-extended JQuery.
  2021. *
  2022. * @external JQuery
  2023. */
  2024. /**
  2025. * Helper function to return the chart of the current JQuery selector
  2026. * element.
  2027. *
  2028. * @function external:JQuery#highcharts
  2029. *
  2030. * @return {Highcharts.Chart}
  2031. * The chart that is linked to the JQuery selector element.
  2032. */ /**
  2033. * Factory function to create a chart in the current JQuery selector
  2034. * element.
  2035. *
  2036. * @function external:JQuery#highcharts
  2037. *
  2038. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2039. * Name of the factory class in the Highcharts namespace.
  2040. *
  2041. * @param {Highcharts.Options} [options]
  2042. * The chart options structure.
  2043. *
  2044. * @param {Highcharts.ChartCallbackFunction} [callback]
  2045. * Function to run when the chart has loaded and and all external
  2046. * images are loaded. Defining a
  2047. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2048. * handler is equivalent.
  2049. *
  2050. * @return {JQuery}
  2051. * The current JQuery selector.
  2052. */
  2053. win.jQuery.fn.highcharts = function () {
  2054. var args = [].slice.call(arguments);
  2055. if (this[0]) { // this[0] is the renderTo div
  2056. // Create the chart
  2057. if (args[0]) {
  2058. new H[ // eslint-disable-line computed-property-spacing, no-new
  2059. // Constructor defaults to Chart
  2060. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2061. return this;
  2062. }
  2063. // When called without parameters or with the return argument,
  2064. // return an existing chart
  2065. return charts[attr(this[0], 'data-highcharts-chart')];
  2066. }
  2067. };
  2068. }
  2069. // TODO use named exports when supported.
  2070. var utilitiesModule = {
  2071. addEvent: addEvent,
  2072. arrayMax: arrayMax,
  2073. arrayMin: arrayMin,
  2074. attr: attr,
  2075. clamp: clamp,
  2076. cleanRecursively: cleanRecursively,
  2077. clearTimeout: internalClearTimeout,
  2078. correctFloat: correctFloat,
  2079. createElement: createElement,
  2080. css: css,
  2081. defined: defined,
  2082. destroyObjectProperties: destroyObjectProperties,
  2083. discardElement: discardElement,
  2084. erase: erase,
  2085. error: error,
  2086. extend: extend,
  2087. extendClass: extendClass,
  2088. find: find,
  2089. fireEvent: fireEvent,
  2090. getMagnitude: getMagnitude,
  2091. getNestedProperty: getNestedProperty,
  2092. getStyle: getStyle,
  2093. inArray: inArray,
  2094. isArray: isArray,
  2095. isClass: isClass,
  2096. isDOMElement: isDOMElement,
  2097. isFunction: isFunction,
  2098. isNumber: isNumber,
  2099. isObject: isObject,
  2100. isString: isString,
  2101. keys: keys,
  2102. merge: merge,
  2103. normalizeTickInterval: normalizeTickInterval,
  2104. objectEach: objectEach,
  2105. offset: offset,
  2106. pad: pad,
  2107. pick: pick,
  2108. pInt: pInt,
  2109. relativeLength: relativeLength,
  2110. removeEvent: removeEvent,
  2111. splat: splat,
  2112. stableSort: stableSort,
  2113. syncTimeout: syncTimeout,
  2114. timeUnits: timeUnits,
  2115. uniqueKey: uniqueKey,
  2116. useSerialIds: useSerialIds,
  2117. wrap: wrap
  2118. };
  2119. return utilitiesModule;
  2120. });
  2121. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2122. /* *
  2123. *
  2124. * (c) 2010-2021 Torstein Honsi
  2125. *
  2126. * License: www.highcharts.com/license
  2127. *
  2128. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2129. *
  2130. * */
  2131. var isNumber = U.isNumber,
  2132. merge = U.merge,
  2133. pInt = U.pInt;
  2134. /**
  2135. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2136. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2137. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2138. * browsers and displayed correctly, but Highcharts is not able to process them
  2139. * and apply concepts like opacity and brightening.
  2140. *
  2141. * @typedef {string} Highcharts.ColorString
  2142. */
  2143. /**
  2144. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2145. * color string, a gradient object, or a pattern object.
  2146. *
  2147. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2148. */
  2149. /**
  2150. * Gradient options instead of a solid color.
  2151. *
  2152. * @example
  2153. * // Linear gradient used as a color option
  2154. * color: {
  2155. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2156. * stops: [
  2157. * [0, '#003399'], // start
  2158. * [0.5, '#ffffff'], // middle
  2159. * [1, '#3366AA'] // end
  2160. * ]
  2161. * }
  2162. *
  2163. * @interface Highcharts.GradientColorObject
  2164. */ /**
  2165. * Holds an object that defines the start position and the end position relative
  2166. * to the shape.
  2167. * @name Highcharts.GradientColorObject#linearGradient
  2168. * @type {Highcharts.LinearGradientColorObject|undefined}
  2169. */ /**
  2170. * Holds an object that defines the center position and the radius.
  2171. * @name Highcharts.GradientColorObject#radialGradient
  2172. * @type {Highcharts.RadialGradientColorObject|undefined}
  2173. */ /**
  2174. * The first item in each tuple is the position in the gradient, where 0 is the
  2175. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2176. * applied. The second item is the color for each stop. This color can also be
  2177. * given in the rgba format.
  2178. * @name Highcharts.GradientColorObject#stops
  2179. * @type {Array<Highcharts.GradientColorStopObject>}
  2180. */
  2181. /**
  2182. * Color stop tuple.
  2183. *
  2184. * @see Highcharts.GradientColorObject
  2185. *
  2186. * @interface Highcharts.GradientColorStopObject
  2187. */ /**
  2188. * @name Highcharts.GradientColorStopObject#0
  2189. * @type {number}
  2190. */ /**
  2191. * @name Highcharts.GradientColorStopObject#1
  2192. * @type {Highcharts.ColorString}
  2193. */ /**
  2194. * @name Highcharts.GradientColorStopObject#color
  2195. * @type {Highcharts.Color|undefined}
  2196. */
  2197. /**
  2198. * Defines the start position and the end position for a gradient relative
  2199. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  2200. * to the shape, where 0 means top/left and 1 is bottom/right.
  2201. *
  2202. * @interface Highcharts.LinearGradientColorObject
  2203. */ /**
  2204. * Start horizontal position of the gradient. Float ranges 0-1.
  2205. * @name Highcharts.LinearGradientColorObject#x1
  2206. * @type {number}
  2207. */ /**
  2208. * End horizontal position of the gradient. Float ranges 0-1.
  2209. * @name Highcharts.LinearGradientColorObject#x2
  2210. * @type {number}
  2211. */ /**
  2212. * Start vertical position of the gradient. Float ranges 0-1.
  2213. * @name Highcharts.LinearGradientColorObject#y1
  2214. * @type {number}
  2215. */ /**
  2216. * End vertical position of the gradient. Float ranges 0-1.
  2217. * @name Highcharts.LinearGradientColorObject#y2
  2218. * @type {number}
  2219. */
  2220. /**
  2221. * Defines the center position and the radius for a gradient.
  2222. *
  2223. * @interface Highcharts.RadialGradientColorObject
  2224. */ /**
  2225. * Center horizontal position relative to the shape. Float ranges 0-1.
  2226. * @name Highcharts.RadialGradientColorObject#cx
  2227. * @type {number}
  2228. */ /**
  2229. * Center vertical position relative to the shape. Float ranges 0-1.
  2230. * @name Highcharts.RadialGradientColorObject#cy
  2231. * @type {number}
  2232. */ /**
  2233. * Radius relative to the shape. Float ranges 0-1.
  2234. * @name Highcharts.RadialGradientColorObject#r
  2235. * @type {number}
  2236. */
  2237. ''; // detach doclets above
  2238. /* *
  2239. *
  2240. * Class
  2241. *
  2242. * */
  2243. /* eslint-disable no-invalid-this, valid-jsdoc */
  2244. /**
  2245. * Handle color operations. Some object methods are chainable.
  2246. *
  2247. * @class
  2248. * @name Highcharts.Color
  2249. *
  2250. * @param {Highcharts.ColorType} input
  2251. * The input color in either rbga or hex format
  2252. */
  2253. var Color = /** @class */ (function () {
  2254. /* *
  2255. *
  2256. * Constructors
  2257. *
  2258. * */
  2259. function Color(input) {
  2260. // Collection of parsers. This can be extended from the outside by pushing
  2261. // parsers to Highcharts.Color.prototype.parsers.
  2262. this.parsers = [{
  2263. // RGBA color
  2264. // eslint-disable-next-line max-len
  2265. regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
  2266. parse: function (result) {
  2267. return [
  2268. pInt(result[1]),
  2269. pInt(result[2]),
  2270. pInt(result[3]),
  2271. parseFloat(result[4], 10)
  2272. ];
  2273. }
  2274. }, {
  2275. // RGB color
  2276. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  2277. parse: function (result) {
  2278. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  2279. }
  2280. }];
  2281. this.rgba = [];
  2282. // Backwards compatibility, allow class overwrite
  2283. if (H.Color !== Color) {
  2284. return new H.Color(input);
  2285. }
  2286. // Backwards compatibility, allow instanciation without new (#13053)
  2287. if (!(this instanceof Color)) {
  2288. return new Color(input);
  2289. }
  2290. this.init(input);
  2291. }
  2292. /* *
  2293. *
  2294. * Static Functions
  2295. *
  2296. * */
  2297. /**
  2298. * Creates a color instance out of a color string or object.
  2299. *
  2300. * @function Highcharts.Color.parse
  2301. *
  2302. * @param {Highcharts.ColorType} input
  2303. * The input color in either rbga or hex format.
  2304. *
  2305. * @return {Highcharts.Color}
  2306. * Color instance.
  2307. */
  2308. Color.parse = function (input) {
  2309. return new Color(input);
  2310. };
  2311. /* *
  2312. *
  2313. * Functions
  2314. *
  2315. * */
  2316. /**
  2317. * Parse the input color to rgba array
  2318. *
  2319. * @private
  2320. * @function Highcharts.Color#init
  2321. *
  2322. * @param {Highcharts.ColorType} input
  2323. * The input color in either rbga or hex format
  2324. *
  2325. * @return {void}
  2326. */
  2327. Color.prototype.init = function (input) {
  2328. var result,
  2329. rgba,
  2330. i,
  2331. parser,
  2332. len;
  2333. this.input = input = Color.names[input && input.toLowerCase ?
  2334. input.toLowerCase() :
  2335. ''] || input;
  2336. // Gradients
  2337. if (input && input.stops) {
  2338. this.stops = input.stops.map(function (stop) {
  2339. return new Color(stop[1]);
  2340. });
  2341. // Solid colors
  2342. }
  2343. else {
  2344. // Bitmasking as input[0] is not working for legacy IE.
  2345. if (input &&
  2346. input.charAt &&
  2347. input.charAt() === '#') {
  2348. len = input.length;
  2349. input = parseInt(input.substr(1), 16);
  2350. // Handle long-form, e.g. #AABBCC
  2351. if (len === 7) {
  2352. rgba = [
  2353. (input & 0xFF0000) >> 16,
  2354. (input & 0xFF00) >> 8,
  2355. (input & 0xFF),
  2356. 1
  2357. ];
  2358. // Handle short-form, e.g. #ABC
  2359. // In short form, the value is assumed to be the same
  2360. // for both nibbles for each component. e.g. #ABC = #AABBCC
  2361. }
  2362. else if (len === 4) {
  2363. rgba = [
  2364. (((input & 0xF00) >> 4) |
  2365. (input & 0xF00) >> 8),
  2366. (((input & 0xF0) >> 4) |
  2367. (input & 0xF0)),
  2368. ((input & 0xF) << 4) | (input & 0xF),
  2369. 1
  2370. ];
  2371. }
  2372. }
  2373. // Otherwise, check regex parsers
  2374. if (!rgba) {
  2375. i = this.parsers.length;
  2376. while (i-- && !rgba) {
  2377. parser = this.parsers[i];
  2378. result = parser.regex.exec(input);
  2379. if (result) {
  2380. rgba = parser.parse(result);
  2381. }
  2382. }
  2383. }
  2384. }
  2385. this.rgba = rgba || [];
  2386. };
  2387. /**
  2388. * Return the color or gradient stops in the specified format
  2389. *
  2390. * @function Highcharts.Color#get
  2391. *
  2392. * @param {string} [format]
  2393. * Possible values are 'a', 'rgb', 'rgba' (default).
  2394. *
  2395. * @return {Highcharts.ColorType}
  2396. * This color as a string or gradient stops.
  2397. */
  2398. Color.prototype.get = function (format) {
  2399. var input = this.input,
  2400. rgba = this.rgba,
  2401. ret;
  2402. if (typeof this.stops !== 'undefined') {
  2403. ret = merge(input);
  2404. ret.stops = [].concat(ret.stops);
  2405. this.stops.forEach(function (stop, i) {
  2406. ret.stops[i] = [
  2407. ret.stops[i][0],
  2408. stop.get(format)
  2409. ];
  2410. });
  2411. // it's NaN if gradient colors on a column chart
  2412. }
  2413. else if (rgba && isNumber(rgba[0])) {
  2414. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  2415. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  2416. }
  2417. else if (format === 'a') {
  2418. ret = rgba[3];
  2419. }
  2420. else {
  2421. ret = 'rgba(' + rgba.join(',') + ')';
  2422. }
  2423. }
  2424. else {
  2425. ret = input;
  2426. }
  2427. return ret;
  2428. };
  2429. /**
  2430. * Brighten the color instance.
  2431. *
  2432. * @function Highcharts.Color#brighten
  2433. *
  2434. * @param {number} alpha
  2435. * The alpha value.
  2436. *
  2437. * @return {Highcharts.Color}
  2438. * This color with modifications.
  2439. */
  2440. Color.prototype.brighten = function (alpha) {
  2441. var i,
  2442. rgba = this.rgba;
  2443. if (this.stops) {
  2444. this.stops.forEach(function (stop) {
  2445. stop.brighten(alpha);
  2446. });
  2447. }
  2448. else if (isNumber(alpha) && alpha !== 0) {
  2449. for (i = 0; i < 3; i++) {
  2450. rgba[i] += pInt(alpha * 255);
  2451. if (rgba[i] < 0) {
  2452. rgba[i] = 0;
  2453. }
  2454. if (rgba[i] > 255) {
  2455. rgba[i] = 255;
  2456. }
  2457. }
  2458. }
  2459. return this;
  2460. };
  2461. /**
  2462. * Set the color's opacity to a given alpha value.
  2463. *
  2464. * @function Highcharts.Color#setOpacity
  2465. *
  2466. * @param {number} alpha
  2467. * Opacity between 0 and 1.
  2468. *
  2469. * @return {Highcharts.Color}
  2470. * Color with modifications.
  2471. */
  2472. Color.prototype.setOpacity = function (alpha) {
  2473. this.rgba[3] = alpha;
  2474. return this;
  2475. };
  2476. /**
  2477. * Return an intermediate color between two colors.
  2478. *
  2479. * @function Highcharts.Color#tweenTo
  2480. *
  2481. * @param {Highcharts.Color} to
  2482. * The color object to tween to.
  2483. *
  2484. * @param {number} pos
  2485. * The intermediate position, where 0 is the from color (current
  2486. * color item), and 1 is the `to` color.
  2487. *
  2488. * @return {Highcharts.ColorString}
  2489. * The intermediate color in rgba notation.
  2490. */
  2491. Color.prototype.tweenTo = function (to, pos) {
  2492. // Check for has alpha, because rgba colors perform worse due to lack of
  2493. // support in WebKit.
  2494. var fromRgba = this.rgba,
  2495. toRgba = to.rgba,
  2496. hasAlpha,
  2497. ret;
  2498. // Unsupported color, return to-color (#3920, #7034)
  2499. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  2500. ret = to.input || 'none';
  2501. // Interpolate
  2502. }
  2503. else {
  2504. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  2505. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  2506. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  2507. ',' +
  2508. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  2509. ',' +
  2510. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  2511. (hasAlpha ?
  2512. (',' +
  2513. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  2514. '') +
  2515. ')';
  2516. }
  2517. return ret;
  2518. };
  2519. /* *
  2520. *
  2521. * Static Properties
  2522. *
  2523. * */
  2524. // Collection of named colors. Can be extended from the outside by adding
  2525. // colors to Highcharts.Color.names.
  2526. Color.names = {
  2527. white: '#ffffff',
  2528. black: '#000000'
  2529. };
  2530. return Color;
  2531. }());
  2532. H.Color = Color;
  2533. /**
  2534. * Creates a color instance out of a color string.
  2535. *
  2536. * @function Highcharts.color
  2537. *
  2538. * @param {Highcharts.ColorType} input
  2539. * The input color in either rbga or hex format
  2540. *
  2541. * @return {Highcharts.Color}
  2542. * Color instance
  2543. */
  2544. H.color = Color.parse;
  2545. /* *
  2546. *
  2547. * Export
  2548. *
  2549. * */
  2550. return Color;
  2551. });
  2552. _registerModule(_modules, 'Core/Color/Palette.js', [], function () {
  2553. var palette = {
  2554. /**
  2555. * Colors for data series and points.
  2556. */
  2557. colors: [
  2558. '#7cb5ec',
  2559. '#434348',
  2560. '#90ed7d',
  2561. '#f7a35c',
  2562. '#8085e9',
  2563. '#f15c80',
  2564. '#e4d354',
  2565. '#2b908f',
  2566. '#f45b5b',
  2567. '#91e8e1'
  2568. ],
  2569. /**
  2570. * Chart background,
  2571. point stroke for markers and columns etc
  2572. */
  2573. backgroundColor: '#ffffff',
  2574. /**
  2575. * Strong text.
  2576. */
  2577. neutralColor100: '#000000',
  2578. /**
  2579. * Main text and some strokes.
  2580. */
  2581. neutralColor80: '#333333',
  2582. /**
  2583. * Axis labels,
  2584. axis title,
  2585. connector fallback.
  2586. */
  2587. neutralColor60: '#666666',
  2588. /**
  2589. * Credits text,
  2590. export menu stroke.
  2591. */
  2592. neutralColor40: '#999999',
  2593. /**
  2594. * Disabled texts,
  2595. button strokes,
  2596. crosshair etc.
  2597. */
  2598. neutralColor20: '#cccccc',
  2599. /**
  2600. * Grid lines etc.
  2601. */
  2602. neutralColor10: '#e6e6e6',
  2603. /**
  2604. * Minor grid lines etc.
  2605. */
  2606. neutralColor5: '#f2f2f2',
  2607. /**
  2608. * Tooltip backgroud,
  2609. button fills,
  2610. map null points.
  2611. */
  2612. neutralColor3: '#f7f7f7',
  2613. /**
  2614. * Drilldown clickable labels,
  2615. color axis max color.
  2616. */
  2617. highlightColor100: '#003399',
  2618. /**
  2619. * Selection marker,
  2620. menu hover,
  2621. button hover,
  2622. chart border,
  2623. navigator series.
  2624. */
  2625. highlightColor80: '#335cad',
  2626. /**
  2627. * Navigator mask fill.
  2628. */
  2629. highlightColor60: '#6685c2',
  2630. /**
  2631. * Ticks and axis line.
  2632. */
  2633. highlightColor20: '#ccd6eb',
  2634. /**
  2635. * Pressed button,
  2636. color axis min color.
  2637. */
  2638. highlightColor10: '#e6ebf5',
  2639. /**
  2640. * Positive indicator color
  2641. */
  2642. positiveColor: '#06b535',
  2643. /**
  2644. * Negative indicator color
  2645. */
  2646. negativeColor: '#f21313'
  2647. };
  2648. return palette;
  2649. });
  2650. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2651. /* *
  2652. *
  2653. * (c) 2010-2021 Torstein Honsi
  2654. *
  2655. * License: www.highcharts.com/license
  2656. *
  2657. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2658. *
  2659. * */
  2660. var win = H.win;
  2661. var defined = U.defined,
  2662. error = U.error,
  2663. extend = U.extend,
  2664. isObject = U.isObject,
  2665. merge = U.merge,
  2666. objectEach = U.objectEach,
  2667. pad = U.pad,
  2668. pick = U.pick,
  2669. splat = U.splat,
  2670. timeUnits = U.timeUnits;
  2671. /**
  2672. * Normalized interval.
  2673. *
  2674. * @interface Highcharts.TimeNormalizedObject
  2675. */ /**
  2676. * The count.
  2677. *
  2678. * @name Highcharts.TimeNormalizedObject#count
  2679. * @type {number}
  2680. */ /**
  2681. * The interval in axis values (ms).
  2682. *
  2683. * @name Highcharts.TimeNormalizedObject#unitRange
  2684. * @type {number}
  2685. */
  2686. /**
  2687. * Function of an additional date format specifier.
  2688. *
  2689. * @callback Highcharts.TimeFormatCallbackFunction
  2690. *
  2691. * @param {number} timestamp
  2692. * The time to format.
  2693. *
  2694. * @return {string}
  2695. * The formatted portion of the date.
  2696. */
  2697. /**
  2698. * Time ticks.
  2699. *
  2700. * @interface Highcharts.AxisTickPositionsArray
  2701. * @extends global.Array<number>
  2702. */ /**
  2703. * @name Highcharts.AxisTickPositionsArray#info
  2704. * @type {Highcharts.TimeTicksInfoObject|undefined}
  2705. */
  2706. /**
  2707. * A callback to return the time zone offset for a given datetime. It
  2708. * takes the timestamp in terms of milliseconds since January 1 1970,
  2709. * and returns the timezone offset in minutes. This provides a hook
  2710. * for drawing time based charts in specific time zones using their
  2711. * local DST crossover dates, with the help of external libraries.
  2712. *
  2713. * @callback Highcharts.TimezoneOffsetCallbackFunction
  2714. *
  2715. * @param {number} timestamp
  2716. * Timestamp in terms of milliseconds since January 1 1970.
  2717. *
  2718. * @return {number}
  2719. * Timezone offset in minutes.
  2720. */
  2721. /**
  2722. * Allows to manually load the `moment.js` library from Highcharts options
  2723. * instead of the `window`.
  2724. * In case of loading the library from a `script` tag,
  2725. * this option is not needed, it will be loaded from there by default.
  2726. *
  2727. * @type {function}
  2728. * @since 8.2.0
  2729. * @apioption time.moment
  2730. */
  2731. ''; // detach doclets above
  2732. /* eslint-disable no-invalid-this, valid-jsdoc */
  2733. /**
  2734. * The Time class. Time settings are applied in general for each page using
  2735. * `Highcharts.setOptions`, or individually for each Chart item through the
  2736. * [time](https://api.highcharts.com/highcharts/time) options set.
  2737. *
  2738. * The Time object is available from {@link Highcharts.Chart#time},
  2739. * which refers to `Highcharts.time` if no individual time settings are
  2740. * applied.
  2741. *
  2742. * @example
  2743. * // Apply time settings globally
  2744. * Highcharts.setOptions({
  2745. * time: {
  2746. * timezone: 'Europe/London'
  2747. * }
  2748. * });
  2749. *
  2750. * // Apply time settings by instance
  2751. * let chart = Highcharts.chart('container', {
  2752. * time: {
  2753. * timezone: 'America/New_York'
  2754. * },
  2755. * series: [{
  2756. * data: [1, 4, 3, 5]
  2757. * }]
  2758. * });
  2759. *
  2760. * // Use the Time object
  2761. * console.log(
  2762. * 'Current time in New York',
  2763. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  2764. * );
  2765. *
  2766. * @since 6.0.5
  2767. *
  2768. * @class
  2769. * @name Highcharts.Time
  2770. *
  2771. * @param {Highcharts.TimeOptions} options
  2772. * Time options as defined in [chart.options.time](/highcharts/time).
  2773. */
  2774. var Time = /** @class */ (function () {
  2775. /* *
  2776. *
  2777. * Constructors
  2778. *
  2779. * */
  2780. function Time(options) {
  2781. /* *
  2782. *
  2783. * Properties
  2784. *
  2785. * */
  2786. this.options = {};
  2787. this.useUTC = false;
  2788. this.variableTimezone = false;
  2789. this.Date = win.Date;
  2790. /**
  2791. * Get the time zone offset based on the current timezone information as
  2792. * set in the global options.
  2793. *
  2794. * @function Highcharts.Time#getTimezoneOffset
  2795. *
  2796. * @param {number} timestamp
  2797. * The JavaScript timestamp to inspect.
  2798. *
  2799. * @return {number}
  2800. * The timezone offset in minutes compared to UTC.
  2801. */
  2802. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2803. this.update(options);
  2804. }
  2805. /* *
  2806. *
  2807. * Functions
  2808. *
  2809. * */
  2810. /**
  2811. * Time units used in `Time.get` and `Time.set`
  2812. *
  2813. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  2814. */
  2815. /**
  2816. * Get the value of a date object in given units, and subject to the Time
  2817. * object's current timezone settings. This function corresponds directly to
  2818. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  2819. * `date.getHours()` or `date.getUTCHours()` we will call
  2820. * `time.get('Hours')`.
  2821. *
  2822. * @function Highcharts.Time#get
  2823. *
  2824. * @param {Highcharts.TimeUnitValue} unit
  2825. * @param {Date} date
  2826. *
  2827. * @return {number}
  2828. * The given time unit
  2829. */
  2830. Time.prototype.get = function (unit, date) {
  2831. if (this.variableTimezone || this.timezoneOffset) {
  2832. var realMs = date.getTime();
  2833. var ms = realMs - this.getTimezoneOffset(date);
  2834. date.setTime(ms); // Temporary adjust to timezone
  2835. var ret = date['getUTC' + unit]();
  2836. date.setTime(realMs); // Reset
  2837. return ret;
  2838. }
  2839. // UTC time with no timezone handling
  2840. if (this.useUTC) {
  2841. return date['getUTC' + unit]();
  2842. }
  2843. // Else, local time
  2844. return date['get' + unit]();
  2845. };
  2846. /**
  2847. * Set the value of a date object in given units, and subject to the Time
  2848. * object's current timezone settings. This function corresponds directly to
  2849. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  2850. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  2851. * `time.set('Hours', 0)`.
  2852. *
  2853. * @function Highcharts.Time#set
  2854. *
  2855. * @param {Highcharts.TimeUnitValue} unit
  2856. * @param {Date} date
  2857. * @param {number} value
  2858. *
  2859. * @return {number}
  2860. * The epoch milliseconds of the updated date
  2861. */
  2862. Time.prototype.set = function (unit, date, value) {
  2863. // UTC time with timezone handling
  2864. if (this.variableTimezone || this.timezoneOffset) {
  2865. // For lower order time units, just set it directly using UTC
  2866. // time
  2867. if (unit === 'Milliseconds' ||
  2868. unit === 'Seconds' ||
  2869. (unit === 'Minutes' && this.getTimezoneOffset(date) % 3600000 === 0) // #13961
  2870. ) {
  2871. return date['setUTC' + unit](value);
  2872. }
  2873. // Higher order time units need to take the time zone into
  2874. // account
  2875. // Adjust by timezone
  2876. var offset = this.getTimezoneOffset(date);
  2877. var ms = date.getTime() - offset;
  2878. date.setTime(ms);
  2879. date['setUTC' + unit](value);
  2880. var newOffset = this.getTimezoneOffset(date);
  2881. ms = date.getTime() + newOffset;
  2882. return date.setTime(ms);
  2883. }
  2884. // UTC time with no timezone handling
  2885. if (this.useUTC) {
  2886. return date['setUTC' + unit](value);
  2887. }
  2888. // Else, local time
  2889. return date['set' + unit](value);
  2890. };
  2891. /**
  2892. * Update the Time object with current options. It is called internally on
  2893. * initializing Highcharts, after running `Highcharts.setOptions` and on
  2894. * `Chart.update`.
  2895. *
  2896. * @private
  2897. * @function Highcharts.Time#update
  2898. *
  2899. * @param {Highcharts.TimeOptions} options
  2900. *
  2901. * @return {void}
  2902. */
  2903. Time.prototype.update = function (options) {
  2904. var useUTC = pick(options && options.useUTC,
  2905. true),
  2906. time = this;
  2907. this.options = options = merge(true, this.options || {}, options);
  2908. // Allow using a different Date class
  2909. this.Date = options.Date || win.Date || Date;
  2910. this.useUTC = useUTC;
  2911. this.timezoneOffset = (useUTC && options.timezoneOffset);
  2912. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2913. /*
  2914. * The time object has options allowing for variable time zones, meaning
  2915. * the axis ticks or series data needs to consider this.
  2916. */
  2917. this.variableTimezone = useUTC && !!(options.getTimezoneOffset ||
  2918. options.timezone);
  2919. };
  2920. /**
  2921. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  2922. * local time or a specific timezone time depending on the current time
  2923. * settings.
  2924. *
  2925. * @function Highcharts.Time#makeTime
  2926. *
  2927. * @param {number} year
  2928. * The year
  2929. *
  2930. * @param {number} month
  2931. * The month. Zero-based, so January is 0.
  2932. *
  2933. * @param {number} [date=1]
  2934. * The day of the month
  2935. *
  2936. * @param {number} [hours=0]
  2937. * The hour of the day, 0-23.
  2938. *
  2939. * @param {number} [minutes=0]
  2940. * The minutes
  2941. *
  2942. * @param {number} [seconds=0]
  2943. * The seconds
  2944. *
  2945. * @return {number}
  2946. * The time in milliseconds since January 1st 1970.
  2947. */
  2948. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  2949. var d,
  2950. offset,
  2951. newOffset;
  2952. if (this.useUTC) {
  2953. d = this.Date.UTC.apply(0, arguments);
  2954. offset = this.getTimezoneOffset(d);
  2955. d += offset;
  2956. newOffset = this.getTimezoneOffset(d);
  2957. if (offset !== newOffset) {
  2958. d += newOffset - offset;
  2959. // A special case for transitioning from summer time to winter time.
  2960. // When the clock is set back, the same time is repeated twice, i.e.
  2961. // 02:30 am is repeated since the clock is set back from 3 am to
  2962. // 2 am. We need to make the same time as local Date does.
  2963. }
  2964. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  2965. !H.isSafari) {
  2966. d -= 36e5;
  2967. }
  2968. }
  2969. else {
  2970. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  2971. }
  2972. return d;
  2973. };
  2974. /**
  2975. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  2976. * default getTimezoneOffset function with that timezone is returned. If
  2977. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  2978. * specified, the function using the `timezoneOffset` option or 0 offset is
  2979. * returned.
  2980. *
  2981. * @private
  2982. * @function Highcharts.Time#timezoneOffsetFunction
  2983. *
  2984. * @return {Function}
  2985. * A getTimezoneOffset function
  2986. */
  2987. Time.prototype.timezoneOffsetFunction = function () {
  2988. var time = this,
  2989. options = this.options,
  2990. moment = options.moment || win.moment;
  2991. if (!this.useUTC) {
  2992. return function (timestamp) {
  2993. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  2994. };
  2995. }
  2996. if (options.timezone) {
  2997. if (!moment) {
  2998. // getTimezoneOffset-function stays undefined because it depends
  2999. // on Moment.js
  3000. error(25);
  3001. }
  3002. else {
  3003. return function (timestamp) {
  3004. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  3005. };
  3006. }
  3007. }
  3008. // If not timezone is set, look for the getTimezoneOffset callback
  3009. if (this.useUTC && options.getTimezoneOffset) {
  3010. return function (timestamp) {
  3011. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  3012. };
  3013. }
  3014. // Last, use the `timezoneOffset` option if set
  3015. return function () {
  3016. return (time.timezoneOffset || 0) * 60000;
  3017. };
  3018. };
  3019. /**
  3020. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  3021. * into a human readable date string. The available format keys are listed
  3022. * below. Additional formats can be given in the
  3023. * {@link Highcharts.dateFormats} hook.
  3024. *
  3025. * Supported format keys:
  3026. * - `%a`: Short weekday, like 'Mon'
  3027. * - `%A`: Long weekday, like 'Monday'
  3028. * - `%d`: Two digit day of the month, 01 to 31
  3029. * - `%e`: Day of the month, 1 through 31
  3030. * - `%w`: Day of the week, 0 through 6
  3031. * - `%b`: Short month, like 'Jan'
  3032. * - `%B`: Long month, like 'January'
  3033. * - `%m`: Two digit month number, 01 through 12
  3034. * - `%y`: Two digits year, like 09 for 2009
  3035. * - `%Y`: Four digits year, like 2009
  3036. * - `%H`: Two digits hours in 24h format, 00 through 23
  3037. * - `%k`: Hours in 24h format, 0 through 23
  3038. * - `%I`: Two digits hours in 12h format, 00 through 11
  3039. * - `%l`: Hours in 12h format, 1 through 12
  3040. * - `%M`: Two digits minutes, 00 through 59
  3041. * - `%p`: Upper case AM or PM
  3042. * - `%P`: Lower case AM or PM
  3043. * - `%S`: Two digits seconds, 00 through 59
  3044. * - `%L`: Milliseconds (naming from Ruby)
  3045. *
  3046. * @example
  3047. * const time = new Highcharts.Time();
  3048. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  3049. * console.log(s); // => 2020-01-01 00:00:00
  3050. *
  3051. * @function Highcharts.Time#dateFormat
  3052. *
  3053. * @param {string} format
  3054. * The desired format where various time representations are
  3055. * prefixed with %.
  3056. *
  3057. * @param {number} [timestamp]
  3058. * The JavaScript timestamp.
  3059. *
  3060. * @param {boolean} [capitalize=false]
  3061. * Upper case first letter in the return.
  3062. *
  3063. * @return {string}
  3064. * The formatted date.
  3065. */
  3066. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  3067. if (!defined(timestamp) || isNaN(timestamp)) {
  3068. return (H.defaultOptions.lang &&
  3069. H.defaultOptions.lang.invalidDate ||
  3070. '');
  3071. }
  3072. format = pick(format, '%Y-%m-%d %H:%M:%S');
  3073. var time = this, date = new this.Date(timestamp),
  3074. // get the basic time values
  3075. hours = this.get('Hours', date), day = this.get('Day', date), dayOfMonth = this.get('Date', date), month = this.get('Month', date), fullYear = this.get('FullYear', date), lang = H.defaultOptions.lang, langWeekdays = (lang && lang.weekdays), shortWeekdays = (lang && lang.shortWeekdays),
  3076. // List all format keys. Custom formats can be added from the
  3077. // outside.
  3078. replacements = extend({
  3079. // Day
  3080. // Short weekday, like 'Mon'
  3081. a: shortWeekdays ?
  3082. shortWeekdays[day] :
  3083. langWeekdays[day].substr(0, 3),
  3084. // Long weekday, like 'Monday'
  3085. A: langWeekdays[day],
  3086. // Two digit day of the month, 01 to 31
  3087. d: pad(dayOfMonth),
  3088. // Day of the month, 1 through 31
  3089. e: pad(dayOfMonth, 2, ' '),
  3090. // Day of the week, 0 through 6
  3091. w: day,
  3092. // Week (none implemented)
  3093. // 'W': weekNumber(),
  3094. // Month
  3095. // Short month, like 'Jan'
  3096. b: lang.shortMonths[month],
  3097. // Long month, like 'January'
  3098. B: lang.months[month],
  3099. // Two digit month number, 01 through 12
  3100. m: pad(month + 1),
  3101. // Month number, 1 through 12 (#8150)
  3102. o: month + 1,
  3103. // Year
  3104. // Two digits year, like 09 for 2009
  3105. y: fullYear.toString().substr(2, 2),
  3106. // Four digits year, like 2009
  3107. Y: fullYear,
  3108. // Time
  3109. // Two digits hours in 24h format, 00 through 23
  3110. H: pad(hours),
  3111. // Hours in 24h format, 0 through 23
  3112. k: hours,
  3113. // Two digits hours in 12h format, 00 through 11
  3114. I: pad((hours % 12) || 12),
  3115. // Hours in 12h format, 1 through 12
  3116. l: (hours % 12) || 12,
  3117. // Two digits minutes, 00 through 59
  3118. M: pad(this.get('Minutes', date)),
  3119. // Upper case AM or PM
  3120. p: hours < 12 ? 'AM' : 'PM',
  3121. // Lower case AM or PM
  3122. P: hours < 12 ? 'am' : 'pm',
  3123. // Two digits seconds, 00 through 59
  3124. S: pad(date.getSeconds()),
  3125. // Milliseconds (naming from Ruby)
  3126. L: pad(Math.floor(timestamp % 1000), 3)
  3127. }, H.dateFormats);
  3128. // Do the replaces
  3129. objectEach(replacements, function (val, key) {
  3130. // Regex would do it in one line, but this is faster
  3131. while (format.indexOf('%' + key) !== -1) {
  3132. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  3133. }
  3134. });
  3135. // Optionally capitalize the string and return
  3136. return capitalize ?
  3137. (format.substr(0, 1).toUpperCase() +
  3138. format.substr(1)) :
  3139. format;
  3140. };
  3141. /**
  3142. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  3143. * an object.
  3144. * @private
  3145. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  3146. * @return {Highcharts.Dictionary<T>} - The object definition
  3147. */
  3148. Time.prototype.resolveDTLFormat = function (f) {
  3149. if (!isObject(f, true)) { // check for string or array
  3150. f = splat(f);
  3151. return {
  3152. main: f[0],
  3153. from: f[1],
  3154. to: f[2]
  3155. };
  3156. }
  3157. return f;
  3158. };
  3159. /**
  3160. * Return an array with time positions distributed on round time values
  3161. * right and right after min and max. Used in datetime axes as well as for
  3162. * grouping data on a datetime axis.
  3163. *
  3164. * @function Highcharts.Time#getTimeTicks
  3165. *
  3166. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  3167. * The interval in axis values (ms) and the count
  3168. *
  3169. * @param {number} [min]
  3170. * The minimum in axis values
  3171. *
  3172. * @param {number} [max]
  3173. * The maximum in axis values
  3174. *
  3175. * @param {number} [startOfWeek=1]
  3176. *
  3177. * @return {Highcharts.AxisTickPositionsArray}
  3178. */
  3179. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  3180. var time = this,
  3181. Date = time.Date,
  3182. tickPositions = [],
  3183. i,
  3184. higherRanks = {},
  3185. minYear, // used in months and years as a basis for Date.UTC()
  3186. // When crossing DST, use the max. Resolves #6278.
  3187. minDate = new Date(min),
  3188. interval = normalizedInterval.unitRange,
  3189. count = normalizedInterval.count || 1,
  3190. variableDayLength,
  3191. minDay;
  3192. startOfWeek = pick(startOfWeek, 1);
  3193. if (defined(min)) { // #1300
  3194. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  3195. 0 : // #3935
  3196. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  3197. if (interval >= timeUnits.second) { // second
  3198. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  3199. 0 : // #3935
  3200. count * Math.floor(time.get('Seconds', minDate) / count));
  3201. }
  3202. if (interval >= timeUnits.minute) { // minute
  3203. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  3204. 0 :
  3205. count * Math.floor(time.get('Minutes', minDate) / count));
  3206. }
  3207. if (interval >= timeUnits.hour) { // hour
  3208. time.set('Hours', minDate, interval >= timeUnits.day ?
  3209. 0 :
  3210. count * Math.floor(time.get('Hours', minDate) / count));
  3211. }
  3212. if (interval >= timeUnits.day) { // day
  3213. time.set('Date', minDate, interval >= timeUnits.month ?
  3214. 1 :
  3215. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  3216. }
  3217. if (interval >= timeUnits.month) { // month
  3218. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  3219. count * Math.floor(time.get('Month', minDate) / count));
  3220. minYear = time.get('FullYear', minDate);
  3221. }
  3222. if (interval >= timeUnits.year) { // year
  3223. minYear -= minYear % count;
  3224. time.set('FullYear', minDate, minYear);
  3225. }
  3226. // week is a special case that runs outside the hierarchy
  3227. if (interval === timeUnits.week) {
  3228. // get start of current week, independent of count
  3229. minDay = time.get('Day', minDate);
  3230. time.set('Date', minDate, (time.get('Date', minDate) -
  3231. minDay + startOfWeek +
  3232. // We don't want to skip days that are before
  3233. // startOfWeek (#7051)
  3234. (minDay < startOfWeek ? -7 : 0)));
  3235. }
  3236. // Get basics for variable time spans
  3237. minYear = time.get('FullYear', minDate);
  3238. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  3239. // Redefine min to the floored/rounded minimum time (#7432)
  3240. min = minDate.getTime();
  3241. // Handle local timezone offset
  3242. if ((time.variableTimezone || !time.useUTC) && defined(max)) {
  3243. // Detect whether we need to take the DST crossover into
  3244. // consideration. If we're crossing over DST, the day length may
  3245. // be 23h or 25h and we need to compute the exact clock time for
  3246. // each tick instead of just adding hours. This comes at a cost,
  3247. // so first we find out if it is needed (#4951).
  3248. variableDayLength = (
  3249. // Long range, assume we're crossing over.
  3250. max - min > 4 * timeUnits.month ||
  3251. // Short range, check if min and max are in different time
  3252. // zones.
  3253. time.getTimezoneOffset(min) !==
  3254. time.getTimezoneOffset(max));
  3255. }
  3256. // Iterate and add tick positions at appropriate values
  3257. var t = minDate.getTime();
  3258. i = 1;
  3259. while (t < max) {
  3260. tickPositions.push(t);
  3261. // if the interval is years, use Date.UTC to increase years
  3262. if (interval === timeUnits.year) {
  3263. t = time.makeTime(minYear + i * count, 0);
  3264. // if the interval is months, use Date.UTC to increase months
  3265. }
  3266. else if (interval === timeUnits.month) {
  3267. t = time.makeTime(minYear, minMonth + i * count);
  3268. // if we're using global time, the interval is not fixed as it
  3269. // jumps one hour at the DST crossover
  3270. }
  3271. else if (variableDayLength &&
  3272. (interval === timeUnits.day || interval === timeUnits.week)) {
  3273. t = time.makeTime(minYear, minMonth, minDateDate +
  3274. i * count * (interval === timeUnits.day ? 1 : 7));
  3275. }
  3276. else if (variableDayLength &&
  3277. interval === timeUnits.hour &&
  3278. count > 1) {
  3279. // make sure higher ranks are preserved across DST (#6797,
  3280. // #7621)
  3281. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  3282. // else, the interval is fixed and we use simple addition
  3283. }
  3284. else {
  3285. t += interval * count;
  3286. }
  3287. i++;
  3288. }
  3289. // push the last time
  3290. tickPositions.push(t);
  3291. // Handle higher ranks. Mark new days if the time is on midnight
  3292. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  3293. // to prevent looping over dense data grouping (#6156).
  3294. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  3295. tickPositions.forEach(function (t) {
  3296. if (
  3297. // Speed optimization, no need to run dateFormat unless
  3298. // we're on a full or half hour
  3299. t % 1800000 === 0 &&
  3300. // Check for local or global midnight
  3301. time.dateFormat('%H%M%S%L', t) === '000000000') {
  3302. higherRanks[t] = 'day';
  3303. }
  3304. });
  3305. }
  3306. }
  3307. // record information on the chosen unit - for dynamic label formatter
  3308. tickPositions.info = extend(normalizedInterval, {
  3309. higherRanks: higherRanks,
  3310. totalRange: interval * count
  3311. });
  3312. return tickPositions;
  3313. };
  3314. return Time;
  3315. }());
  3316. H.Time = Time;
  3317. return H.Time;
  3318. });
  3319. _registerModule(_modules, 'Core/Options.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Color/Palette.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, Color, palette, Time, U) {
  3320. /* *
  3321. *
  3322. * (c) 2010-2021 Torstein Honsi
  3323. *
  3324. * License: www.highcharts.com/license
  3325. *
  3326. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3327. *
  3328. * */
  3329. var isTouchDevice = H.isTouchDevice,
  3330. svg = H.svg;
  3331. var color = Color.parse;
  3332. var getNestedProperty = U.getNestedProperty,
  3333. isNumber = U.isNumber,
  3334. merge = U.merge,
  3335. pick = U.pick,
  3336. pInt = U.pInt;
  3337. /* *
  3338. *
  3339. * API Declarations
  3340. *
  3341. * */
  3342. /**
  3343. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  3344. */
  3345. /**
  3346. * Gets fired when a series is added to the chart after load time, using the
  3347. * `addSeries` method. Returning `false` prevents the series from being added.
  3348. *
  3349. * @callback Highcharts.ChartAddSeriesCallbackFunction
  3350. *
  3351. * @param {Highcharts.Chart} this
  3352. * The chart on which the event occured.
  3353. *
  3354. * @param {Highcharts.ChartAddSeriesEventObject} event
  3355. * The event that occured.
  3356. */
  3357. /**
  3358. * Contains common event information. Through the `options` property you can
  3359. * access the series options that were passed to the `addSeries` method.
  3360. *
  3361. * @interface Highcharts.ChartAddSeriesEventObject
  3362. */ /**
  3363. * The series options that were passed to the `addSeries` method.
  3364. * @name Highcharts.ChartAddSeriesEventObject#options
  3365. * @type {Highcharts.SeriesOptionsType}
  3366. */ /**
  3367. * Prevents the default behaviour of the event.
  3368. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  3369. * @type {Function}
  3370. */ /**
  3371. * The event target.
  3372. * @name Highcharts.ChartAddSeriesEventObject#target
  3373. * @type {Highcharts.Chart}
  3374. */ /**
  3375. * The event type.
  3376. * @name Highcharts.ChartAddSeriesEventObject#type
  3377. * @type {"addSeries"}
  3378. */
  3379. /**
  3380. * Gets fired when clicking on the plot background.
  3381. *
  3382. * @callback Highcharts.ChartClickCallbackFunction
  3383. *
  3384. * @param {Highcharts.Chart} this
  3385. * The chart on which the event occured.
  3386. *
  3387. * @param {Highcharts.PointerEventObject} event
  3388. * The event that occured.
  3389. */
  3390. /**
  3391. * Contains an axes of the clicked spot.
  3392. *
  3393. * @interface Highcharts.ChartClickEventAxisObject
  3394. */ /**
  3395. * Axis at the clicked spot.
  3396. * @name Highcharts.ChartClickEventAxisObject#axis
  3397. * @type {Highcharts.Axis}
  3398. */ /**
  3399. * Axis value at the clicked spot.
  3400. * @name Highcharts.ChartClickEventAxisObject#value
  3401. * @type {number}
  3402. */
  3403. /**
  3404. * Contains information about the clicked spot on the chart. Remember the unit
  3405. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  3406. *
  3407. * @interface Highcharts.ChartClickEventObject
  3408. * @extends Highcharts.PointerEventObject
  3409. */ /**
  3410. * Information about the x-axis on the clicked spot.
  3411. * @name Highcharts.ChartClickEventObject#xAxis
  3412. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3413. */ /**
  3414. * Information about the y-axis on the clicked spot.
  3415. * @name Highcharts.ChartClickEventObject#yAxis
  3416. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3417. */ /**
  3418. * Information about the z-axis on the clicked spot.
  3419. * @name Highcharts.ChartClickEventObject#zAxis
  3420. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  3421. */
  3422. /**
  3423. * Gets fired when the chart is finished loading.
  3424. *
  3425. * @callback Highcharts.ChartLoadCallbackFunction
  3426. *
  3427. * @param {Highcharts.Chart} this
  3428. * The chart on which the event occured.
  3429. *
  3430. * @param {global.Event} event
  3431. * The event that occured.
  3432. */
  3433. /**
  3434. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  3435. * after an axis, series or point is modified with the `redraw` option set to
  3436. * `true`.
  3437. *
  3438. * @callback Highcharts.ChartRedrawCallbackFunction
  3439. *
  3440. * @param {Highcharts.Chart} this
  3441. * The chart on which the event occured.
  3442. *
  3443. * @param {global.Event} event
  3444. * The event that occured.
  3445. */
  3446. /**
  3447. * Gets fired after initial load of the chart (directly after the `load` event),
  3448. * and after each redraw (directly after the `redraw` event).
  3449. *
  3450. * @callback Highcharts.ChartRenderCallbackFunction
  3451. *
  3452. * @param {Highcharts.Chart} this
  3453. * The chart on which the event occured.
  3454. *
  3455. * @param {global.Event} event
  3456. * The event that occured.
  3457. */
  3458. /**
  3459. * Gets fired when an area of the chart has been selected. The default action
  3460. * for the selection event is to zoom the chart to the selected area. It can be
  3461. * prevented by calling `event.preventDefault()` or return false.
  3462. *
  3463. * @callback Highcharts.ChartSelectionCallbackFunction
  3464. *
  3465. * @param {Highcharts.Chart} this
  3466. * The chart on which the event occured.
  3467. *
  3468. * @param {global.ChartSelectionContextObject} event
  3469. * Event informations
  3470. *
  3471. * @return {boolean|undefined}
  3472. * Return false to prevent the default action, usually zoom.
  3473. */
  3474. /**
  3475. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  3476. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  3477. *
  3478. * @interface Highcharts.ChartSelectionContextObject
  3479. * @extends global.Event
  3480. */ /**
  3481. * Arrays containing the axes of each dimension and each axis' min and max
  3482. * values.
  3483. * @name Highcharts.ChartSelectionContextObject#xAxis
  3484. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3485. */ /**
  3486. * Arrays containing the axes of each dimension and each axis' min and max
  3487. * values.
  3488. * @name Highcharts.ChartSelectionContextObject#yAxis
  3489. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3490. */
  3491. /**
  3492. * Axis context of the selection.
  3493. *
  3494. * @interface Highcharts.ChartSelectionAxisContextObject
  3495. */ /**
  3496. * The selected Axis.
  3497. * @name Highcharts.ChartSelectionAxisContextObject#axis
  3498. * @type {Highcharts.Axis}
  3499. */ /**
  3500. * The maximum axis value, either automatic or set manually.
  3501. * @name Highcharts.ChartSelectionAxisContextObject#max
  3502. * @type {number}
  3503. */ /**
  3504. * The minimum axis value, either automatic or set manually.
  3505. * @name Highcharts.ChartSelectionAxisContextObject#min
  3506. * @type {number}
  3507. */
  3508. (''); // detach doclets above
  3509. /* *
  3510. *
  3511. * API Options
  3512. *
  3513. * */
  3514. /**
  3515. * Global default settings.
  3516. *
  3517. * @name Highcharts.defaultOptions
  3518. * @type {Highcharts.Options}
  3519. */ /**
  3520. * @optionparent
  3521. */
  3522. var defaultOptions = {
  3523. /**
  3524. * An array containing the default colors for the chart's series. When
  3525. * all colors are used, new colors are pulled from the start again.
  3526. *
  3527. * Default colors can also be set on a series or series.type basis,
  3528. * see [column.colors](#plotOptions.column.colors),
  3529. * [pie.colors](#plotOptions.pie.colors).
  3530. *
  3531. * In styled mode, the colors option doesn't exist. Instead, colors
  3532. * are defined in CSS and applied either through series or point class
  3533. * names, or through the [chart.colorCount](#chart.colorCount) option.
  3534. *
  3535. *
  3536. * ### Legacy
  3537. *
  3538. * In Highcharts 3.x, the default colors were:
  3539. * ```js
  3540. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  3541. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  3542. * ```
  3543. *
  3544. * In Highcharts 2.x, the default colors were:
  3545. * ```js
  3546. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  3547. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  3548. * ```
  3549. *
  3550. * @sample {highcharts} highcharts/chart/colors/
  3551. * Assign a global color theme
  3552. *
  3553. * @type {Array<Highcharts.ColorString>}
  3554. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  3555. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  3556. */
  3557. colors: palette.colors,
  3558. /**
  3559. * Styled mode only. Configuration object for adding SVG definitions for
  3560. * reusable elements. See [gradients, shadows and
  3561. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  3562. * for more information and code examples.
  3563. *
  3564. * @type {*}
  3565. * @since 5.0.0
  3566. * @apioption defs
  3567. */
  3568. /**
  3569. * @ignore-option
  3570. */
  3571. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  3572. /**
  3573. * The language object is global and it can't be set on each chart
  3574. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  3575. * chart is initialized.
  3576. *
  3577. * ```js
  3578. * Highcharts.setOptions({
  3579. * lang: {
  3580. * months: [
  3581. * 'Janvier', 'Février', 'Mars', 'Avril',
  3582. * 'Mai', 'Juin', 'Juillet', 'Août',
  3583. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  3584. * ],
  3585. * weekdays: [
  3586. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  3587. * 'Jeudi', 'Vendredi', 'Samedi'
  3588. * ]
  3589. * }
  3590. * });
  3591. * ```
  3592. */
  3593. lang: {
  3594. /**
  3595. * The loading text that appears when the chart is set into the loading
  3596. * state following a call to `chart.showLoading`.
  3597. */
  3598. loading: 'Loading...',
  3599. /**
  3600. * An array containing the months names. Corresponds to the `%B` format
  3601. * in `Highcharts.dateFormat()`.
  3602. *
  3603. * @type {Array<string>}
  3604. * @default ["January", "February", "March", "April", "May", "June",
  3605. * "July", "August", "September", "October", "November",
  3606. * "December"]
  3607. */
  3608. months: [
  3609. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  3610. 'August', 'September', 'October', 'November', 'December'
  3611. ],
  3612. /**
  3613. * An array containing the months names in abbreviated form. Corresponds
  3614. * to the `%b` format in `Highcharts.dateFormat()`.
  3615. *
  3616. * @type {Array<string>}
  3617. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  3618. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  3619. */
  3620. shortMonths: [
  3621. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  3622. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  3623. ],
  3624. /**
  3625. * An array containing the weekday names.
  3626. *
  3627. * @type {Array<string>}
  3628. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  3629. * "Friday", "Saturday"]
  3630. */
  3631. weekdays: [
  3632. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  3633. 'Thursday', 'Friday', 'Saturday'
  3634. ],
  3635. /**
  3636. * Short week days, starting Sunday. If not specified, Highcharts uses
  3637. * the first three letters of the `lang.weekdays` option.
  3638. *
  3639. * @sample highcharts/lang/shortweekdays/
  3640. * Finnish two-letter abbreviations
  3641. *
  3642. * @type {Array<string>}
  3643. * @since 4.2.4
  3644. * @apioption lang.shortWeekdays
  3645. */
  3646. /**
  3647. * What to show in a date field for invalid dates. Defaults to an empty
  3648. * string.
  3649. *
  3650. * @type {string}
  3651. * @since 4.1.8
  3652. * @product highcharts highstock
  3653. * @apioption lang.invalidDate
  3654. */
  3655. /**
  3656. * The title appearing on hovering the zoom in button. The text itself
  3657. * defaults to "+" and can be changed in the button options.
  3658. *
  3659. * @type {string}
  3660. * @default Zoom in
  3661. * @product highmaps
  3662. * @apioption lang.zoomIn
  3663. */
  3664. /**
  3665. * The title appearing on hovering the zoom out button. The text itself
  3666. * defaults to "-" and can be changed in the button options.
  3667. *
  3668. * @type {string}
  3669. * @default Zoom out
  3670. * @product highmaps
  3671. * @apioption lang.zoomOut
  3672. */
  3673. /**
  3674. * The default decimal point used in the `Highcharts.numberFormat`
  3675. * method unless otherwise specified in the function arguments.
  3676. *
  3677. * @since 1.2.2
  3678. */
  3679. decimalPoint: '.',
  3680. /**
  3681. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  3682. * to shorten high numbers in axis labels. Replacing any of the
  3683. * positions with `null` causes the full number to be written. Setting
  3684. * `numericSymbols` to `null` disables shortening altogether.
  3685. *
  3686. * @sample {highcharts} highcharts/lang/numericsymbols/
  3687. * Replacing the symbols with text
  3688. * @sample {highstock} highcharts/lang/numericsymbols/
  3689. * Replacing the symbols with text
  3690. *
  3691. * @type {Array<string>}
  3692. * @default ["k", "M", "G", "T", "P", "E"]
  3693. * @since 2.3.0
  3694. */
  3695. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  3696. /**
  3697. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  3698. * Use 10000 for Japanese, Korean and various Chinese locales, which
  3699. * use symbols for 10^4, 10^8 and 10^12.
  3700. *
  3701. * @sample highcharts/lang/numericsymbolmagnitude/
  3702. * 10000 magnitude for Japanese
  3703. *
  3704. * @type {number}
  3705. * @default 1000
  3706. * @since 5.0.3
  3707. * @apioption lang.numericSymbolMagnitude
  3708. */
  3709. /**
  3710. * The text for the label appearing when a chart is zoomed.
  3711. *
  3712. * @since 1.2.4
  3713. */
  3714. resetZoom: 'Reset zoom',
  3715. /**
  3716. * The tooltip title for the label appearing when a chart is zoomed.
  3717. *
  3718. * @since 1.2.4
  3719. */
  3720. resetZoomTitle: 'Reset zoom level 1:1',
  3721. /**
  3722. * The default thousands separator used in the `Highcharts.numberFormat`
  3723. * method unless otherwise specified in the function arguments. Defaults
  3724. * to a single space character, which is recommended in
  3725. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  3726. * across Anglo-American and continental European languages.
  3727. *
  3728. * @default \u0020
  3729. * @since 1.2.2
  3730. */
  3731. thousandsSep: ' '
  3732. },
  3733. /**
  3734. * Global options that don't apply to each chart. These options, like
  3735. * the `lang` options, must be set using the `Highcharts.setOptions`
  3736. * method.
  3737. *
  3738. * ```js
  3739. * Highcharts.setOptions({
  3740. * global: {
  3741. * useUTC: false
  3742. * }
  3743. * });
  3744. * ```
  3745. */
  3746. /**
  3747. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  3748. * Use the [libURL](#exporting.libURL) option to configure exporting._
  3749. *
  3750. * The URL to the additional file to lazy load for Android 2.x devices.
  3751. * These devices don't support SVG, so we download a helper file that
  3752. * contains [canvg](https://github.com/canvg/canvg), its dependency
  3753. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  3754. * our site, you can install canvas-tools.js on your own server and
  3755. * change this option accordingly.
  3756. *
  3757. * @deprecated
  3758. *
  3759. * @type {string}
  3760. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  3761. * @product highcharts highmaps
  3762. * @apioption global.canvasToolsURL
  3763. */
  3764. /**
  3765. * This option is deprecated since v6.0.5. Instead, use
  3766. * [time.useUTC](#time.useUTC) that supports individual time settings
  3767. * per chart.
  3768. *
  3769. * @deprecated
  3770. *
  3771. * @type {boolean}
  3772. * @apioption global.useUTC
  3773. */
  3774. /**
  3775. * This option is deprecated since v6.0.5. Instead, use
  3776. * [time.Date](#time.Date) that supports individual time settings
  3777. * per chart.
  3778. *
  3779. * @deprecated
  3780. *
  3781. * @type {Function}
  3782. * @product highcharts highstock
  3783. * @apioption global.Date
  3784. */
  3785. /**
  3786. * This option is deprecated since v6.0.5. Instead, use
  3787. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  3788. * individual time settings per chart.
  3789. *
  3790. * @deprecated
  3791. *
  3792. * @type {Function}
  3793. * @product highcharts highstock
  3794. * @apioption global.getTimezoneOffset
  3795. */
  3796. /**
  3797. * This option is deprecated since v6.0.5. Instead, use
  3798. * [time.timezone](#time.timezone) that supports individual time
  3799. * settings per chart.
  3800. *
  3801. * @deprecated
  3802. *
  3803. * @type {string}
  3804. * @product highcharts highstock
  3805. * @apioption global.timezone
  3806. */
  3807. /**
  3808. * This option is deprecated since v6.0.5. Instead, use
  3809. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  3810. * time settings per chart.
  3811. *
  3812. * @deprecated
  3813. *
  3814. * @type {number}
  3815. * @product highcharts highstock
  3816. * @apioption global.timezoneOffset
  3817. */
  3818. global: {},
  3819. /**
  3820. * Time options that can apply globally or to individual charts. These
  3821. * settings affect how `datetime` axes are laid out, how tooltips are
  3822. * formatted, how series
  3823. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  3824. * the Highcharts Stock range selector handles time.
  3825. *
  3826. * The common use case is that all charts in the same Highcharts object
  3827. * share the same time settings, in which case the global settings are set
  3828. * using `setOptions`.
  3829. *
  3830. * ```js
  3831. * // Apply time settings globally
  3832. * Highcharts.setOptions({
  3833. * time: {
  3834. * timezone: 'Europe/London'
  3835. * }
  3836. * });
  3837. * // Apply time settings by instance
  3838. * let chart = Highcharts.chart('container', {
  3839. * time: {
  3840. * timezone: 'America/New_York'
  3841. * },
  3842. * series: [{
  3843. * data: [1, 4, 3, 5]
  3844. * }]
  3845. * });
  3846. *
  3847. * // Use the Time object
  3848. * console.log(
  3849. * 'Current time in New York',
  3850. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  3851. * );
  3852. * ```
  3853. *
  3854. * Since v6.0.5, the time options were moved from the `global` obect to the
  3855. * `time` object, and time options can be set on each individual chart.
  3856. *
  3857. * @sample {highcharts|highstock}
  3858. * highcharts/time/timezone/
  3859. * Set the timezone globally
  3860. * @sample {highcharts}
  3861. * highcharts/time/individual/
  3862. * Set the timezone per chart instance
  3863. * @sample {highstock}
  3864. * stock/time/individual/
  3865. * Set the timezone per chart instance
  3866. *
  3867. * @since 6.0.5
  3868. * @optionparent time
  3869. */
  3870. time: {
  3871. /**
  3872. * A custom `Date` class for advanced date handling. For example,
  3873. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  3874. * handle Jalali dates.
  3875. *
  3876. * @type {*}
  3877. * @since 4.0.4
  3878. * @product highcharts highstock gantt
  3879. */
  3880. Date: void 0,
  3881. /**
  3882. * A callback to return the time zone offset for a given datetime. It
  3883. * takes the timestamp in terms of milliseconds since January 1 1970,
  3884. * and returns the timezone offset in minutes. This provides a hook
  3885. * for drawing time based charts in specific time zones using their
  3886. * local DST crossover dates, with the help of external libraries.
  3887. *
  3888. * @see [global.timezoneOffset](#global.timezoneOffset)
  3889. *
  3890. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  3891. * Use moment.js to draw Oslo time regardless of browser locale
  3892. *
  3893. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  3894. * @since 4.1.0
  3895. * @product highcharts highstock gantt
  3896. */
  3897. getTimezoneOffset: void 0,
  3898. /**
  3899. * Requires [moment.js](https://momentjs.com/). If the timezone option
  3900. * is specified, it creates a default
  3901. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  3902. * up the specified timezone in moment.js. If moment.js is not included,
  3903. * this throws a Highcharts error in the console, but does not crash the
  3904. * chart.
  3905. *
  3906. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  3907. *
  3908. * @sample {highcharts|highstock} highcharts/time/timezone/
  3909. * Europe/Oslo
  3910. *
  3911. * @type {string}
  3912. * @since 5.0.7
  3913. * @product highcharts highstock gantt
  3914. */
  3915. timezone: void 0,
  3916. /**
  3917. * The timezone offset in minutes. Positive values are west, negative
  3918. * values are east of UTC, as in the ECMAScript
  3919. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  3920. * method. Use this to display UTC based data in a predefined time zone.
  3921. *
  3922. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  3923. *
  3924. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  3925. * Timezone offset
  3926. *
  3927. * @since 3.0.8
  3928. * @product highcharts highstock gantt
  3929. */
  3930. timezoneOffset: 0,
  3931. /**
  3932. * Whether to use UTC time for axis scaling, tickmark placement and
  3933. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  3934. * is that the time displays equally regardless of the user agent's
  3935. * time zone settings. Local time can be used when the data is loaded
  3936. * in real time or when correct Daylight Saving Time transitions are
  3937. * required.
  3938. *
  3939. * @sample {highcharts} highcharts/time/useutc-true/
  3940. * True by default
  3941. * @sample {highcharts} highcharts/time/useutc-false/
  3942. * False
  3943. */
  3944. useUTC: true
  3945. },
  3946. /**
  3947. * General options for the chart.
  3948. */
  3949. chart: {
  3950. /**
  3951. * Default `mapData` for all series. If set to a string, it functions
  3952. * as an index into the `Highcharts.maps` array. Otherwise it is
  3953. * interpreted as map data.
  3954. *
  3955. * @see [mapData](#series.map.mapData)
  3956. *
  3957. * @sample maps/demo/geojson
  3958. * Loading geoJSON data
  3959. * @sample maps/chart/topojson
  3960. * Loading topoJSON converted to geoJSON
  3961. *
  3962. * @type {string|Array<*>|Highcharts.GeoJSON}
  3963. * @since 5.0.0
  3964. * @product highmaps
  3965. * @apioption chart.map
  3966. */
  3967. /**
  3968. * Set lat/lon transformation definitions for the chart. If not defined,
  3969. * these are extracted from the map data.
  3970. *
  3971. * @type {*}
  3972. * @since 5.0.0
  3973. * @product highmaps
  3974. * @apioption chart.mapTransforms
  3975. */
  3976. /**
  3977. * When using multiple axis, the ticks of two or more opposite axes
  3978. * will automatically be aligned by adding ticks to the axis or axes
  3979. * with the least ticks, as if `tickAmount` were specified.
  3980. *
  3981. * This can be prevented by setting `alignTicks` to false. If the grid
  3982. * lines look messy, it's a good idea to hide them for the secondary
  3983. * axis by setting `gridLineWidth` to 0.
  3984. *
  3985. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  3986. * then the `alignTicks ` will be disabled for the Axis.
  3987. *
  3988. * Disabled for logarithmic axes.
  3989. *
  3990. * @sample {highcharts} highcharts/chart/alignticks-true/
  3991. * True by default
  3992. * @sample {highcharts} highcharts/chart/alignticks-false/
  3993. * False
  3994. * @sample {highstock} stock/chart/alignticks-true/
  3995. * True by default
  3996. * @sample {highstock} stock/chart/alignticks-false/
  3997. * False
  3998. *
  3999. * @type {boolean}
  4000. * @default true
  4001. * @product highcharts highstock gantt
  4002. * @apioption chart.alignTicks
  4003. */
  4004. /**
  4005. * Set the overall animation for all chart updating. Animation can be
  4006. * disabled throughout the chart by setting it to false here. It can
  4007. * be overridden for each individual API method as a function parameter.
  4008. * The only animation not affected by this option is the initial series
  4009. * animation, see [plotOptions.series.animation](
  4010. * #plotOptions.series.animation).
  4011. *
  4012. * The animation can either be set as a boolean or a configuration
  4013. * object. If `true`, it will use the 'swing' jQuery easing and a
  4014. * duration of 500 ms. If used as a configuration object, the following
  4015. * properties are supported:
  4016. *
  4017. * - `defer`: The animation delay time in milliseconds.
  4018. *
  4019. * - `duration`: The duration of the animation in milliseconds.
  4020. *
  4021. * - `easing`: A string reference to an easing function set on the
  4022. * `Math` object. See
  4023. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  4024. *
  4025. * When zooming on a series with less than 100 points, the chart redraw
  4026. * will be done with animation, but in case of more data points, it is
  4027. * necessary to set this option to ensure animation on zoom.
  4028. *
  4029. * @sample {highcharts} highcharts/chart/animation-none/
  4030. * Updating with no animation
  4031. * @sample {highcharts} highcharts/chart/animation-duration/
  4032. * With a longer duration
  4033. * @sample {highcharts} highcharts/chart/animation-easing/
  4034. * With a jQuery UI easing
  4035. * @sample {highmaps} maps/chart/animation-none/
  4036. * Updating with no animation
  4037. * @sample {highmaps} maps/chart/animation-duration/
  4038. * With a longer duration
  4039. *
  4040. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  4041. * @default undefined
  4042. * @apioption chart.animation
  4043. */
  4044. /**
  4045. * A CSS class name to apply to the charts container `div`, allowing
  4046. * unique CSS styling for each chart.
  4047. *
  4048. * @type {string}
  4049. * @apioption chart.className
  4050. */
  4051. /**
  4052. * Event listeners for the chart.
  4053. *
  4054. * @apioption chart.events
  4055. */
  4056. /**
  4057. * Fires when a series is added to the chart after load time, using the
  4058. * `addSeries` method. One parameter, `event`, is passed to the
  4059. * function, containing common event information. Through
  4060. * `event.options` you can access the series options that were passed to
  4061. * the `addSeries` method. Returning false prevents the series from
  4062. * being added.
  4063. *
  4064. * @sample {highcharts} highcharts/chart/events-addseries/
  4065. * Alert on add series
  4066. * @sample {highstock} stock/chart/events-addseries/
  4067. * Alert on add series
  4068. *
  4069. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  4070. * @since 1.2.0
  4071. * @context Highcharts.Chart
  4072. * @apioption chart.events.addSeries
  4073. */
  4074. /**
  4075. * Fires when clicking on the plot background. One parameter, `event`,
  4076. * is passed to the function, containing common event information.
  4077. *
  4078. * Information on the clicked spot can be found through `event.xAxis`
  4079. * and `event.yAxis`, which are arrays containing the axes of each
  4080. * dimension and each axis' value at the clicked spot. The primary axes
  4081. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4082. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4083. *
  4084. * ```js
  4085. * click: function(e) {
  4086. * console.log(
  4087. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  4088. * e.yAxis[0].value
  4089. * )
  4090. * }
  4091. * ```
  4092. *
  4093. * @sample {highcharts} highcharts/chart/events-click/
  4094. * Alert coordinates on click
  4095. * @sample {highcharts} highcharts/chart/events-container/
  4096. * Alternatively, attach event to container
  4097. * @sample {highstock} stock/chart/events-click/
  4098. * Alert coordinates on click
  4099. * @sample {highstock} highcharts/chart/events-container/
  4100. * Alternatively, attach event to container
  4101. * @sample {highmaps} maps/chart/events-click/
  4102. * Record coordinates on click
  4103. * @sample {highmaps} highcharts/chart/events-container/
  4104. * Alternatively, attach event to container
  4105. *
  4106. * @type {Highcharts.ChartClickCallbackFunction}
  4107. * @since 1.2.0
  4108. * @context Highcharts.Chart
  4109. * @apioption chart.events.click
  4110. */
  4111. /**
  4112. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  4113. * for images to be loaded, for example from point markers. One
  4114. * parameter, `event`, is passed to the function, containing common
  4115. * event information.
  4116. *
  4117. * There is also a second parameter to the chart constructor where a
  4118. * callback function can be passed to be executed on chart.load.
  4119. *
  4120. * @sample {highcharts} highcharts/chart/events-load/
  4121. * Alert on chart load
  4122. * @sample {highstock} stock/chart/events-load/
  4123. * Alert on chart load
  4124. * @sample {highmaps} maps/chart/events-load/
  4125. * Add series on chart load
  4126. *
  4127. * @type {Highcharts.ChartLoadCallbackFunction}
  4128. * @context Highcharts.Chart
  4129. * @apioption chart.events.load
  4130. */
  4131. /**
  4132. * Fires when the chart is redrawn, either after a call to
  4133. * `chart.redraw()` or after an axis, series or point is modified with
  4134. * the `redraw` option set to `true`. One parameter, `event`, is passed
  4135. * to the function, containing common event information.
  4136. *
  4137. * @sample {highcharts} highcharts/chart/events-redraw/
  4138. * Alert on chart redraw
  4139. * @sample {highstock} stock/chart/events-redraw/
  4140. * Alert on chart redraw when adding a series or moving the
  4141. * zoomed range
  4142. * @sample {highmaps} maps/chart/events-redraw/
  4143. * Set subtitle on chart redraw
  4144. *
  4145. * @type {Highcharts.ChartRedrawCallbackFunction}
  4146. * @since 1.2.0
  4147. * @context Highcharts.Chart
  4148. * @apioption chart.events.redraw
  4149. */
  4150. /**
  4151. * Fires after initial load of the chart (directly after the `load`
  4152. * event), and after each redraw (directly after the `redraw` event).
  4153. *
  4154. * @type {Highcharts.ChartRenderCallbackFunction}
  4155. * @since 5.0.7
  4156. * @context Highcharts.Chart
  4157. * @apioption chart.events.render
  4158. */
  4159. /**
  4160. * Fires when an area of the chart has been selected. Selection is
  4161. * enabled by setting the chart's zoomType. One parameter, `event`, is
  4162. * passed to the function, containing common event information. The
  4163. * default action for the selection event is to zoom the chart to the
  4164. * selected area. It can be prevented by calling
  4165. * `event.preventDefault()` or return false.
  4166. *
  4167. * Information on the selected area can be found through `event.xAxis`
  4168. * and `event.yAxis`, which are arrays containing the axes of each
  4169. * dimension and each axis' min and max values. The primary axes are
  4170. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4171. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4172. *
  4173. * ```js
  4174. * selection: function(event) {
  4175. * // log the min and max of the primary, datetime x-axis
  4176. * console.log(
  4177. * Highcharts.dateFormat(
  4178. * '%Y-%m-%d %H:%M:%S',
  4179. * event.xAxis[0].min
  4180. * ),
  4181. * Highcharts.dateFormat(
  4182. * '%Y-%m-%d %H:%M:%S',
  4183. * event.xAxis[0].max
  4184. * )
  4185. * );
  4186. * // log the min and max of the y axis
  4187. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  4188. * }
  4189. * ```
  4190. *
  4191. * @sample {highcharts} highcharts/chart/events-selection/
  4192. * Report on selection and reset
  4193. * @sample {highcharts} highcharts/chart/events-selection-points/
  4194. * Select a range of points through a drag selection
  4195. * @sample {highstock} stock/chart/events-selection/
  4196. * Report on selection and reset
  4197. * @sample {highstock} highcharts/chart/events-selection-points/
  4198. * Select a range of points through a drag selection
  4199. * (Highcharts)
  4200. *
  4201. * @type {Highcharts.ChartSelectionCallbackFunction}
  4202. * @apioption chart.events.selection
  4203. */
  4204. /**
  4205. * The margin between the outer edge of the chart and the plot area.
  4206. * The numbers in the array designate top, right, bottom and left
  4207. * respectively. Use the options `marginTop`, `marginRight`,
  4208. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  4209. *
  4210. * By default there is no margin. The actual space is dynamically
  4211. * calculated from the offset of axis labels, axis title, title,
  4212. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  4213. * `spacingBottom` and `spacingLeft` options.
  4214. *
  4215. * @sample {highcharts} highcharts/chart/margins-zero/
  4216. * Zero margins
  4217. * @sample {highstock} stock/chart/margin-zero/
  4218. * Zero margins
  4219. *
  4220. * @type {number|Array<number>}
  4221. * @apioption chart.margin
  4222. */
  4223. /**
  4224. * The margin between the bottom outer edge of the chart and the plot
  4225. * area. Use this to set a fixed pixel value for the margin as opposed
  4226. * to the default dynamic margin. See also `spacingBottom`.
  4227. *
  4228. * @sample {highcharts} highcharts/chart/marginbottom/
  4229. * 100px bottom margin
  4230. * @sample {highstock} stock/chart/marginbottom/
  4231. * 100px bottom margin
  4232. * @sample {highmaps} maps/chart/margin/
  4233. * 100px margins
  4234. *
  4235. * @type {number}
  4236. * @since 2.0
  4237. * @apioption chart.marginBottom
  4238. */
  4239. /**
  4240. * The margin between the left outer edge of the chart and the plot
  4241. * area. Use this to set a fixed pixel value for the margin as opposed
  4242. * to the default dynamic margin. See also `spacingLeft`.
  4243. *
  4244. * @sample {highcharts} highcharts/chart/marginleft/
  4245. * 150px left margin
  4246. * @sample {highstock} stock/chart/marginleft/
  4247. * 150px left margin
  4248. * @sample {highmaps} maps/chart/margin/
  4249. * 100px margins
  4250. *
  4251. * @type {number}
  4252. * @since 2.0
  4253. * @apioption chart.marginLeft
  4254. */
  4255. /**
  4256. * The margin between the right outer edge of the chart and the plot
  4257. * area. Use this to set a fixed pixel value for the margin as opposed
  4258. * to the default dynamic margin. See also `spacingRight`.
  4259. *
  4260. * @sample {highcharts} highcharts/chart/marginright/
  4261. * 100px right margin
  4262. * @sample {highstock} stock/chart/marginright/
  4263. * 100px right margin
  4264. * @sample {highmaps} maps/chart/margin/
  4265. * 100px margins
  4266. *
  4267. * @type {number}
  4268. * @since 2.0
  4269. * @apioption chart.marginRight
  4270. */
  4271. /**
  4272. * The margin between the top outer edge of the chart and the plot area.
  4273. * Use this to set a fixed pixel value for the margin as opposed to
  4274. * the default dynamic margin. See also `spacingTop`.
  4275. *
  4276. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  4277. * @sample {highstock} stock/chart/margintop/
  4278. * 100px top margin
  4279. * @sample {highmaps} maps/chart/margin/
  4280. * 100px margins
  4281. *
  4282. * @type {number}
  4283. * @since 2.0
  4284. * @apioption chart.marginTop
  4285. */
  4286. /**
  4287. * Callback function to override the default function that formats all
  4288. * the numbers in the chart. Returns a string with the formatted number.
  4289. *
  4290. * @sample highcharts/members/highcharts-numberformat
  4291. * Arabic digits in Highcharts
  4292. * @type {Highcharts.NumberFormatterCallbackFunction}
  4293. * @since 8.0.0
  4294. * @apioption chart.numberFormatter
  4295. */
  4296. /**
  4297. * Allows setting a key to switch between zooming and panning. Can be
  4298. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  4299. * key on Windows) or `shift`. The keys are mapped directly to the key
  4300. * properties of the click event argument (`event.altKey`,
  4301. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  4302. *
  4303. * @type {string}
  4304. * @since 4.0.3
  4305. * @product highcharts gantt
  4306. * @validvalue ["alt", "ctrl", "meta", "shift"]
  4307. * @apioption chart.panKey
  4308. */
  4309. /**
  4310. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  4311. * to combine zooming and panning.
  4312. *
  4313. * On touch devices, when the [tooltip.followTouchMove](
  4314. * #tooltip.followTouchMove) option is `true` (default), panning
  4315. * requires two fingers. To allow panning with one finger, set
  4316. * `followTouchMove` to `false`.
  4317. *
  4318. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  4319. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  4320. */
  4321. panning: {
  4322. /**
  4323. * Enable or disable chart panning.
  4324. *
  4325. * @type {boolean}
  4326. * @default {highcharts} false
  4327. * @default {highstock|highmaps} true
  4328. */
  4329. enabled: false,
  4330. /**
  4331. * Decides in what dimensions the user can pan the chart. Can be
  4332. * one of `x`, `y`, or `xy`.
  4333. *
  4334. * @sample {highcharts} highcharts/chart/panning-type
  4335. * Zooming and xy panning
  4336. *
  4337. * @type {string}
  4338. * @validvalue ["x", "y", "xy"]
  4339. * @default {highcharts|highstock} x
  4340. * @default {highmaps} xy
  4341. */
  4342. type: 'x'
  4343. },
  4344. /**
  4345. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  4346. * gestures only. By default, the `pinchType` is the same as the
  4347. * `zoomType` setting. However, pinching can be enabled separately in
  4348. * some cases, for example in stock charts where a mouse drag pans the
  4349. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  4350. * #tooltip.followTouchMove) is true, pinchType only applies to
  4351. * two-finger touches.
  4352. *
  4353. * @type {string}
  4354. * @default {highcharts} undefined
  4355. * @default {highstock} x
  4356. * @since 3.0
  4357. * @product highcharts highstock gantt
  4358. * @validvalue ["x", "y", "xy"]
  4359. * @apioption chart.pinchType
  4360. */
  4361. /**
  4362. * Whether to apply styled mode. When in styled mode, no presentational
  4363. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  4364. * are required to style the chart. The default style sheet is
  4365. * available from `https://code.highcharts.com/css/highcharts.css`.
  4366. *
  4367. * @type {boolean}
  4368. * @default false
  4369. * @since 7.0
  4370. * @apioption chart.styledMode
  4371. */
  4372. styledMode: false,
  4373. /**
  4374. * The corner radius of the outer chart border.
  4375. *
  4376. * @sample {highcharts} highcharts/chart/borderradius/
  4377. * 20px radius
  4378. * @sample {highstock} stock/chart/border/
  4379. * 10px radius
  4380. * @sample {highmaps} maps/chart/border/
  4381. * Border options
  4382. *
  4383. */
  4384. borderRadius: 0,
  4385. /**
  4386. * In styled mode, this sets how many colors the class names
  4387. * should rotate between. With ten colors, series (or points) are
  4388. * given class names like `highcharts-color-0`, `highcharts-color-0`
  4389. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  4390. * is to set colors using the [colors](#colors) setting.
  4391. *
  4392. * @since 5.0.0
  4393. */
  4394. colorCount: 10,
  4395. /**
  4396. * Alias of `type`.
  4397. *
  4398. * @sample {highcharts} highcharts/chart/defaultseriestype/
  4399. * Bar
  4400. *
  4401. * @deprecated
  4402. *
  4403. * @product highcharts
  4404. */
  4405. defaultSeriesType: 'line',
  4406. /**
  4407. * If true, the axes will scale to the remaining visible series once
  4408. * one series is hidden. If false, hiding and showing a series will
  4409. * not affect the axes or the other series. For stacks, once one series
  4410. * within the stack is hidden, the rest of the stack will close in
  4411. * around it even if the axis is not affected.
  4412. *
  4413. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  4414. * True by default
  4415. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  4416. * False
  4417. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  4418. * True with stack
  4419. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  4420. * True by default
  4421. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  4422. * False
  4423. *
  4424. * @since 1.2.0
  4425. * @product highcharts highstock gantt
  4426. */
  4427. ignoreHiddenSeries: true,
  4428. /**
  4429. * Whether to invert the axes so that the x axis is vertical and y axis
  4430. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  4431. * by default.
  4432. *
  4433. * @productdesc {highcharts}
  4434. * If a bar series is present in the chart, it will be inverted
  4435. * automatically. Inverting the chart doesn't have an effect if there
  4436. * are no cartesian series in the chart, or if the chart is
  4437. * [polar](#chart.polar).
  4438. *
  4439. * @sample {highcharts} highcharts/chart/inverted/
  4440. * Inverted line
  4441. * @sample {highstock} stock/navigator/inverted/
  4442. * Inverted stock chart
  4443. *
  4444. * @type {boolean}
  4445. * @default false
  4446. * @product highcharts highstock gantt
  4447. * @apioption chart.inverted
  4448. */
  4449. /**
  4450. * The distance between the outer edge of the chart and the content,
  4451. * like title or legend, or axis title and labels if present. The
  4452. * numbers in the array designate top, right, bottom and left
  4453. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  4454. * and spacingLeft options for shorthand setting of one option.
  4455. *
  4456. * @type {Array<number>}
  4457. * @see [chart.margin](#chart.margin)
  4458. * @default [10, 10, 15, 10]
  4459. * @since 3.0.6
  4460. */
  4461. spacing: [10, 10, 15, 10],
  4462. /**
  4463. * The button that appears after a selection zoom, allowing the user
  4464. * to reset zoom.
  4465. */
  4466. resetZoomButton: {
  4467. /**
  4468. * What frame the button placement should be related to. Can be
  4469. * either `plotBox` or `spacingBox`.
  4470. *
  4471. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  4472. * Relative to the chart
  4473. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  4474. * Relative to the chart
  4475. *
  4476. * @type {Highcharts.ButtonRelativeToValue}
  4477. * @default plot
  4478. * @since 2.2
  4479. * @apioption chart.resetZoomButton.relativeTo
  4480. */
  4481. /**
  4482. * A collection of attributes for the button. The object takes SVG
  4483. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  4484. * border radius. The theme also supports `style`, a collection of
  4485. * CSS properties for the text. Equivalent attributes for the hover
  4486. * state are given in `theme.states.hover`.
  4487. *
  4488. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  4489. * Theming the button
  4490. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  4491. * Theming the button
  4492. *
  4493. * @type {Highcharts.SVGAttributes}
  4494. * @since 2.2
  4495. */
  4496. theme: {
  4497. /** @internal */
  4498. zIndex: 6
  4499. },
  4500. /**
  4501. * The position of the button.
  4502. *
  4503. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  4504. * Above the plot area
  4505. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  4506. * Above the plot area
  4507. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  4508. * Above the plot area
  4509. *
  4510. * @type {Highcharts.AlignObject}
  4511. * @since 2.2
  4512. */
  4513. position: {
  4514. /**
  4515. * The horizontal alignment of the button.
  4516. */
  4517. align: 'right',
  4518. /**
  4519. * The horizontal offset of the button.
  4520. */
  4521. x: -10,
  4522. /**
  4523. * The vertical alignment of the button.
  4524. *
  4525. * @type {Highcharts.VerticalAlignValue}
  4526. * @default top
  4527. * @apioption chart.resetZoomButton.position.verticalAlign
  4528. */
  4529. /**
  4530. * The vertical offset of the button.
  4531. */
  4532. y: 10
  4533. }
  4534. },
  4535. /**
  4536. * The pixel width of the plot area border.
  4537. *
  4538. * @sample {highcharts} highcharts/chart/plotborderwidth/
  4539. * 1px border
  4540. * @sample {highstock} stock/chart/plotborder/
  4541. * 2px border
  4542. * @sample {highmaps} maps/chart/plotborder/
  4543. * Plot border options
  4544. *
  4545. * @type {number}
  4546. * @default 0
  4547. * @apioption chart.plotBorderWidth
  4548. */
  4549. /**
  4550. * Whether to apply a drop shadow to the plot area. Requires that
  4551. * plotBackgroundColor be set. The shadow can be an object configuration
  4552. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  4553. *
  4554. * @sample {highcharts} highcharts/chart/plotshadow/
  4555. * Plot shadow
  4556. * @sample {highstock} stock/chart/plotshadow/
  4557. * Plot shadow
  4558. * @sample {highmaps} maps/chart/plotborder/
  4559. * Plot border options
  4560. *
  4561. * @type {boolean|Highcharts.CSSObject}
  4562. * @default false
  4563. * @apioption chart.plotShadow
  4564. */
  4565. /**
  4566. * When true, cartesian charts like line, spline, area and column are
  4567. * transformed into the polar coordinate system. This produces _polar
  4568. * charts_, also known as _radar charts_.
  4569. *
  4570. * @sample {highcharts} highcharts/demo/polar/
  4571. * Polar chart
  4572. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  4573. * Wind rose, stacked polar column chart
  4574. * @sample {highcharts} highcharts/demo/polar-spider/
  4575. * Spider web chart
  4576. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  4577. * Star plot, multivariate data in a polar chart
  4578. *
  4579. * @type {boolean}
  4580. * @default false
  4581. * @since 2.3.0
  4582. * @product highcharts
  4583. * @requires highcharts-more
  4584. * @apioption chart.polar
  4585. */
  4586. /**
  4587. * Whether to reflow the chart to fit the width of the container div
  4588. * on resizing the window.
  4589. *
  4590. * @sample {highcharts} highcharts/chart/reflow-true/
  4591. * True by default
  4592. * @sample {highcharts} highcharts/chart/reflow-false/
  4593. * False
  4594. * @sample {highstock} stock/chart/reflow-true/
  4595. * True by default
  4596. * @sample {highstock} stock/chart/reflow-false/
  4597. * False
  4598. * @sample {highmaps} maps/chart/reflow-true/
  4599. * True by default
  4600. * @sample {highmaps} maps/chart/reflow-false/
  4601. * False
  4602. *
  4603. * @type {boolean}
  4604. * @default true
  4605. * @since 2.1
  4606. * @apioption chart.reflow
  4607. */
  4608. /**
  4609. * The HTML element where the chart will be rendered. If it is a string,
  4610. * the element by that id is used. The HTML element can also be passed
  4611. * by direct reference, or as the first argument of the chart
  4612. * constructor, in which case the option is not needed.
  4613. *
  4614. * @sample {highcharts} highcharts/chart/reflow-true/
  4615. * String
  4616. * @sample {highcharts} highcharts/chart/renderto-object/
  4617. * Object reference
  4618. * @sample {highstock} stock/chart/renderto-string/
  4619. * String
  4620. * @sample {highstock} stock/chart/renderto-object/
  4621. * Object reference
  4622. *
  4623. * @type {string|Highcharts.HTMLDOMElement}
  4624. * @apioption chart.renderTo
  4625. */
  4626. /**
  4627. * The background color of the marker square when selecting (zooming
  4628. * in on) an area of the chart.
  4629. *
  4630. * @see In styled mode, the selection marker fill is set with the
  4631. * `.highcharts-selection-marker` class.
  4632. *
  4633. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4634. * @default rgba(51,92,173,0.25)
  4635. * @since 2.1.7
  4636. * @apioption chart.selectionMarkerFill
  4637. */
  4638. /**
  4639. * Whether to apply a drop shadow to the outer chart area. Requires
  4640. * that backgroundColor be set. The shadow can be an object
  4641. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  4642. * `width`.
  4643. *
  4644. * @sample {highcharts} highcharts/chart/shadow/
  4645. * Shadow
  4646. * @sample {highstock} stock/chart/shadow/
  4647. * Shadow
  4648. * @sample {highmaps} maps/chart/border/
  4649. * Chart border and shadow
  4650. *
  4651. * @type {boolean|Highcharts.CSSObject}
  4652. * @default false
  4653. * @apioption chart.shadow
  4654. */
  4655. /**
  4656. * Whether to show the axes initially. This only applies to empty charts
  4657. * where series are added dynamically, as axes are automatically added
  4658. * to cartesian series.
  4659. *
  4660. * @sample {highcharts} highcharts/chart/showaxes-false/
  4661. * False by default
  4662. * @sample {highcharts} highcharts/chart/showaxes-true/
  4663. * True
  4664. *
  4665. * @type {boolean}
  4666. * @since 1.2.5
  4667. * @product highcharts gantt
  4668. * @apioption chart.showAxes
  4669. */
  4670. /**
  4671. * The space between the bottom edge of the chart and the content (plot
  4672. * area, axis title and labels, title, subtitle or legend in top
  4673. * position).
  4674. *
  4675. * @sample {highcharts} highcharts/chart/spacingbottom/
  4676. * Spacing bottom set to 100
  4677. * @sample {highstock} stock/chart/spacingbottom/
  4678. * Spacing bottom set to 100
  4679. * @sample {highmaps} maps/chart/spacing/
  4680. * Spacing 100 all around
  4681. *
  4682. * @type {number}
  4683. * @default 15
  4684. * @since 2.1
  4685. * @apioption chart.spacingBottom
  4686. */
  4687. /**
  4688. * The space between the left edge of the chart and the content (plot
  4689. * area, axis title and labels, title, subtitle or legend in top
  4690. * position).
  4691. *
  4692. * @sample {highcharts} highcharts/chart/spacingleft/
  4693. * Spacing left set to 100
  4694. * @sample {highstock} stock/chart/spacingleft/
  4695. * Spacing left set to 100
  4696. * @sample {highmaps} maps/chart/spacing/
  4697. * Spacing 100 all around
  4698. *
  4699. * @type {number}
  4700. * @default 10
  4701. * @since 2.1
  4702. * @apioption chart.spacingLeft
  4703. */
  4704. /**
  4705. * The space between the right edge of the chart and the content (plot
  4706. * area, axis title and labels, title, subtitle or legend in top
  4707. * position).
  4708. *
  4709. * @sample {highcharts} highcharts/chart/spacingright-100/
  4710. * Spacing set to 100
  4711. * @sample {highcharts} highcharts/chart/spacingright-legend/
  4712. * Legend in right position with default spacing
  4713. * @sample {highstock} stock/chart/spacingright/
  4714. * Spacing set to 100
  4715. * @sample {highmaps} maps/chart/spacing/
  4716. * Spacing 100 all around
  4717. *
  4718. * @type {number}
  4719. * @default 10
  4720. * @since 2.1
  4721. * @apioption chart.spacingRight
  4722. */
  4723. /**
  4724. * The space between the top edge of the chart and the content (plot
  4725. * area, axis title and labels, title, subtitle or legend in top
  4726. * position).
  4727. *
  4728. * @sample {highcharts} highcharts/chart/spacingtop-100/
  4729. * A top spacing of 100
  4730. * @sample {highcharts} highcharts/chart/spacingtop-10/
  4731. * Floating chart title makes the plot area align to the default
  4732. * spacingTop of 10.
  4733. * @sample {highstock} stock/chart/spacingtop/
  4734. * A top spacing of 100
  4735. * @sample {highmaps} maps/chart/spacing/
  4736. * Spacing 100 all around
  4737. *
  4738. * @type {number}
  4739. * @default 10
  4740. * @since 2.1
  4741. * @apioption chart.spacingTop
  4742. */
  4743. /**
  4744. * Additional CSS styles to apply inline to the container `div`. Note
  4745. * that since the default font styles are applied in the renderer, it
  4746. * is ignorant of the individual chart options and must be set globally.
  4747. *
  4748. * @see In styled mode, general chart styles can be set with the
  4749. * `.highcharts-root` class.
  4750. * @sample {highcharts} highcharts/chart/style-serif-font/
  4751. * Using a serif type font
  4752. * @sample {highcharts} highcharts/css/em/
  4753. * Styled mode with relative font sizes
  4754. * @sample {highstock} stock/chart/style/
  4755. * Using a serif type font
  4756. * @sample {highmaps} maps/chart/style-serif-font/
  4757. * Using a serif type font
  4758. *
  4759. * @type {Highcharts.CSSObject}
  4760. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  4761. * @apioption chart.style
  4762. */
  4763. /**
  4764. * The default series type for the chart. Can be any of the chart types
  4765. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  4766. * be a series provided by an additional module.
  4767. *
  4768. * In TypeScript this option has no effect in sense of typing and
  4769. * instead the `type` option must always be set in the series.
  4770. *
  4771. * @sample {highcharts} highcharts/chart/type-bar/
  4772. * Bar
  4773. * @sample {highstock} stock/chart/type/
  4774. * Areaspline
  4775. * @sample {highmaps} maps/chart/type-mapline/
  4776. * Mapline
  4777. *
  4778. * @type {string}
  4779. * @default {highcharts} line
  4780. * @default {highstock} line
  4781. * @default {highmaps} map
  4782. * @since 2.1.0
  4783. * @apioption chart.type
  4784. */
  4785. /**
  4786. * Decides in what dimensions the user can zoom by dragging the mouse.
  4787. * Can be one of `x`, `y` or `xy`.
  4788. *
  4789. * @see [panKey](#chart.panKey)
  4790. *
  4791. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4792. * None by default
  4793. * @sample {highcharts} highcharts/chart/zoomtype-x/
  4794. * X
  4795. * @sample {highcharts} highcharts/chart/zoomtype-y/
  4796. * Y
  4797. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  4798. * Xy
  4799. * @sample {highstock} stock/demo/basic-line/
  4800. * None by default
  4801. * @sample {highstock} stock/chart/zoomtype-x/
  4802. * X
  4803. * @sample {highstock} stock/chart/zoomtype-y/
  4804. * Y
  4805. * @sample {highstock} stock/chart/zoomtype-xy/
  4806. * Xy
  4807. *
  4808. * @type {string}
  4809. * @product highcharts highstock gantt
  4810. * @validvalue ["x", "y", "xy"]
  4811. * @apioption chart.zoomType
  4812. */
  4813. /**
  4814. * Enables zooming by a single touch, in combination with
  4815. * [chart.zoomType](#chart.zoomType). When enabled, two-finger pinch
  4816. * will still work as set up by [chart.pinchType](#chart.pinchType).
  4817. * However, `zoomBySingleTouch` will interfere with touch-dragging the
  4818. * chart to read the tooltip. And especially when vertical zooming is
  4819. * enabled, it will make it hard to scroll vertically on the page.
  4820. * @since 9.0.0
  4821. * @sample highcharts/chart/zoombysingletouch
  4822. * Zoom by single touch enabled, with buttons to toggle
  4823. * @product highcharts highstock gantt
  4824. */
  4825. zoomBySingleTouch: false,
  4826. /**
  4827. * An explicit width for the chart. By default (when `null`) the width
  4828. * is calculated from the offset width of the containing element.
  4829. *
  4830. * @sample {highcharts} highcharts/chart/width/
  4831. * 800px wide
  4832. * @sample {highstock} stock/chart/width/
  4833. * 800px wide
  4834. * @sample {highmaps} maps/chart/size/
  4835. * Chart with explicit size
  4836. *
  4837. * @type {null|number|string}
  4838. */
  4839. width: null,
  4840. /**
  4841. * An explicit height for the chart. If a _number_, the height is
  4842. * given in pixels. If given a _percentage string_ (for example
  4843. * `'56%'`), the height is given as the percentage of the actual chart
  4844. * width. This allows for preserving the aspect ratio across responsive
  4845. * sizes.
  4846. *
  4847. * By default (when `null`) the height is calculated from the offset
  4848. * height of the containing element, or 400 pixels if the containing
  4849. * element's height is 0.
  4850. *
  4851. * @sample {highcharts} highcharts/chart/height/
  4852. * 500px height
  4853. * @sample {highstock} stock/chart/height/
  4854. * 300px height
  4855. * @sample {highmaps} maps/chart/size/
  4856. * Chart with explicit size
  4857. * @sample highcharts/chart/height-percent/
  4858. * Highcharts with percentage height
  4859. *
  4860. * @type {null|number|string}
  4861. */
  4862. height: null,
  4863. /**
  4864. * The color of the outer chart border.
  4865. *
  4866. * @see In styled mode, the stroke is set with the
  4867. * `.highcharts-background` class.
  4868. *
  4869. * @sample {highcharts} highcharts/chart/bordercolor/
  4870. * Brown border
  4871. * @sample {highstock} stock/chart/border/
  4872. * Brown border
  4873. * @sample {highmaps} maps/chart/border/
  4874. * Border options
  4875. *
  4876. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4877. */
  4878. borderColor: palette.highlightColor80,
  4879. /**
  4880. * The pixel width of the outer chart border.
  4881. *
  4882. * @see In styled mode, the stroke is set with the
  4883. * `.highcharts-background` class.
  4884. *
  4885. * @sample {highcharts} highcharts/chart/borderwidth/
  4886. * 5px border
  4887. * @sample {highstock} stock/chart/border/
  4888. * 2px border
  4889. * @sample {highmaps} maps/chart/border/
  4890. * Border options
  4891. *
  4892. * @type {number}
  4893. * @default 0
  4894. * @apioption chart.borderWidth
  4895. */
  4896. /**
  4897. * The background color or gradient for the outer chart area.
  4898. *
  4899. * @see In styled mode, the background is set with the
  4900. * `.highcharts-background` class.
  4901. *
  4902. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  4903. * Color
  4904. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  4905. * Gradient
  4906. * @sample {highstock} stock/chart/backgroundcolor-color/
  4907. * Color
  4908. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  4909. * Gradient
  4910. * @sample {highmaps} maps/chart/backgroundcolor-color/
  4911. * Color
  4912. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  4913. * Gradient
  4914. *
  4915. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4916. */
  4917. backgroundColor: palette.backgroundColor,
  4918. /**
  4919. * The background color or gradient for the plot area.
  4920. *
  4921. * @see In styled mode, the plot background is set with the
  4922. * `.highcharts-plot-background` class.
  4923. *
  4924. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  4925. * Color
  4926. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  4927. * Gradient
  4928. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  4929. * Color
  4930. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  4931. * Gradient
  4932. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  4933. * Color
  4934. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  4935. * Gradient
  4936. *
  4937. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4938. * @apioption chart.plotBackgroundColor
  4939. */
  4940. /**
  4941. * The URL for an image to use as the plot background. To set an image
  4942. * as the background for the entire chart, set a CSS background image
  4943. * to the container element. Note that for the image to be applied to
  4944. * exported charts, its URL needs to be accessible by the export server.
  4945. *
  4946. * @see In styled mode, a plot background image can be set with the
  4947. * `.highcharts-plot-background` class and a [custom pattern](
  4948. * https://www.highcharts.com/docs/chart-design-and-style/
  4949. * gradients-shadows-and-patterns).
  4950. *
  4951. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  4952. * Skies
  4953. * @sample {highstock} stock/chart/plotbackgroundimage/
  4954. * Skies
  4955. *
  4956. * @type {string}
  4957. * @apioption chart.plotBackgroundImage
  4958. */
  4959. /**
  4960. * The color of the inner chart or plot area border.
  4961. *
  4962. * @see In styled mode, a plot border stroke can be set with the
  4963. * `.highcharts-plot-border` class.
  4964. *
  4965. * @sample {highcharts} highcharts/chart/plotbordercolor/
  4966. * Blue border
  4967. * @sample {highstock} stock/chart/plotborder/
  4968. * Blue border
  4969. * @sample {highmaps} maps/chart/plotborder/
  4970. * Plot border options
  4971. *
  4972. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4973. */
  4974. plotBorderColor: palette.neutralColor20
  4975. },
  4976. /**
  4977. * The chart's main title.
  4978. *
  4979. * @sample {highmaps} maps/title/title/
  4980. * Title options demonstrated
  4981. */
  4982. title: {
  4983. /**
  4984. * When the title is floating, the plot area will not move to make space
  4985. * for it.
  4986. *
  4987. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4988. * False by default
  4989. * @sample {highcharts} highcharts/title/floating/
  4990. * True - title on top of the plot area
  4991. * @sample {highstock} stock/chart/title-floating/
  4992. * True - title on top of the plot area
  4993. *
  4994. * @type {boolean}
  4995. * @default false
  4996. * @since 2.1
  4997. * @apioption title.floating
  4998. */
  4999. /**
  5000. * CSS styles for the title. Use this for font styling, but use `align`,
  5001. * `x` and `y` for text alignment.
  5002. *
  5003. * In styled mode, the title style is given in the `.highcharts-title`
  5004. * class.
  5005. *
  5006. * @sample {highcharts} highcharts/title/style/
  5007. * Custom color and weight
  5008. * @sample {highstock} stock/chart/title-style/
  5009. * Custom color and weight
  5010. * @sample highcharts/css/titles/
  5011. * Styled mode
  5012. *
  5013. * @type {Highcharts.CSSObject}
  5014. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  5015. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  5016. * @apioption title.style
  5017. */
  5018. /**
  5019. * Whether to
  5020. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5021. * to render the text.
  5022. *
  5023. * @type {boolean}
  5024. * @default false
  5025. * @apioption title.useHTML
  5026. */
  5027. /**
  5028. * The vertical alignment of the title. Can be one of `"top"`,
  5029. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  5030. * as if [floating](#title.floating) were `true`.
  5031. *
  5032. * @sample {highcharts} highcharts/title/verticalalign/
  5033. * Chart title in bottom right corner
  5034. * @sample {highstock} stock/chart/title-verticalalign/
  5035. * Chart title in bottom right corner
  5036. *
  5037. * @type {Highcharts.VerticalAlignValue}
  5038. * @since 2.1
  5039. * @apioption title.verticalAlign
  5040. */
  5041. /**
  5042. * The x position of the title relative to the alignment within
  5043. * `chart.spacingLeft` and `chart.spacingRight`.
  5044. *
  5045. * @sample {highcharts} highcharts/title/align/
  5046. * Aligned to the plot area (x = 70px = margin left - spacing
  5047. * left)
  5048. * @sample {highstock} stock/chart/title-align/
  5049. * Aligned to the plot area (x = 50px = margin left - spacing
  5050. * left)
  5051. *
  5052. * @type {number}
  5053. * @default 0
  5054. * @since 2.0
  5055. * @apioption title.x
  5056. */
  5057. /**
  5058. * The y position of the title relative to the alignment within
  5059. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  5060. * #chart.spacingBottom). By default it depends on the font size.
  5061. *
  5062. * @sample {highcharts} highcharts/title/y/
  5063. * Title inside the plot area
  5064. * @sample {highstock} stock/chart/title-verticalalign/
  5065. * Chart title in bottom right corner
  5066. *
  5067. * @type {number}
  5068. * @since 2.0
  5069. * @apioption title.y
  5070. */
  5071. /**
  5072. * The title of the chart. To disable the title, set the `text` to
  5073. * `undefined`.
  5074. *
  5075. * @sample {highcharts} highcharts/title/text/
  5076. * Custom title
  5077. * @sample {highstock} stock/chart/title-text/
  5078. * Custom title
  5079. *
  5080. * @default {highcharts|highmaps} Chart title
  5081. * @default {highstock} undefined
  5082. */
  5083. text: 'Chart title',
  5084. /**
  5085. * The horizontal alignment of the title. Can be one of "left", "center"
  5086. * and "right".
  5087. *
  5088. * @sample {highcharts} highcharts/title/align/
  5089. * Aligned to the plot area (x = 70px = margin left - spacing
  5090. * left)
  5091. * @sample {highstock} stock/chart/title-align/
  5092. * Aligned to the plot area (x = 50px = margin left - spacing
  5093. * left)
  5094. *
  5095. * @type {Highcharts.AlignValue}
  5096. * @since 2.0
  5097. */
  5098. align: 'center',
  5099. /**
  5100. * The margin between the title and the plot area, or if a subtitle
  5101. * is present, the margin between the subtitle and the plot area.
  5102. *
  5103. * @sample {highcharts} highcharts/title/margin-50/
  5104. * A chart title margin of 50
  5105. * @sample {highcharts} highcharts/title/margin-subtitle/
  5106. * The same margin applied with a subtitle
  5107. * @sample {highstock} stock/chart/title-margin/
  5108. * A chart title margin of 50
  5109. *
  5110. * @since 2.1
  5111. */
  5112. margin: 15,
  5113. /**
  5114. * Adjustment made to the title width, normally to reserve space for
  5115. * the exporting burger menu.
  5116. *
  5117. * @sample highcharts/title/widthadjust/
  5118. * Wider menu, greater padding
  5119. *
  5120. * @since 4.2.5
  5121. */
  5122. widthAdjust: -44
  5123. },
  5124. /**
  5125. * The chart's subtitle. This can be used both to display a subtitle below
  5126. * the main title, and to display random text anywhere in the chart. The
  5127. * subtitle can be updated after chart initialization through the
  5128. * `Chart.setTitle` method.
  5129. *
  5130. * @sample {highmaps} maps/title/subtitle/
  5131. * Subtitle options demonstrated
  5132. */
  5133. subtitle: {
  5134. /**
  5135. * When the subtitle is floating, the plot area will not move to make
  5136. * space for it.
  5137. *
  5138. * @sample {highcharts} highcharts/subtitle/floating/
  5139. * Floating title and subtitle
  5140. * @sample {highstock} stock/chart/subtitle-footnote
  5141. * Footnote floating at bottom right of plot area
  5142. *
  5143. * @type {boolean}
  5144. * @default false
  5145. * @since 2.1
  5146. * @apioption subtitle.floating
  5147. */
  5148. /**
  5149. * CSS styles for the title.
  5150. *
  5151. * In styled mode, the subtitle style is given in the
  5152. * `.highcharts-subtitle` class.
  5153. *
  5154. * @sample {highcharts} highcharts/subtitle/style/
  5155. * Custom color and weight
  5156. * @sample {highcharts} highcharts/css/titles/
  5157. * Styled mode
  5158. * @sample {highstock} stock/chart/subtitle-style
  5159. * Custom color and weight
  5160. * @sample {highstock} highcharts/css/titles/
  5161. * Styled mode
  5162. * @sample {highmaps} highcharts/css/titles/
  5163. * Styled mode
  5164. *
  5165. * @type {Highcharts.CSSObject}
  5166. * @default {"color": "#666666"}
  5167. * @apioption subtitle.style
  5168. */
  5169. /**
  5170. * Whether to
  5171. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5172. * to render the text.
  5173. *
  5174. * @type {boolean}
  5175. * @default false
  5176. * @apioption subtitle.useHTML
  5177. */
  5178. /**
  5179. * The vertical alignment of the title. Can be one of `"top"`,
  5180. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  5181. * floating.
  5182. *
  5183. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5184. * Footnote at the bottom right of plot area
  5185. * @sample {highstock} stock/chart/subtitle-footnote
  5186. * Footnote at the bottom right of plot area
  5187. *
  5188. * @type {Highcharts.VerticalAlignValue}
  5189. * @since 2.1
  5190. * @apioption subtitle.verticalAlign
  5191. */
  5192. /**
  5193. * The x position of the subtitle relative to the alignment within
  5194. * `chart.spacingLeft` and `chart.spacingRight`.
  5195. *
  5196. * @sample {highcharts} highcharts/subtitle/align/
  5197. * Footnote at right of plot area
  5198. * @sample {highstock} stock/chart/subtitle-footnote
  5199. * Footnote at the bottom right of plot area
  5200. *
  5201. * @type {number}
  5202. * @default 0
  5203. * @since 2.0
  5204. * @apioption subtitle.x
  5205. */
  5206. /**
  5207. * The y position of the subtitle relative to the alignment within
  5208. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  5209. * is laid out below the title unless the title is floating.
  5210. *
  5211. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5212. * Footnote at the bottom right of plot area
  5213. * @sample {highstock} stock/chart/subtitle-footnote
  5214. * Footnote at the bottom right of plot area
  5215. *
  5216. * @type {number}
  5217. * @since 2.0
  5218. * @apioption subtitle.y
  5219. */
  5220. /**
  5221. * The subtitle of the chart.
  5222. *
  5223. * @sample {highcharts|highstock} highcharts/subtitle/text/
  5224. * Custom subtitle
  5225. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  5226. * Formatted and linked text.
  5227. */
  5228. text: '',
  5229. /**
  5230. * The horizontal alignment of the subtitle. Can be one of "left",
  5231. * "center" and "right".
  5232. *
  5233. * @sample {highcharts} highcharts/subtitle/align/
  5234. * Footnote at right of plot area
  5235. * @sample {highstock} stock/chart/subtitle-footnote
  5236. * Footnote at bottom right of plot area
  5237. *
  5238. * @type {Highcharts.AlignValue}
  5239. * @since 2.0
  5240. */
  5241. align: 'center',
  5242. /**
  5243. * Adjustment made to the subtitle width, normally to reserve space
  5244. * for the exporting burger menu.
  5245. *
  5246. * @see [title.widthAdjust](#title.widthAdjust)
  5247. *
  5248. * @sample highcharts/title/widthadjust/
  5249. * Wider menu, greater padding
  5250. *
  5251. * @since 4.2.5
  5252. */
  5253. widthAdjust: -44
  5254. },
  5255. /**
  5256. * The chart's caption, which will render below the chart and will be part
  5257. * of exported charts. The caption can be updated after chart initialization
  5258. * through the `Chart.update` or `Chart.caption.update` methods.
  5259. *
  5260. * @sample highcharts/caption/text/
  5261. * A chart with a caption
  5262. * @since 7.2.0
  5263. */
  5264. caption: {
  5265. /**
  5266. * When the caption is floating, the plot area will not move to make
  5267. * space for it.
  5268. *
  5269. * @type {boolean}
  5270. * @default false
  5271. * @apioption caption.floating
  5272. */
  5273. /**
  5274. * The margin between the caption and the plot area.
  5275. */
  5276. margin: 15,
  5277. /**
  5278. * CSS styles for the caption.
  5279. *
  5280. * In styled mode, the caption style is given in the
  5281. * `.highcharts-caption` class.
  5282. *
  5283. * @sample {highcharts} highcharts/css/titles/
  5284. * Styled mode
  5285. *
  5286. * @type {Highcharts.CSSObject}
  5287. * @default {"color": "#666666"}
  5288. * @apioption caption.style
  5289. */
  5290. /**
  5291. * Whether to
  5292. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5293. * to render the text.
  5294. *
  5295. * @type {boolean}
  5296. * @default false
  5297. * @apioption caption.useHTML
  5298. */
  5299. /**
  5300. * The x position of the caption relative to the alignment within
  5301. * `chart.spacingLeft` and `chart.spacingRight`.
  5302. *
  5303. * @type {number}
  5304. * @default 0
  5305. * @apioption caption.x
  5306. */
  5307. /**
  5308. * The y position of the caption relative to the alignment within
  5309. * `chart.spacingTop` and `chart.spacingBottom`.
  5310. *
  5311. * @type {number}
  5312. * @apioption caption.y
  5313. */
  5314. /**
  5315. * The caption text of the chart.
  5316. *
  5317. * @sample {highcharts} highcharts/caption/text/
  5318. * Custom caption
  5319. */
  5320. text: '',
  5321. /**
  5322. * The horizontal alignment of the caption. Can be one of "left",
  5323. * "center" and "right".
  5324. *
  5325. * @type {Highcharts.AlignValue}
  5326. */
  5327. align: 'left',
  5328. /**
  5329. * The vertical alignment of the caption. Can be one of `"top"`,
  5330. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  5331. * floating.
  5332. *
  5333. * @type {Highcharts.VerticalAlignValue}
  5334. */
  5335. verticalAlign: 'bottom'
  5336. },
  5337. /**
  5338. * The plotOptions is a wrapper object for config objects for each series
  5339. * type. The config objects for each series can also be overridden for
  5340. * each series item as given in the series array.
  5341. *
  5342. * Configuration options for the series are given in three levels. Options
  5343. * for all series in a chart are given in the [plotOptions.series](
  5344. * #plotOptions.series) object. Then options for all series of a specific
  5345. * type are given in the plotOptions of that type, for example
  5346. * `plotOptions.line`. Next, options for one single series are given in
  5347. * [the series array](#series).
  5348. */
  5349. plotOptions: {},
  5350. /**
  5351. * HTML labels that can be positioned anywhere in the chart area.
  5352. *
  5353. * This option is deprecated since v7.1.2. Instead, use
  5354. * [annotations](#annotations) that support labels.
  5355. *
  5356. * @deprecated
  5357. * @product highcharts highstock
  5358. */
  5359. labels: {
  5360. /**
  5361. * An HTML label that can be positioned anywhere in the chart area.
  5362. *
  5363. * @deprecated
  5364. * @type {Array<*>}
  5365. * @apioption labels.items
  5366. */
  5367. /**
  5368. * Inner HTML or text for the label.
  5369. *
  5370. * @deprecated
  5371. * @type {string}
  5372. * @apioption labels.items.html
  5373. */
  5374. /**
  5375. * CSS styles for each label. To position the label, use left and top
  5376. * like this:
  5377. * ```js
  5378. * style: {
  5379. * left: '100px',
  5380. * top: '100px'
  5381. * }
  5382. * ```
  5383. *
  5384. * @deprecated
  5385. * @type {Highcharts.CSSObject}
  5386. * @apioption labels.items.style
  5387. */
  5388. /**
  5389. * Shared CSS styles for all labels.
  5390. *
  5391. * @deprecated
  5392. * @type {Highcharts.CSSObject}
  5393. * @default {"color": "#333333", "position": "absolute"}
  5394. */
  5395. style: {
  5396. /**
  5397. * @ignore-option
  5398. */
  5399. position: 'absolute',
  5400. /**
  5401. * @ignore-option
  5402. */
  5403. color: palette.neutralColor80
  5404. }
  5405. },
  5406. /**
  5407. * The legend is a box containing a symbol and name for each series
  5408. * item or point item in the chart. Each series (or points in case
  5409. * of pie charts) is represented by a symbol and its name in the legend.
  5410. *
  5411. * It is possible to override the symbol creator function and create
  5412. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  5413. *
  5414. * @productdesc {highmaps}
  5415. * A Highmaps legend by default contains one legend item per series, but if
  5416. * a `colorAxis` is defined, the axis will be displayed in the legend.
  5417. * Either as a gradient, or as multiple legend items for `dataClasses`.
  5418. */
  5419. legend: {
  5420. /**
  5421. * The background color of the legend.
  5422. *
  5423. * @see In styled mode, the legend background fill can be applied with
  5424. * the `.highcharts-legend-box` class.
  5425. *
  5426. * @sample {highcharts} highcharts/legend/backgroundcolor/
  5427. * Yellowish background
  5428. * @sample {highstock} stock/legend/align/
  5429. * Various legend options
  5430. * @sample {highmaps} maps/legend/border-background/
  5431. * Border and background options
  5432. *
  5433. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5434. * @apioption legend.backgroundColor
  5435. */
  5436. /**
  5437. * The width of the drawn border around the legend.
  5438. *
  5439. * @see In styled mode, the legend border stroke width can be applied
  5440. * with the `.highcharts-legend-box` class.
  5441. *
  5442. * @sample {highcharts} highcharts/legend/borderwidth/
  5443. * 2px border width
  5444. * @sample {highstock} stock/legend/align/
  5445. * Various legend options
  5446. * @sample {highmaps} maps/legend/border-background/
  5447. * Border and background options
  5448. *
  5449. * @type {number}
  5450. * @default 0
  5451. * @apioption legend.borderWidth
  5452. */
  5453. /**
  5454. * Enable or disable the legend. There is also a series-specific option,
  5455. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  5456. * series from the legend. In some series types this is `false` by
  5457. * default, so it must set to `true` in order to show the legend for the
  5458. * series.
  5459. *
  5460. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  5461. * @sample {highstock} stock/legend/align/ Various legend options
  5462. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  5463. *
  5464. * @default {highstock} false
  5465. * @default {highmaps} true
  5466. * @default {gantt} false
  5467. */
  5468. enabled: true,
  5469. /**
  5470. * The horizontal alignment of the legend box within the chart area.
  5471. * Valid values are `left`, `center` and `right`.
  5472. *
  5473. * In the case that the legend is aligned in a corner position, the
  5474. * `layout` option will determine whether to place it above/below
  5475. * or on the side of the plot area.
  5476. *
  5477. * @sample {highcharts} highcharts/legend/align/
  5478. * Legend at the right of the chart
  5479. * @sample {highstock} stock/legend/align/
  5480. * Various legend options
  5481. * @sample {highmaps} maps/legend/alignment/
  5482. * Legend alignment
  5483. *
  5484. * @type {Highcharts.AlignValue}
  5485. * @since 2.0
  5486. */
  5487. align: 'center',
  5488. /**
  5489. * If the [layout](legend.layout) is `horizontal` and the legend items
  5490. * span over two lines or more, whether to align the items into vertical
  5491. * columns. Setting this to `false` makes room for more items, but will
  5492. * look more messy.
  5493. *
  5494. * @since 6.1.0
  5495. */
  5496. alignColumns: true,
  5497. /**
  5498. * When the legend is floating, the plot area ignores it and is allowed
  5499. * to be placed below it.
  5500. *
  5501. * @sample {highcharts} highcharts/legend/floating-false/
  5502. * False by default
  5503. * @sample {highcharts} highcharts/legend/floating-true/
  5504. * True
  5505. * @sample {highmaps} maps/legend/alignment/
  5506. * Floating legend
  5507. *
  5508. * @type {boolean}
  5509. * @default false
  5510. * @since 2.1
  5511. * @apioption legend.floating
  5512. */
  5513. /**
  5514. * The layout of the legend items. Can be one of `horizontal` or
  5515. * `vertical` or `proximate`. When `proximate`, the legend items will be
  5516. * placed as close as possible to the graphs they're representing,
  5517. * except in inverted charts or when the legend position doesn't allow
  5518. * it.
  5519. *
  5520. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5521. * Horizontal by default
  5522. * @sample {highcharts} highcharts/legend/layout-vertical/
  5523. * Vertical
  5524. * @sample highcharts/legend/layout-proximate
  5525. * Labels proximate to the data
  5526. * @sample {highstock} stock/legend/layout-horizontal/
  5527. * Horizontal by default
  5528. * @sample {highmaps} maps/legend/padding-itemmargin/
  5529. * Vertical with data classes
  5530. * @sample {highmaps} maps/legend/layout-vertical/
  5531. * Vertical with color axis gradient
  5532. *
  5533. * @validvalue ["horizontal", "vertical", "proximate"]
  5534. */
  5535. layout: 'horizontal',
  5536. /**
  5537. * In a legend with horizontal layout, the itemDistance defines the
  5538. * pixel distance between each item.
  5539. *
  5540. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5541. * 50px item distance
  5542. * @sample {highstock} highcharts/legend/layout-horizontal/
  5543. * 50px item distance
  5544. *
  5545. * @type {number}
  5546. * @default {highcharts} 20
  5547. * @default {highstock} 20
  5548. * @default {highmaps} 8
  5549. * @since 3.0.3
  5550. * @apioption legend.itemDistance
  5551. */
  5552. /**
  5553. * The pixel bottom margin for each legend item.
  5554. *
  5555. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5556. * Padding and item margins demonstrated
  5557. * @sample {highmaps} maps/legend/padding-itemmargin/
  5558. * Padding and item margins demonstrated
  5559. *
  5560. * @type {number}
  5561. * @default 0
  5562. * @since 2.2.0
  5563. * @apioption legend.itemMarginBottom
  5564. */
  5565. /**
  5566. * The pixel top margin for each legend item.
  5567. *
  5568. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5569. * Padding and item margins demonstrated
  5570. * @sample {highmaps} maps/legend/padding-itemmargin/
  5571. * Padding and item margins demonstrated
  5572. *
  5573. * @type {number}
  5574. * @default 0
  5575. * @since 2.2.0
  5576. * @apioption legend.itemMarginTop
  5577. */
  5578. /**
  5579. * The width for each legend item. By default the items are laid out
  5580. * successively. In a [horizontal layout](legend.layout), if the items
  5581. * are laid out across two rows or more, they will be vertically aligned
  5582. * depending on the [legend.alignColumns](legend.alignColumns) option.
  5583. *
  5584. * @sample {highcharts} highcharts/legend/itemwidth-default/
  5585. * Undefined by default
  5586. * @sample {highcharts} highcharts/legend/itemwidth-80/
  5587. * 80 for aligned legend items
  5588. *
  5589. * @type {number}
  5590. * @since 2.0
  5591. * @apioption legend.itemWidth
  5592. */
  5593. /**
  5594. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  5595. * for each legend label. Available variables relates to properties on
  5596. * the series, or the point in case of pies.
  5597. *
  5598. * @type {string}
  5599. * @default {name}
  5600. * @since 1.3
  5601. * @apioption legend.labelFormat
  5602. */
  5603. /* eslint-disable valid-jsdoc */
  5604. /**
  5605. * Callback function to format each of the series' labels. The `this`
  5606. * keyword refers to the series object, or the point object in case of
  5607. * pie charts. By default the series or point name is printed.
  5608. *
  5609. * @productdesc {highmaps}
  5610. * In Highmaps the context can also be a data class in case of a
  5611. * `colorAxis`.
  5612. *
  5613. * @sample {highcharts} highcharts/legend/labelformatter/
  5614. * Add text
  5615. * @sample {highmaps} maps/legend/labelformatter/
  5616. * Data classes with label formatter
  5617. *
  5618. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  5619. */
  5620. labelFormatter: function () {
  5621. /** eslint-enable valid-jsdoc */
  5622. return this.name;
  5623. },
  5624. /**
  5625. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  5626. * the line height for each item can be set using
  5627. * `itemStyle.lineHeight`, and the padding between items using
  5628. * `itemMarginTop` and `itemMarginBottom`.
  5629. *
  5630. * @sample {highcharts} highcharts/legend/lineheight/
  5631. * Setting padding
  5632. *
  5633. * @deprecated
  5634. *
  5635. * @type {number}
  5636. * @default 16
  5637. * @since 2.0
  5638. * @product highcharts gantt
  5639. * @apioption legend.lineHeight
  5640. */
  5641. /**
  5642. * If the plot area sized is calculated automatically and the legend is
  5643. * not floating, the legend margin is the space between the legend and
  5644. * the axis labels or plot area.
  5645. *
  5646. * @sample {highcharts} highcharts/legend/margin-default/
  5647. * 12 pixels by default
  5648. * @sample {highcharts} highcharts/legend/margin-30/
  5649. * 30 pixels
  5650. *
  5651. * @type {number}
  5652. * @default 12
  5653. * @since 2.1
  5654. * @apioption legend.margin
  5655. */
  5656. /**
  5657. * Maximum pixel height for the legend. When the maximum height is
  5658. * extended, navigation will show.
  5659. *
  5660. * @type {number}
  5661. * @since 2.3.0
  5662. * @apioption legend.maxHeight
  5663. */
  5664. /**
  5665. * The color of the drawn border around the legend.
  5666. *
  5667. * @see In styled mode, the legend border stroke can be applied with the
  5668. * `.highcharts-legend-box` class.
  5669. *
  5670. * @sample {highcharts} highcharts/legend/bordercolor/
  5671. * Brown border
  5672. * @sample {highstock} stock/legend/align/
  5673. * Various legend options
  5674. * @sample {highmaps} maps/legend/border-background/
  5675. * Border and background options
  5676. *
  5677. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5678. */
  5679. borderColor: palette.neutralColor40,
  5680. /**
  5681. * The border corner radius of the legend.
  5682. *
  5683. * @sample {highcharts} highcharts/legend/borderradius-default/
  5684. * Square by default
  5685. * @sample {highcharts} highcharts/legend/borderradius-round/
  5686. * 5px rounded
  5687. * @sample {highmaps} maps/legend/border-background/
  5688. * Border and background options
  5689. */
  5690. borderRadius: 0,
  5691. /**
  5692. * Options for the paging or navigation appearing when the legend is
  5693. * overflown. Navigation works well on screen, but not in static
  5694. * exported images. One way of working around that is to
  5695. * [increase the chart height in
  5696. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  5697. */
  5698. navigation: {
  5699. /**
  5700. * How to animate the pages when navigating up or down. A value of
  5701. * `true` applies the default navigation given in the
  5702. * `chart.animation` option. Additional options can be given as an
  5703. * object containing values for easing and duration.
  5704. *
  5705. * @sample {highcharts} highcharts/legend/navigation/
  5706. * Legend page navigation demonstrated
  5707. * @sample {highstock} highcharts/legend/navigation/
  5708. * Legend page navigation demonstrated
  5709. *
  5710. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  5711. * @default true
  5712. * @since 2.2.4
  5713. * @apioption legend.navigation.animation
  5714. */
  5715. /**
  5716. * The pixel size of the up and down arrows in the legend paging
  5717. * navigation.
  5718. *
  5719. * @sample {highcharts} highcharts/legend/navigation/
  5720. * Legend page navigation demonstrated
  5721. * @sample {highstock} highcharts/legend/navigation/
  5722. * Legend page navigation demonstrated
  5723. *
  5724. * @type {number}
  5725. * @default 12
  5726. * @since 2.2.4
  5727. * @apioption legend.navigation.arrowSize
  5728. */
  5729. /**
  5730. * Whether to enable the legend navigation. In most cases, disabling
  5731. * the navigation results in an unwanted overflow.
  5732. *
  5733. * See also the [adapt chart to legend](
  5734. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  5735. * plugin for a solution to extend the chart height to make room for
  5736. * the legend, optionally in exported charts only.
  5737. *
  5738. * @type {boolean}
  5739. * @default true
  5740. * @since 4.2.4
  5741. * @apioption legend.navigation.enabled
  5742. */
  5743. /**
  5744. * Text styles for the legend page navigation.
  5745. *
  5746. * @see In styled mode, the navigation items are styled with the
  5747. * `.highcharts-legend-navigation` class.
  5748. *
  5749. * @sample {highcharts} highcharts/legend/navigation/
  5750. * Legend page navigation demonstrated
  5751. * @sample {highstock} highcharts/legend/navigation/
  5752. * Legend page navigation demonstrated
  5753. *
  5754. * @type {Highcharts.CSSObject}
  5755. * @since 2.2.4
  5756. * @apioption legend.navigation.style
  5757. */
  5758. /**
  5759. * The color for the active up or down arrow in the legend page
  5760. * navigation.
  5761. *
  5762. * @see In styled mode, the active arrow be styled with the
  5763. * `.highcharts-legend-nav-active` class.
  5764. *
  5765. * @sample {highcharts} highcharts/legend/navigation/
  5766. * Legend page navigation demonstrated
  5767. * @sample {highstock} highcharts/legend/navigation/
  5768. * Legend page navigation demonstrated
  5769. *
  5770. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5771. * @since 2.2.4
  5772. */
  5773. activeColor: palette.highlightColor100,
  5774. /**
  5775. * The color of the inactive up or down arrow in the legend page
  5776. * navigation. .
  5777. *
  5778. * @see In styled mode, the inactive arrow be styled with the
  5779. * `.highcharts-legend-nav-inactive` class.
  5780. *
  5781. * @sample {highcharts} highcharts/legend/navigation/
  5782. * Legend page navigation demonstrated
  5783. * @sample {highstock} highcharts/legend/navigation/
  5784. * Legend page navigation demonstrated
  5785. *
  5786. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5787. * @since 2.2.4
  5788. */
  5789. inactiveColor: palette.neutralColor20
  5790. },
  5791. /**
  5792. * The inner padding of the legend box.
  5793. *
  5794. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5795. * Padding and item margins demonstrated
  5796. * @sample {highmaps} maps/legend/padding-itemmargin/
  5797. * Padding and item margins demonstrated
  5798. *
  5799. * @type {number}
  5800. * @default 8
  5801. * @since 2.2.0
  5802. * @apioption legend.padding
  5803. */
  5804. /**
  5805. * Whether to reverse the order of the legend items compared to the
  5806. * order of the series or points as defined in the configuration object.
  5807. *
  5808. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  5809. * [series.legendIndex](#series.legendIndex)
  5810. *
  5811. * @sample {highcharts} highcharts/legend/reversed/
  5812. * Stacked bar with reversed legend
  5813. *
  5814. * @type {boolean}
  5815. * @default false
  5816. * @since 1.2.5
  5817. * @apioption legend.reversed
  5818. */
  5819. /**
  5820. * Whether to show the symbol on the right side of the text rather than
  5821. * the left side. This is common in Arabic and Hebrew.
  5822. *
  5823. * @sample {highcharts} highcharts/legend/rtl/
  5824. * Symbol to the right
  5825. *
  5826. * @type {boolean}
  5827. * @default false
  5828. * @since 2.2
  5829. * @apioption legend.rtl
  5830. */
  5831. /**
  5832. * CSS styles for the legend area. In the 1.x versions the position
  5833. * of the legend area was determined by CSS. In 2.x, the position is
  5834. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  5835. * but the styles are still parsed for backwards compatibility.
  5836. *
  5837. * @deprecated
  5838. *
  5839. * @type {Highcharts.CSSObject}
  5840. * @product highcharts highstock
  5841. * @apioption legend.style
  5842. */
  5843. /**
  5844. * CSS styles for each legend item. Only a subset of CSS is supported,
  5845. * notably those options related to text. The default `textOverflow`
  5846. * property makes long texts truncate. Set it to `undefined` to wrap
  5847. * text instead. A `width` property can be added to control the text
  5848. * width.
  5849. *
  5850. * @see In styled mode, the legend items can be styled with the
  5851. * `.highcharts-legend-item` class.
  5852. *
  5853. * @sample {highcharts} highcharts/legend/itemstyle/
  5854. * Bold black text
  5855. * @sample {highmaps} maps/legend/itemstyle/
  5856. * Item text styles
  5857. *
  5858. * @type {Highcharts.CSSObject}
  5859. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  5860. */
  5861. itemStyle: {
  5862. /**
  5863. * @ignore
  5864. */
  5865. color: palette.neutralColor80,
  5866. /**
  5867. * @ignore
  5868. */
  5869. cursor: 'pointer',
  5870. /**
  5871. * @ignore
  5872. */
  5873. fontSize: '12px',
  5874. /**
  5875. * @ignore
  5876. */
  5877. fontWeight: 'bold',
  5878. /**
  5879. * @ignore
  5880. */
  5881. textOverflow: 'ellipsis'
  5882. },
  5883. /**
  5884. * CSS styles for each legend item in hover mode. Only a subset of
  5885. * CSS is supported, notably those options related to text. Properties
  5886. * are inherited from `style` unless overridden here.
  5887. *
  5888. * @see In styled mode, the hovered legend items can be styled with
  5889. * the `.highcharts-legend-item:hover` pesudo-class.
  5890. *
  5891. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  5892. * Red on hover
  5893. * @sample {highmaps} maps/legend/itemstyle/
  5894. * Item text styles
  5895. *
  5896. * @type {Highcharts.CSSObject}
  5897. * @default {"color": "#000000"}
  5898. */
  5899. itemHoverStyle: {
  5900. /**
  5901. * @ignore
  5902. */
  5903. color: palette.neutralColor100
  5904. },
  5905. /**
  5906. * CSS styles for each legend item when the corresponding series or
  5907. * point is hidden. Only a subset of CSS is supported, notably those
  5908. * options related to text. Properties are inherited from `style`
  5909. * unless overridden here.
  5910. *
  5911. * @see In styled mode, the hidden legend items can be styled with
  5912. * the `.highcharts-legend-item-hidden` class.
  5913. *
  5914. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  5915. * Darker gray color
  5916. *
  5917. * @type {Highcharts.CSSObject}
  5918. * @default {"color": "#cccccc"}
  5919. */
  5920. itemHiddenStyle: {
  5921. /**
  5922. * @ignore
  5923. */
  5924. color: palette.neutralColor20
  5925. },
  5926. /**
  5927. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  5928. * also needs to be applied for this to take effect. The shadow can be
  5929. * an object configuration containing `color`, `offsetX`, `offsetY`,
  5930. * `opacity` and `width`.
  5931. *
  5932. * @sample {highcharts} highcharts/legend/shadow/
  5933. * White background and drop shadow
  5934. * @sample {highstock} stock/legend/align/
  5935. * Various legend options
  5936. * @sample {highmaps} maps/legend/border-background/
  5937. * Border and background options
  5938. *
  5939. * @type {boolean|Highcharts.CSSObject}
  5940. */
  5941. shadow: false,
  5942. /**
  5943. * Default styling for the checkbox next to a legend item when
  5944. * `showCheckbox` is true.
  5945. *
  5946. * @type {Highcharts.CSSObject}
  5947. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  5948. */
  5949. itemCheckboxStyle: {
  5950. /**
  5951. * @ignore
  5952. */
  5953. position: 'absolute',
  5954. /**
  5955. * @ignore
  5956. */
  5957. width: '13px',
  5958. /**
  5959. * @ignore
  5960. */
  5961. height: '13px'
  5962. },
  5963. // itemWidth: undefined,
  5964. /**
  5965. * When this is true, the legend symbol width will be the same as
  5966. * the symbol height, which in turn defaults to the font size of the
  5967. * legend items.
  5968. *
  5969. * @since 5.0.0
  5970. */
  5971. squareSymbol: true,
  5972. /**
  5973. * The pixel height of the symbol for series types that use a rectangle
  5974. * in the legend. Defaults to the font size of legend items.
  5975. *
  5976. * @productdesc {highmaps}
  5977. * In Highmaps, when the symbol is the gradient of a vertical color
  5978. * axis, the height defaults to 200.
  5979. *
  5980. * @sample {highmaps} maps/legend/layout-vertical-sized/
  5981. * Sized vertical gradient
  5982. * @sample {highmaps} maps/legend/padding-itemmargin/
  5983. * No distance between data classes
  5984. *
  5985. * @type {number}
  5986. * @since 3.0.8
  5987. * @apioption legend.symbolHeight
  5988. */
  5989. /**
  5990. * The border radius of the symbol for series types that use a rectangle
  5991. * in the legend. Defaults to half the `symbolHeight`.
  5992. *
  5993. * @sample {highcharts} highcharts/legend/symbolradius/
  5994. * Round symbols
  5995. * @sample {highstock} highcharts/legend/symbolradius/
  5996. * Round symbols
  5997. * @sample {highmaps} highcharts/legend/symbolradius/
  5998. * Round symbols
  5999. *
  6000. * @type {number}
  6001. * @since 3.0.8
  6002. * @apioption legend.symbolRadius
  6003. */
  6004. /**
  6005. * The pixel width of the legend item symbol. When the `squareSymbol`
  6006. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  6007. *
  6008. * @productdesc {highmaps}
  6009. * In Highmaps, when the symbol is the gradient of a horizontal color
  6010. * axis, the width defaults to 200.
  6011. *
  6012. * @sample {highcharts} highcharts/legend/symbolwidth/
  6013. * Greater symbol width and padding
  6014. * @sample {highmaps} maps/legend/padding-itemmargin/
  6015. * Padding and item margins demonstrated
  6016. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6017. * Sized vertical gradient
  6018. *
  6019. * @type {number}
  6020. * @apioption legend.symbolWidth
  6021. */
  6022. /**
  6023. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  6024. * to render the legend item texts.
  6025. *
  6026. * Prior to 4.1.7, when using HTML, [legend.navigation](
  6027. * #legend.navigation) was disabled.
  6028. *
  6029. * @type {boolean}
  6030. * @default false
  6031. * @apioption legend.useHTML
  6032. */
  6033. /**
  6034. * The width of the legend box. If a number is set, it translates to
  6035. * pixels. Since v7.0.2 it allows setting a percent string of the full
  6036. * chart width, for example `40%`.
  6037. *
  6038. * Defaults to the full chart width for legends below or above the
  6039. * chart, half the chart width for legends to the left and right.
  6040. *
  6041. * @sample {highcharts} highcharts/legend/width/
  6042. * Aligned to the plot area
  6043. * @sample {highcharts} highcharts/legend/width-percent/
  6044. * A percent of the chart width
  6045. *
  6046. * @type {number|string}
  6047. * @since 2.0
  6048. * @apioption legend.width
  6049. */
  6050. /**
  6051. * The pixel padding between the legend item symbol and the legend
  6052. * item text.
  6053. *
  6054. * @sample {highcharts} highcharts/legend/symbolpadding/
  6055. * Greater symbol width and padding
  6056. */
  6057. symbolPadding: 5,
  6058. /**
  6059. * The vertical alignment of the legend box. Can be one of `top`,
  6060. * `middle` or `bottom`. Vertical position can be further determined
  6061. * by the `y` option.
  6062. *
  6063. * In the case that the legend is aligned in a corner position, the
  6064. * `layout` option will determine whether to place it above/below
  6065. * or on the side of the plot area.
  6066. *
  6067. * When the [layout](#legend.layout) option is `proximate`, the
  6068. * `verticalAlign` option doesn't apply.
  6069. *
  6070. * @sample {highcharts} highcharts/legend/verticalalign/
  6071. * Legend 100px from the top of the chart
  6072. * @sample {highstock} stock/legend/align/
  6073. * Various legend options
  6074. * @sample {highmaps} maps/legend/alignment/
  6075. * Legend alignment
  6076. *
  6077. * @type {Highcharts.VerticalAlignValue}
  6078. * @since 2.0
  6079. */
  6080. verticalAlign: 'bottom',
  6081. // width: undefined,
  6082. /**
  6083. * The x offset of the legend relative to its horizontal alignment
  6084. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  6085. * x moves it to the left, positive x moves it to the right.
  6086. *
  6087. * @sample {highcharts} highcharts/legend/width/
  6088. * Aligned to the plot area
  6089. *
  6090. * @since 2.0
  6091. */
  6092. x: 0,
  6093. /**
  6094. * The vertical offset of the legend relative to it's vertical alignment
  6095. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  6096. * Negative y moves it up, positive y moves it down.
  6097. *
  6098. * @sample {highcharts} highcharts/legend/verticalalign/
  6099. * Legend 100px from the top of the chart
  6100. * @sample {highstock} stock/legend/align/
  6101. * Various legend options
  6102. * @sample {highmaps} maps/legend/alignment/
  6103. * Legend alignment
  6104. *
  6105. * @since 2.0
  6106. */
  6107. y: 0,
  6108. /**
  6109. * A title to be added on top of the legend.
  6110. *
  6111. * @sample {highcharts} highcharts/legend/title/
  6112. * Legend title
  6113. * @sample {highmaps} maps/legend/alignment/
  6114. * Legend with title
  6115. *
  6116. * @since 3.0
  6117. */
  6118. title: {
  6119. /**
  6120. * A text or HTML string for the title.
  6121. *
  6122. * @type {string}
  6123. * @since 3.0
  6124. * @apioption legend.title.text
  6125. */
  6126. /**
  6127. * Generic CSS styles for the legend title.
  6128. *
  6129. * @see In styled mode, the legend title is styled with the
  6130. * `.highcharts-legend-title` class.
  6131. *
  6132. * @type {Highcharts.CSSObject}
  6133. * @default {"fontWeight": "bold"}
  6134. * @since 3.0
  6135. */
  6136. style: {
  6137. /**
  6138. * @ignore
  6139. */
  6140. fontWeight: 'bold'
  6141. }
  6142. }
  6143. },
  6144. /**
  6145. * The loading options control the appearance of the loading screen
  6146. * that covers the plot area on chart operations. This screen only
  6147. * appears after an explicit call to `chart.showLoading()`. It is a
  6148. * utility for developers to communicate to the end user that something
  6149. * is going on, for example while retrieving new data via an XHR connection.
  6150. * The "Loading..." text itself is not part of this configuration
  6151. * object, but part of the `lang` object.
  6152. */
  6153. loading: {
  6154. /**
  6155. * The duration in milliseconds of the fade out effect.
  6156. *
  6157. * @sample highcharts/loading/hideduration/
  6158. * Fade in and out over a second
  6159. *
  6160. * @type {number}
  6161. * @default 100
  6162. * @since 1.2.0
  6163. * @apioption loading.hideDuration
  6164. */
  6165. /**
  6166. * The duration in milliseconds of the fade in effect.
  6167. *
  6168. * @sample highcharts/loading/hideduration/
  6169. * Fade in and out over a second
  6170. *
  6171. * @type {number}
  6172. * @default 100
  6173. * @since 1.2.0
  6174. * @apioption loading.showDuration
  6175. */
  6176. /**
  6177. * CSS styles for the loading label `span`.
  6178. *
  6179. * @see In styled mode, the loading label is styled with the
  6180. * `.highcharts-loading-inner` class.
  6181. *
  6182. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  6183. * Vertically centered
  6184. * @sample {highstock} stock/loading/general/
  6185. * Label styles
  6186. *
  6187. * @type {Highcharts.CSSObject}
  6188. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  6189. * @since 1.2.0
  6190. */
  6191. labelStyle: {
  6192. /**
  6193. * @ignore
  6194. */
  6195. fontWeight: 'bold',
  6196. /**
  6197. * @ignore
  6198. */
  6199. position: 'relative',
  6200. /**
  6201. * @ignore
  6202. */
  6203. top: '45%'
  6204. },
  6205. /**
  6206. * CSS styles for the loading screen that covers the plot area.
  6207. *
  6208. * In styled mode, the loading label is styled with the
  6209. * `.highcharts-loading` class.
  6210. *
  6211. * @sample {highcharts|highmaps} highcharts/loading/style/
  6212. * Gray plot area, white text
  6213. * @sample {highstock} stock/loading/general/
  6214. * Gray plot area, white text
  6215. *
  6216. * @type {Highcharts.CSSObject}
  6217. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  6218. * @since 1.2.0
  6219. */
  6220. style: {
  6221. /**
  6222. * @ignore
  6223. */
  6224. position: 'absolute',
  6225. /**
  6226. * @ignore
  6227. */
  6228. backgroundColor: palette.backgroundColor,
  6229. /**
  6230. * @ignore
  6231. */
  6232. opacity: 0.5,
  6233. /**
  6234. * @ignore
  6235. */
  6236. textAlign: 'center'
  6237. }
  6238. },
  6239. /**
  6240. * Options for the tooltip that appears when the user hovers over a
  6241. * series or point.
  6242. *
  6243. * @declare Highcharts.TooltipOptions
  6244. */
  6245. tooltip: {
  6246. /**
  6247. * The color of the tooltip border. When `undefined`, the border takes
  6248. * the color of the corresponding series or point.
  6249. *
  6250. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6251. * Follow series by default
  6252. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  6253. * Black border
  6254. * @sample {highstock} stock/tooltip/general/
  6255. * Styled tooltip
  6256. * @sample {highmaps} maps/tooltip/background-border/
  6257. * Background and border demo
  6258. *
  6259. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6260. * @apioption tooltip.borderColor
  6261. */
  6262. /**
  6263. * A CSS class name to apply to the tooltip's container div,
  6264. * allowing unique CSS styling for each chart.
  6265. *
  6266. * @type {string}
  6267. * @apioption tooltip.className
  6268. */
  6269. /**
  6270. * Since 4.1, the crosshair definitions are moved to the Axis object
  6271. * in order for a better separation from the tooltip. See
  6272. * [xAxis.crosshair](#xAxis.crosshair).
  6273. *
  6274. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  6275. * Enable a crosshair for the x value
  6276. *
  6277. * @deprecated
  6278. *
  6279. * @type {*}
  6280. * @default true
  6281. * @apioption tooltip.crosshairs
  6282. */
  6283. /**
  6284. * Distance from point to tooltip in pixels.
  6285. *
  6286. * @type {number}
  6287. * @default 16
  6288. * @apioption tooltip.distance
  6289. */
  6290. /**
  6291. * Whether the tooltip should follow the mouse as it moves across
  6292. * columns, pie slices and other point types with an extent.
  6293. * By default it behaves this way for pie, polygon, map, sankey
  6294. * and wordcloud series by override in the `plotOptions`
  6295. * for those series types.
  6296. *
  6297. * Does not apply if [split](#tooltip.split) is `true`.
  6298. *
  6299. * For touch moves to behave the same way, [followTouchMove](
  6300. * #tooltip.followTouchMove) must be `true` also.
  6301. *
  6302. * @type {boolean}
  6303. * @default {highcharts} false
  6304. * @default {highstock} false
  6305. * @default {highmaps} true
  6306. * @since 3.0
  6307. * @apioption tooltip.followPointer
  6308. */
  6309. /**
  6310. * Whether the tooltip should update as the finger moves on a touch
  6311. * device. If this is `true` and [chart.panning](#chart.panning) is
  6312. * set,`followTouchMove` will take over one-finger touches, so the user
  6313. * needs to use two fingers for zooming and panning.
  6314. *
  6315. * Note the difference to [followPointer](#tooltip.followPointer) that
  6316. * only defines the _position_ of the tooltip. If `followPointer` is
  6317. * false in for example a column series, the tooltip will show above or
  6318. * below the column, but as `followTouchMove` is true, the tooltip will
  6319. * jump from column to column as the user swipes across the plot area.
  6320. *
  6321. * @type {boolean}
  6322. * @default {highcharts} true
  6323. * @default {highstock} true
  6324. * @default {highmaps} false
  6325. * @since 3.0.1
  6326. * @apioption tooltip.followTouchMove
  6327. */
  6328. /**
  6329. * Callback function to format the text of the tooltip from scratch. In
  6330. * case of single or [shared](#tooltip.shared) tooltips, a string should
  6331. * be returned. In case of [split](#tooltip.split) tooltips, it should
  6332. * return an array where the first item is the header, and subsequent
  6333. * items are mapped to the points. Return `false` to disable tooltip for
  6334. * a specific point on series.
  6335. *
  6336. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  6337. * the tooltip is parsed and converted to SVG, therefore this isn't a
  6338. * complete HTML renderer. The following HTML tags are supported: `b`,
  6339. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  6340. * attribute, but only text-related CSS, that is shared with SVG, is
  6341. * handled.
  6342. *
  6343. * The available data in the formatter differ a bit depending on whether
  6344. * the tooltip is shared or split, or belongs to a single point. In a
  6345. * shared/split tooltip, all properties except `x`, which is common for
  6346. * all points, are kept in an array, `this.points`.
  6347. *
  6348. * Available data are:
  6349. *
  6350. * - **this.percentage (not shared) /**
  6351. * **this.points[i].percentage (shared)**:
  6352. * Stacked series and pies only. The point's percentage of the total.
  6353. *
  6354. * - **this.point (not shared) / this.points[i].point (shared)**:
  6355. * The point object. The point name, if defined, is available through
  6356. * `this.point.name`.
  6357. *
  6358. * - **this.points**:
  6359. * In a shared tooltip, this is an array containing all other
  6360. * properties for each point.
  6361. *
  6362. * - **this.series (not shared) / this.points[i].series (shared)**:
  6363. * The series object. The series name is available through
  6364. * `this.series.name`.
  6365. *
  6366. * - **this.total (not shared) / this.points[i].total (shared)**:
  6367. * Stacked series only. The total value at this point's x value.
  6368. *
  6369. * - **this.x**:
  6370. * The x value. This property is the same regardless of the tooltip
  6371. * being shared or not.
  6372. *
  6373. * - **this.y (not shared) / this.points[i].y (shared)**:
  6374. * The y value.
  6375. *
  6376. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  6377. * Simple string formatting
  6378. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  6379. * Formatting with shared tooltip
  6380. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6381. * Formatting with split tooltip
  6382. * @sample highcharts/tooltip/formatter-conditional-default/
  6383. * Extending default formatter
  6384. * @sample {highstock} stock/tooltip/formatter/
  6385. * Formatting with shared tooltip
  6386. * @sample {highmaps} maps/tooltip/formatter/
  6387. * String formatting
  6388. *
  6389. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6390. * @apioption tooltip.formatter
  6391. */
  6392. /**
  6393. * Callback function to format the text of the tooltip for
  6394. * visible null points.
  6395. * Works analogously to [formatter](#tooltip.formatter).
  6396. *
  6397. * @sample highcharts/plotoptions/series-nullformat
  6398. * Format data label and tooltip for null point.
  6399. *
  6400. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6401. * @apioption tooltip.nullFormatter
  6402. */
  6403. /**
  6404. * The number of milliseconds to wait until the tooltip is hidden when
  6405. * mouse out from a point or chart.
  6406. *
  6407. * @type {number}
  6408. * @default 500
  6409. * @since 3.0
  6410. * @apioption tooltip.hideDelay
  6411. */
  6412. /**
  6413. * Whether to allow the tooltip to render outside the chart's SVG
  6414. * element box. By default (`false`), the tooltip is rendered within the
  6415. * chart's SVG element, which results in the tooltip being aligned
  6416. * inside the chart area. For small charts, this may result in clipping
  6417. * or overlapping. When `true`, a separate SVG element is created and
  6418. * overlaid on the page, allowing the tooltip to be aligned inside the
  6419. * page itself.
  6420. *
  6421. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  6422. * otherwise `false`.
  6423. *
  6424. * @sample highcharts/tooltip/outside
  6425. * Small charts with tooltips outside
  6426. *
  6427. * @type {boolean|undefined}
  6428. * @default undefined
  6429. * @since 6.1.1
  6430. * @apioption tooltip.outside
  6431. */
  6432. /**
  6433. * A callback function for formatting the HTML output for a single point
  6434. * in the tooltip. Like the `pointFormat` string, but with more
  6435. * flexibility.
  6436. *
  6437. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  6438. * @since 4.1.0
  6439. * @context Highcharts.Point
  6440. * @apioption tooltip.pointFormatter
  6441. */
  6442. /**
  6443. * A callback function to place the tooltip in a default position. The
  6444. * callback receives three parameters: `labelWidth`, `labelHeight` and
  6445. * `point`, where point contains values for `plotX` and `plotY` telling
  6446. * where the reference point is in the plot area. Add `chart.plotLeft`
  6447. * and `chart.plotTop` to get the full coordinates.
  6448. *
  6449. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  6450. * positioner is called for each of the boxes separately, including
  6451. * xAxis header. xAxis header is not a point, instead `point` argument
  6452. * contains info:
  6453. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  6454. *
  6455. *
  6456. * The return should be an object containing x and y values, for example
  6457. * `{ x: 100, y: 100 }`.
  6458. *
  6459. * @sample {highcharts} highcharts/tooltip/positioner/
  6460. * A fixed tooltip position
  6461. * @sample {highstock} stock/tooltip/positioner/
  6462. * A fixed tooltip position on top of the chart
  6463. * @sample {highmaps} maps/tooltip/positioner/
  6464. * A fixed tooltip position
  6465. * @sample {highstock} stock/tooltip/split-positioner/
  6466. * Split tooltip with fixed positions
  6467. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  6468. * Scrollable plot area combined with tooltip positioner
  6469. *
  6470. * @type {Highcharts.TooltipPositionerCallbackFunction}
  6471. * @since 2.2.4
  6472. * @apioption tooltip.positioner
  6473. */
  6474. /**
  6475. * The name of a symbol to use for the border around the tooltip. Can
  6476. * be one of: `"callout"`, `"circle"` or `"rect"`. When
  6477. * [tooltip.split](#tooltip.split)
  6478. * option is enabled, shape is applied to all boxes except header, which
  6479. * is controlled by
  6480. * [tooltip.headerShape](#tooltip.headerShape).
  6481. *
  6482. * Custom callbacks for symbol path generation can also be added to
  6483. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6484. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6485. *
  6486. * @type {Highcharts.TooltipShapeValue}
  6487. * @default callout
  6488. * @since 4.0
  6489. * @apioption tooltip.shape
  6490. */
  6491. /**
  6492. * The name of a symbol to use for the border around the tooltip
  6493. * header. Applies only when [tooltip.split](#tooltip.split) is
  6494. * enabled.
  6495. *
  6496. * Custom callbacks for symbol path generation can also be added to
  6497. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6498. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6499. *
  6500. * @see [tooltip.shape](#tooltip.shape)
  6501. *
  6502. * @sample {highstock} stock/tooltip/split-positioner/
  6503. * Different shapes for header and split boxes
  6504. *
  6505. * @type {Highcharts.TooltipShapeValue}
  6506. * @default callout
  6507. * @validvalue ["callout", "square"]
  6508. * @since 7.0
  6509. * @apioption tooltip.headerShape
  6510. */
  6511. /**
  6512. * When the tooltip is shared, the entire plot area will capture mouse
  6513. * movement or touch events. Tooltip texts for series types with ordered
  6514. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  6515. * This is recommended for single series charts and for tablet/mobile
  6516. * optimized charts.
  6517. *
  6518. * See also [tooltip.split](#tooltip.split), that is better suited for
  6519. * charts with many series, especially line-type series. The
  6520. * `tooltip.split` option takes precedence over `tooltip.shared`.
  6521. *
  6522. * @sample {highcharts} highcharts/tooltip/shared-false/
  6523. * False by default
  6524. * @sample {highcharts} highcharts/tooltip/shared-true/
  6525. * True
  6526. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  6527. * True with x axis crosshair
  6528. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  6529. * True with mixed series types
  6530. *
  6531. * @type {boolean}
  6532. * @default false
  6533. * @since 2.1
  6534. * @product highcharts highstock
  6535. * @apioption tooltip.shared
  6536. */
  6537. /**
  6538. * Split the tooltip into one label per series, with the header close
  6539. * to the axis. This is recommended over [shared](#tooltip.shared)
  6540. * tooltips for charts with multiple line series, generally making them
  6541. * easier to read. This option takes precedence over `tooltip.shared`.
  6542. *
  6543. * @productdesc {highstock} In Highcharts Stock, tooltips are split
  6544. * by default since v6.0.0. Stock charts typically contain
  6545. * multi-dimension points and multiple panes, making split tooltips
  6546. * the preferred layout over
  6547. * the previous `shared` tooltip.
  6548. *
  6549. * @sample highcharts/tooltip/split/
  6550. * Split tooltip
  6551. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6552. * Split tooltip and custom formatter callback
  6553. *
  6554. * @type {boolean}
  6555. * @default {highcharts} false
  6556. * @default {highstock} true
  6557. * @since 5.0.0
  6558. * @product highcharts highstock
  6559. * @apioption tooltip.split
  6560. */
  6561. /**
  6562. * Prevents the tooltip from switching or closing, when touched or
  6563. * pointed.
  6564. *
  6565. * @sample highcharts/tooltip/stickoncontact/
  6566. * Tooltip sticks on pointer contact
  6567. *
  6568. * @type {boolean}
  6569. * @since 8.0.1
  6570. * @apioption tooltip.stickOnContact
  6571. */
  6572. /**
  6573. * Use HTML to render the contents of the tooltip instead of SVG. Using
  6574. * HTML allows advanced formatting like tables and images in the
  6575. * tooltip. It is also recommended for rtl languages as it works around
  6576. * rtl bugs in early Firefox.
  6577. *
  6578. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  6579. * A table for value alignment
  6580. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  6581. * Full HTML tooltip
  6582. * @sample {highmaps} maps/tooltip/usehtml/
  6583. * Pure HTML tooltip
  6584. *
  6585. * @type {boolean}
  6586. * @default false
  6587. * @since 2.2
  6588. * @apioption tooltip.useHTML
  6589. */
  6590. /**
  6591. * How many decimals to show in each series' y value. This is
  6592. * overridable in each series' tooltip options object. The default is to
  6593. * preserve all decimals.
  6594. *
  6595. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6596. * Set decimals, prefix and suffix for the value
  6597. * @sample {highmaps} maps/tooltip/valuedecimals/
  6598. * Set decimals, prefix and suffix for the value
  6599. *
  6600. * @type {number}
  6601. * @since 2.2
  6602. * @apioption tooltip.valueDecimals
  6603. */
  6604. /**
  6605. * A string to prepend to each series' y value. Overridable in each
  6606. * series' tooltip options object.
  6607. *
  6608. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6609. * Set decimals, prefix and suffix for the value
  6610. * @sample {highmaps} maps/tooltip/valuedecimals/
  6611. * Set decimals, prefix and suffix for the value
  6612. *
  6613. * @type {string}
  6614. * @since 2.2
  6615. * @apioption tooltip.valuePrefix
  6616. */
  6617. /**
  6618. * A string to append to each series' y value. Overridable in each
  6619. * series' tooltip options object.
  6620. *
  6621. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6622. * Set decimals, prefix and suffix for the value
  6623. * @sample {highmaps} maps/tooltip/valuedecimals/
  6624. * Set decimals, prefix and suffix for the value
  6625. *
  6626. * @type {string}
  6627. * @since 2.2
  6628. * @apioption tooltip.valueSuffix
  6629. */
  6630. /**
  6631. * The format for the date in the tooltip header if the X axis is a
  6632. * datetime axis. The default is a best guess based on the smallest
  6633. * distance between points in the chart.
  6634. *
  6635. * @sample {highcharts} highcharts/tooltip/xdateformat/
  6636. * A different format
  6637. *
  6638. * @type {string}
  6639. * @product highcharts highstock gantt
  6640. * @apioption tooltip.xDateFormat
  6641. */
  6642. /**
  6643. * How many decimals to show for the `point.change` value when the
  6644. * `series.compare` option is set. This is overridable in each series'
  6645. * tooltip options object. The default is to preserve all decimals.
  6646. *
  6647. * @type {number}
  6648. * @since 1.0.1
  6649. * @product highstock
  6650. * @apioption tooltip.changeDecimals
  6651. */
  6652. /**
  6653. * Enable or disable the tooltip.
  6654. *
  6655. * @sample {highcharts} highcharts/tooltip/enabled/
  6656. * Disabled
  6657. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  6658. * Disable tooltip and show values on chart instead
  6659. */
  6660. enabled: true,
  6661. /**
  6662. * Enable or disable animation of the tooltip.
  6663. *
  6664. * @type {boolean}
  6665. * @default true
  6666. * @since 2.3.0
  6667. */
  6668. animation: svg,
  6669. /**
  6670. * The radius of the rounded border corners.
  6671. *
  6672. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6673. * 5px by default
  6674. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  6675. * Square borders
  6676. * @sample {highmaps} maps/tooltip/background-border/
  6677. * Background and border demo
  6678. */
  6679. borderRadius: 3,
  6680. /**
  6681. * For series on datetime axes, the date format in the tooltip's
  6682. * header will by default be guessed based on the closest data points.
  6683. * This member gives the default string representations used for
  6684. * each unit. For an overview of the replacement codes, see
  6685. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  6686. *
  6687. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  6688. *
  6689. * @type {Highcharts.Dictionary<string>}
  6690. * @product highcharts highstock gantt
  6691. */
  6692. dateTimeLabelFormats: {
  6693. /** @internal */
  6694. millisecond: '%A, %b %e, %H:%M:%S.%L',
  6695. /** @internal */
  6696. second: '%A, %b %e, %H:%M:%S',
  6697. /** @internal */
  6698. minute: '%A, %b %e, %H:%M',
  6699. /** @internal */
  6700. hour: '%A, %b %e, %H:%M',
  6701. /** @internal */
  6702. day: '%A, %b %e, %Y',
  6703. /** @internal */
  6704. week: 'Week from %A, %b %e, %Y',
  6705. /** @internal */
  6706. month: '%B %Y',
  6707. /** @internal */
  6708. year: '%Y'
  6709. },
  6710. /**
  6711. * A string to append to the tooltip format.
  6712. *
  6713. * @sample {highcharts} highcharts/tooltip/footerformat/
  6714. * A table for value alignment
  6715. * @sample {highmaps} maps/tooltip/format/
  6716. * Format demo
  6717. *
  6718. * @since 2.2
  6719. */
  6720. footerFormat: '',
  6721. /**
  6722. * Padding inside the tooltip, in pixels.
  6723. *
  6724. * @since 5.0.0
  6725. */
  6726. padding: 8,
  6727. /**
  6728. * Proximity snap for graphs or single points. It defaults to 10 for
  6729. * mouse-powered devices and 25 for touch devices.
  6730. *
  6731. * Note that in most cases the whole plot area captures the mouse
  6732. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  6733. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  6734. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  6735. * or [split](#tooltip.split).
  6736. *
  6737. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6738. * 10 px by default
  6739. * @sample {highcharts} highcharts/tooltip/snap-50/
  6740. * 50 px on graph
  6741. *
  6742. * @type {number}
  6743. * @default 10/25
  6744. * @since 1.2.0
  6745. * @product highcharts highstock
  6746. */
  6747. snap: isTouchDevice ? 25 : 10,
  6748. /**
  6749. * The HTML of the tooltip header line. Variables are enclosed by
  6750. * curly brackets. Available variables are `point.key`, `series.name`,
  6751. * `series.color` and other members from the `point` and `series`
  6752. * objects. The `point.key` variable contains the category name, x
  6753. * value or datetime string depending on the type of axis. For datetime
  6754. * axes, the `point.key` date format can be set using
  6755. * `tooltip.xDateFormat`.
  6756. *
  6757. * @sample {highcharts} highcharts/tooltip/footerformat/
  6758. * An HTML table in the tooltip
  6759. * @sample {highstock} highcharts/tooltip/footerformat/
  6760. * An HTML table in the tooltip
  6761. * @sample {highmaps} maps/tooltip/format/
  6762. * Format demo
  6763. *
  6764. * @type {string}
  6765. * @apioption tooltip.headerFormat
  6766. */
  6767. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  6768. /**
  6769. * The HTML of the null point's line in the tooltip. Works analogously
  6770. * to [pointFormat](#tooltip.pointFormat).
  6771. *
  6772. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  6773. * Format data label and tooltip for null point.
  6774. *
  6775. * @type {string}
  6776. * @apioption tooltip.nullFormat
  6777. */
  6778. /**
  6779. * The HTML of the point's line in the tooltip. Variables are enclosed
  6780. * by curly brackets. Available variables are `point.x`, `point.y`,
  6781. * `series.name` and `series.color` and other properties on the same
  6782. * form. Furthermore, `point.y` can be extended by the
  6783. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  6784. * also be overridden for each series, which makes it a good hook for
  6785. * displaying units.
  6786. *
  6787. * In styled mode, the dot is colored by a class name rather
  6788. * than the point color.
  6789. *
  6790. * @sample {highcharts} highcharts/tooltip/pointformat/
  6791. * A different point format with value suffix
  6792. * @sample {highmaps} maps/tooltip/format/
  6793. * Format demo
  6794. *
  6795. * @type {string}
  6796. * @since 2.2
  6797. * @apioption tooltip.pointFormat
  6798. */
  6799. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  6800. /**
  6801. * The background color or gradient for the tooltip.
  6802. *
  6803. * In styled mode, the stroke width is set in the
  6804. * `.highcharts-tooltip-box` class.
  6805. *
  6806. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  6807. * Yellowish background
  6808. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  6809. * Gradient
  6810. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6811. * Tooltip in styled mode
  6812. * @sample {highstock} stock/tooltip/general/
  6813. * Custom tooltip
  6814. * @sample {highstock} highcharts/css/tooltip-border-background/
  6815. * Tooltip in styled mode
  6816. * @sample {highmaps} maps/tooltip/background-border/
  6817. * Background and border demo
  6818. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6819. * Tooltip in styled mode
  6820. *
  6821. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6822. */
  6823. backgroundColor: color(palette.neutralColor3)
  6824. .setOpacity(0.85).get(),
  6825. /**
  6826. * The pixel width of the tooltip border.
  6827. *
  6828. * In styled mode, the stroke width is set in the
  6829. * `.highcharts-tooltip-box` class.
  6830. *
  6831. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6832. * 2px by default
  6833. * @sample {highcharts} highcharts/tooltip/borderwidth/
  6834. * No border (shadow only)
  6835. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6836. * Tooltip in styled mode
  6837. * @sample {highstock} stock/tooltip/general/
  6838. * Custom tooltip
  6839. * @sample {highstock} highcharts/css/tooltip-border-background/
  6840. * Tooltip in styled mode
  6841. * @sample {highmaps} maps/tooltip/background-border/
  6842. * Background and border demo
  6843. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6844. * Tooltip in styled mode
  6845. */
  6846. borderWidth: 1,
  6847. /**
  6848. * Whether to apply a drop shadow to the tooltip.
  6849. *
  6850. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6851. * True by default
  6852. * @sample {highcharts} highcharts/tooltip/shadow/
  6853. * False
  6854. * @sample {highmaps} maps/tooltip/positioner/
  6855. * Fixed tooltip position, border and shadow disabled
  6856. *
  6857. * @type {boolean|Highcharts.ShadowOptionsObject}
  6858. */
  6859. shadow: true,
  6860. /**
  6861. * CSS styles for the tooltip. The tooltip can also be styled through
  6862. * the CSS class `.highcharts-tooltip`.
  6863. *
  6864. * Note that the default `pointerEvents` style makes the tooltip ignore
  6865. * mouse events, so in order to use clickable tooltips, this value must
  6866. * be set to `auto`.
  6867. *
  6868. * @sample {highcharts} highcharts/tooltip/style/
  6869. * Greater padding, bold text
  6870. *
  6871. * @type {Highcharts.CSSObject}
  6872. */
  6873. style: {
  6874. /** @internal */
  6875. color: palette.neutralColor80,
  6876. /** @internal */
  6877. cursor: 'default',
  6878. /** @internal */
  6879. fontSize: '12px',
  6880. /** @internal */
  6881. whiteSpace: 'nowrap'
  6882. }
  6883. },
  6884. /**
  6885. * Highchart by default puts a credits label in the lower right corner
  6886. * of the chart. This can be changed using these options.
  6887. */
  6888. credits: {
  6889. /**
  6890. * Credits for map source to be concatenated with conventional credit
  6891. * text. By default this is a format string that collects copyright
  6892. * information from the map if available.
  6893. *
  6894. * @see [mapTextFull](#credits.mapTextFull)
  6895. * @see [text](#credits.text)
  6896. *
  6897. * @type {string}
  6898. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  6899. * @since 4.2.2
  6900. * @product highmaps
  6901. * @apioption credits.mapText
  6902. */
  6903. /**
  6904. * Detailed credits for map source to be displayed on hover of credits
  6905. * text. By default this is a format string that collects copyright
  6906. * information from the map if available.
  6907. *
  6908. * @see [mapText](#credits.mapText)
  6909. * @see [text](#credits.text)
  6910. *
  6911. * @type {string}
  6912. * @default {geojson.copyright}
  6913. * @since 4.2.2
  6914. * @product highmaps
  6915. * @apioption credits.mapTextFull
  6916. */
  6917. /**
  6918. * Whether to show the credits text.
  6919. *
  6920. * @sample {highcharts} highcharts/credits/enabled-false/
  6921. * Credits disabled
  6922. * @sample {highstock} stock/credits/enabled/
  6923. * Credits disabled
  6924. * @sample {highmaps} maps/credits/enabled-false/
  6925. * Credits disabled
  6926. */
  6927. enabled: true,
  6928. /**
  6929. * The URL for the credits label.
  6930. *
  6931. * @sample {highcharts} highcharts/credits/href/
  6932. * Custom URL and text
  6933. * @sample {highmaps} maps/credits/customized/
  6934. * Custom URL and text
  6935. */
  6936. href: 'https://www.highcharts.com?credits',
  6937. /**
  6938. * Position configuration for the credits label.
  6939. *
  6940. * @sample {highcharts} highcharts/credits/position-left/
  6941. * Left aligned
  6942. * @sample {highcharts} highcharts/credits/position-left/
  6943. * Left aligned
  6944. * @sample {highmaps} maps/credits/customized/
  6945. * Left aligned
  6946. * @sample {highmaps} maps/credits/customized/
  6947. * Left aligned
  6948. *
  6949. * @type {Highcharts.AlignObject}
  6950. * @since 2.1
  6951. */
  6952. position: {
  6953. /** @internal */
  6954. align: 'right',
  6955. /** @internal */
  6956. x: -10,
  6957. /** @internal */
  6958. verticalAlign: 'bottom',
  6959. /** @internal */
  6960. y: -5
  6961. },
  6962. /**
  6963. * CSS styles for the credits label.
  6964. *
  6965. * @see In styled mode, credits styles can be set with the
  6966. * `.highcharts-credits` class.
  6967. *
  6968. * @type {Highcharts.CSSObject}
  6969. */
  6970. style: {
  6971. /** @internal */
  6972. cursor: 'pointer',
  6973. /** @internal */
  6974. color: palette.neutralColor40,
  6975. /** @internal */
  6976. fontSize: '9px'
  6977. },
  6978. /**
  6979. * The text for the credits label.
  6980. *
  6981. * @productdesc {highmaps}
  6982. * If a map is loaded as GeoJSON, the text defaults to
  6983. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  6984. * `Highcharts.com`.
  6985. *
  6986. * @sample {highcharts} highcharts/credits/href/
  6987. * Custom URL and text
  6988. * @sample {highmaps} maps/credits/customized/
  6989. * Custom URL and text
  6990. */
  6991. text: 'Highcharts.com'
  6992. }
  6993. };
  6994. /* eslint-disable spaced-comment */
  6995. defaultOptions.chart.styledMode = false;
  6996. '';
  6997. var defaultTime = new Time(merge(defaultOptions.global,
  6998. defaultOptions.time));
  6999. /**
  7000. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  7001. * for outside modules wasn't enough because the setOptions method created a new
  7002. * object.
  7003. *
  7004. * @function Highcharts.getOptions
  7005. *
  7006. * @return {Highcharts.Options}
  7007. */
  7008. function getOptions() {
  7009. return defaultOptions;
  7010. }
  7011. /**
  7012. * Merge the default options with custom options and return the new options
  7013. * structure. Commonly used for defining reusable templates.
  7014. *
  7015. * @sample highcharts/global/useutc-false Setting a global option
  7016. * @sample highcharts/members/setoptions Applying a global theme
  7017. *
  7018. * @function Highcharts.setOptions
  7019. *
  7020. * @param {Highcharts.Options} options
  7021. * The new custom chart options.
  7022. *
  7023. * @return {Highcharts.Options}
  7024. * Updated options.
  7025. */
  7026. function setOptions(options) {
  7027. // Copy in the default options
  7028. merge(true, defaultOptions, options);
  7029. // Update the time object
  7030. if (options.time || options.global) {
  7031. if (H.time) {
  7032. H.time.update(merge(defaultOptions.global, defaultOptions.time, options.global, options.time));
  7033. }
  7034. else {
  7035. /**
  7036. * Global `Time` object with default options. Since v6.0.5, time
  7037. * settings can be applied individually for each chart. If no
  7038. * individual settings apply, this `Time` object is shared by all
  7039. * instances.
  7040. *
  7041. * @name Highcharts.time
  7042. * @type {Highcharts.Time}
  7043. */
  7044. H.time = defaultTime;
  7045. }
  7046. }
  7047. return defaultOptions;
  7048. }
  7049. var optionsModule = {
  7050. defaultOptions: defaultOptions,
  7051. defaultTime: defaultTime,
  7052. getOptions: getOptions,
  7053. setOptions: setOptions
  7054. };
  7055. return optionsModule;
  7056. });
  7057. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  7058. /* *
  7059. *
  7060. * (c) 2010-2021 Torstein Honsi
  7061. *
  7062. * License: www.highcharts.com/license
  7063. *
  7064. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7065. *
  7066. * */
  7067. var color = Color.parse;
  7068. var win = H.win;
  7069. var isNumber = U.isNumber,
  7070. objectEach = U.objectEach;
  7071. /* eslint-disable no-invalid-this, valid-jsdoc */
  7072. /**
  7073. * An animator object used internally. One instance applies to one property
  7074. * (attribute or style prop) on one element. Animation is always initiated
  7075. * through {@link SVGElement#animate}.
  7076. *
  7077. * @example
  7078. * let rect = renderer.rect(0, 0, 10, 10).add();
  7079. * rect.animate({ width: 100 });
  7080. *
  7081. * @private
  7082. * @class
  7083. * @name Highcharts.Fx
  7084. */
  7085. var Fx = /** @class */ (function () {
  7086. /* *
  7087. *
  7088. * Constructors
  7089. *
  7090. * */
  7091. /**
  7092. *
  7093. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  7094. * The element to animate.
  7095. *
  7096. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  7097. * Animation options.
  7098. *
  7099. * @param {string} prop
  7100. * The single attribute or CSS property to animate.
  7101. */
  7102. function Fx(elem, options, prop) {
  7103. this.pos = NaN;
  7104. this.options = options;
  7105. this.elem = elem;
  7106. this.prop = prop;
  7107. }
  7108. /* *
  7109. *
  7110. * Functions
  7111. *
  7112. * */
  7113. /**
  7114. * Set the current step of a path definition on SVGElement.
  7115. *
  7116. * @function Highcharts.Fx#dSetter
  7117. *
  7118. * @return {void}
  7119. */
  7120. Fx.prototype.dSetter = function () {
  7121. var paths = this.paths,
  7122. start = paths && paths[0],
  7123. end = paths && paths[1],
  7124. now = this.now || 0;
  7125. var path = [];
  7126. // Land on the final path without adjustment points appended in the ends
  7127. if (now === 1 || !start || !end) {
  7128. path = this.toD || [];
  7129. }
  7130. else if (start.length === end.length && now < 1) {
  7131. for (var i = 0; i < end.length; i++) {
  7132. // Tween between the start segment and the end segment. Start
  7133. // with a copy of the end segment and tween the appropriate
  7134. // numerics
  7135. var startSeg = start[i];
  7136. var endSeg = end[i];
  7137. var tweenSeg = [];
  7138. for (var j = 0; j < endSeg.length; j++) {
  7139. var startItem = startSeg[j];
  7140. var endItem = endSeg[j];
  7141. // Tween numbers
  7142. if (isNumber(startItem) &&
  7143. isNumber(endItem) &&
  7144. // Arc boolean flags
  7145. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  7146. tweenSeg[j] = startItem + now * (endItem - startItem);
  7147. // Strings, take directly from the end segment
  7148. }
  7149. else {
  7150. tweenSeg[j] = endItem;
  7151. }
  7152. }
  7153. path.push(tweenSeg);
  7154. }
  7155. // If animation is finished or length not matching, land on right value
  7156. }
  7157. else {
  7158. path = end;
  7159. }
  7160. this.elem.attr('d', path, void 0, true);
  7161. };
  7162. /**
  7163. * Update the element with the current animation step.
  7164. *
  7165. * @function Highcharts.Fx#update
  7166. *
  7167. * @return {void}
  7168. */
  7169. Fx.prototype.update = function () {
  7170. var elem = this.elem,
  7171. prop = this.prop, // if destroyed, it is null
  7172. now = this.now,
  7173. step = this.options.step;
  7174. // Animation setter defined from outside
  7175. if (this[prop + 'Setter']) {
  7176. this[prop + 'Setter']();
  7177. // Other animations on SVGElement
  7178. }
  7179. else if (elem.attr) {
  7180. if (elem.element) {
  7181. elem.attr(prop, now, null, true);
  7182. }
  7183. // HTML styles, raw HTML content like container size
  7184. }
  7185. else {
  7186. elem.style[prop] = now + this.unit;
  7187. }
  7188. if (step) {
  7189. step.call(elem, now, this);
  7190. }
  7191. };
  7192. /**
  7193. * Run an animation.
  7194. *
  7195. * @function Highcharts.Fx#run
  7196. *
  7197. * @param {number} from
  7198. * The current value, value to start from.
  7199. *
  7200. * @param {number} to
  7201. * The end value, value to land on.
  7202. *
  7203. * @param {string} unit
  7204. * The property unit, for example `px`.
  7205. *
  7206. * @return {void}
  7207. */
  7208. Fx.prototype.run = function (from, to, unit) {
  7209. var self = this,
  7210. options = self.options,
  7211. timer = function (gotoEnd) {
  7212. return timer.stopped ? false : self.step(gotoEnd);
  7213. }, requestAnimationFrame = win.requestAnimationFrame ||
  7214. function (step) {
  7215. setTimeout(step, 13);
  7216. }, step = function () {
  7217. for (var i = 0; i < Fx.timers.length; i++) {
  7218. if (!Fx.timers[i]()) {
  7219. Fx.timers.splice(i--, 1);
  7220. }
  7221. }
  7222. if (Fx.timers.length) {
  7223. requestAnimationFrame(step);
  7224. }
  7225. };
  7226. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  7227. delete options.curAnim[this.prop];
  7228. if (options.complete && Object.keys(options.curAnim).length === 0) {
  7229. options.complete.call(this.elem);
  7230. }
  7231. }
  7232. else { // #7166
  7233. this.startTime = +new Date();
  7234. this.start = from;
  7235. this.end = to;
  7236. this.unit = unit;
  7237. this.now = this.start;
  7238. this.pos = 0;
  7239. timer.elem = this.elem;
  7240. timer.prop = this.prop;
  7241. if (timer() && Fx.timers.push(timer) === 1) {
  7242. requestAnimationFrame(step);
  7243. }
  7244. }
  7245. };
  7246. /**
  7247. * Run a single step in the animation.
  7248. *
  7249. * @function Highcharts.Fx#step
  7250. *
  7251. * @param {boolean} [gotoEnd]
  7252. * Whether to go to the endpoint of the animation after abort.
  7253. *
  7254. * @return {boolean}
  7255. * Returns `true` if animation continues.
  7256. */
  7257. Fx.prototype.step = function (gotoEnd) {
  7258. var t = +new Date(),
  7259. options = this.options,
  7260. elem = this.elem,
  7261. complete = options.complete,
  7262. duration = options.duration,
  7263. curAnim = options.curAnim;
  7264. var ret,
  7265. done;
  7266. if (elem.attr && !elem.element) { // #2616, element is destroyed
  7267. ret = false;
  7268. }
  7269. else if (gotoEnd || t >= duration + this.startTime) {
  7270. this.now = this.end;
  7271. this.pos = 1;
  7272. this.update();
  7273. curAnim[this.prop] = true;
  7274. done = true;
  7275. objectEach(curAnim, function (val) {
  7276. if (val !== true) {
  7277. done = false;
  7278. }
  7279. });
  7280. if (done && complete) {
  7281. complete.call(elem);
  7282. }
  7283. ret = false;
  7284. }
  7285. else {
  7286. this.pos = options.easing((t - this.startTime) / duration);
  7287. this.now = this.start + ((this.end - this.start) * this.pos);
  7288. this.update();
  7289. ret = true;
  7290. }
  7291. return ret;
  7292. };
  7293. /**
  7294. * Prepare start and end values so that the path can be animated one to one.
  7295. *
  7296. * @function Highcharts.Fx#initPath
  7297. *
  7298. * @param {Highcharts.SVGElement} elem
  7299. * The SVGElement item.
  7300. *
  7301. * @param {Highcharts.SVGPathArray|undefined} fromD
  7302. * Starting path definition.
  7303. *
  7304. * @param {Highcharts.SVGPathArray} toD
  7305. * Ending path definition.
  7306. *
  7307. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  7308. * An array containing start and end paths in array form so that
  7309. * they can be animated in parallel.
  7310. */
  7311. Fx.prototype.initPath = function (elem, fromD, toD) {
  7312. var startX = elem.startX,
  7313. endX = elem.endX,
  7314. end = toD.slice(), // copy
  7315. isArea = elem.isArea,
  7316. positionFactor = isArea ? 2 : 1;
  7317. var shift,
  7318. fullLength,
  7319. i,
  7320. reverse,
  7321. start = fromD && fromD.slice(); // copy
  7322. if (!start) {
  7323. return [end,
  7324. end];
  7325. }
  7326. /**
  7327. * If shifting points, prepend a dummy point to the end path.
  7328. * @private
  7329. * @param {Highcharts.SVGPathArray} arr - array
  7330. * @param {Highcharts.SVGPathArray} other - array
  7331. * @return {void}
  7332. */
  7333. function prepend(arr, other) {
  7334. while (arr.length < fullLength) {
  7335. // Move to, line to or curve to?
  7336. var moveSegment = arr[0],
  7337. otherSegment = other[fullLength - arr.length];
  7338. if (otherSegment && moveSegment[0] === 'M') {
  7339. if (otherSegment[0] === 'C') {
  7340. arr[0] = [
  7341. 'C',
  7342. moveSegment[1],
  7343. moveSegment[2],
  7344. moveSegment[1],
  7345. moveSegment[2],
  7346. moveSegment[1],
  7347. moveSegment[2]
  7348. ];
  7349. }
  7350. else {
  7351. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  7352. }
  7353. }
  7354. // Prepend a copy of the first point
  7355. arr.unshift(moveSegment);
  7356. // For areas, the bottom path goes back again to the left, so we
  7357. // need to append a copy of the last point.
  7358. if (isArea) {
  7359. var z = arr.pop();
  7360. arr.push(arr[arr.length - 1], z); // append point and the Z
  7361. }
  7362. }
  7363. }
  7364. /**
  7365. * Copy and append last point until the length matches the end length.
  7366. * @private
  7367. * @param {Highcharts.SVGPathArray} arr - array
  7368. * @param {Highcharts.SVGPathArray} other - array
  7369. * @return {void}
  7370. */
  7371. function append(arr, other) {
  7372. while (arr.length < fullLength) {
  7373. // Pull out the slice that is going to be appended or inserted.
  7374. // In a line graph, the positionFactor is 1, and the last point
  7375. // is sliced out. In an area graph, the positionFactor is 2,
  7376. // causing the middle two points to be sliced out, since an area
  7377. // path starts at left, follows the upper path then turns and
  7378. // follows the bottom back.
  7379. var segmentToAdd = arr[Math.floor(arr.length / positionFactor) - 1].slice();
  7380. // Disable the first control point of curve segments
  7381. if (segmentToAdd[0] === 'C') {
  7382. segmentToAdd[1] = segmentToAdd[5];
  7383. segmentToAdd[2] = segmentToAdd[6];
  7384. }
  7385. if (!isArea) {
  7386. arr.push(segmentToAdd);
  7387. }
  7388. else {
  7389. var lowerSegmentToAdd = arr[Math.floor(arr.length / positionFactor)].slice();
  7390. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  7391. }
  7392. }
  7393. }
  7394. // For sideways animation, find out how much we need to shift to get the
  7395. // start path Xs to match the end path Xs.
  7396. if (startX && endX && endX.length) {
  7397. for (i = 0; i < startX.length; i++) {
  7398. // Moving left, new points coming in on right
  7399. if (startX[i] === endX[0]) {
  7400. shift = i;
  7401. break;
  7402. // Moving right
  7403. }
  7404. else if (startX[0] ===
  7405. endX[endX.length - startX.length + i]) {
  7406. shift = i;
  7407. reverse = true;
  7408. break;
  7409. // Fixed from the right side, "scaling" left
  7410. }
  7411. else if (startX[startX.length - 1] ===
  7412. endX[endX.length - startX.length + i]) {
  7413. shift = startX.length - i;
  7414. break;
  7415. }
  7416. }
  7417. if (typeof shift === 'undefined') {
  7418. start = [];
  7419. }
  7420. }
  7421. if (start.length && isNumber(shift)) {
  7422. // The common target length for the start and end array, where both
  7423. // arrays are padded in opposite ends
  7424. fullLength = end.length + shift * positionFactor;
  7425. if (!reverse) {
  7426. prepend(end, start);
  7427. append(start, end);
  7428. }
  7429. else {
  7430. prepend(start, end);
  7431. append(end, start);
  7432. }
  7433. }
  7434. return [start, end];
  7435. };
  7436. /**
  7437. * Handle animation of the color attributes directly.
  7438. *
  7439. * @function Highcharts.Fx#fillSetter
  7440. *
  7441. * @return {void}
  7442. */
  7443. Fx.prototype.fillSetter = function () {
  7444. Fx.prototype.strokeSetter.apply(this, arguments);
  7445. };
  7446. /**
  7447. * Handle animation of the color attributes directly.
  7448. *
  7449. * @function Highcharts.Fx#strokeSetter
  7450. *
  7451. * @return {void}
  7452. */
  7453. Fx.prototype.strokeSetter = function () {
  7454. this.elem.attr(this.prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  7455. };
  7456. /* *
  7457. *
  7458. * Static properties
  7459. *
  7460. * */
  7461. Fx.timers = [];
  7462. return Fx;
  7463. }());
  7464. /* *
  7465. *
  7466. * Default Export
  7467. *
  7468. * */
  7469. return Fx;
  7470. });
  7471. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Utilities.js']], function (Fx, U) {
  7472. /* *
  7473. *
  7474. * (c) 2010-2021 Torstein Honsi
  7475. *
  7476. * License: www.highcharts.com/license
  7477. *
  7478. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7479. *
  7480. * */
  7481. var defined = U.defined,
  7482. getStyle = U.getStyle,
  7483. isArray = U.isArray,
  7484. isNumber = U.isNumber,
  7485. isObject = U.isObject,
  7486. merge = U.merge,
  7487. objectEach = U.objectEach,
  7488. pick = U.pick;
  7489. /**
  7490. * Set the global animation to either a given value, or fall back to the given
  7491. * chart's animation option.
  7492. *
  7493. * @function Highcharts.setAnimation
  7494. *
  7495. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  7496. * The animation object.
  7497. *
  7498. * @param {Highcharts.Chart} chart
  7499. * The chart instance.
  7500. *
  7501. * @todo
  7502. * This function always relates to a chart, and sets a property on the renderer,
  7503. * so it should be moved to the SVGRenderer.
  7504. */
  7505. function setAnimation(animation, chart) {
  7506. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  7507. }
  7508. /**
  7509. * Get the animation in object form, where a disabled animation is always
  7510. * returned as `{ duration: 0 }`.
  7511. *
  7512. * @function Highcharts.animObject
  7513. *
  7514. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  7515. * An animation setting. Can be an object with duration, complete and
  7516. * easing properties, or a boolean to enable or disable.
  7517. *
  7518. * @return {Highcharts.AnimationOptionsObject}
  7519. * An object with at least a duration property.
  7520. */
  7521. function animObject(animation) {
  7522. return isObject(animation) ?
  7523. merge({ duration: 500, defer: 0 }, animation) :
  7524. { duration: animation ? 500 : 0, defer: 0 };
  7525. }
  7526. /**
  7527. * Get the defer as a number value from series animation options.
  7528. *
  7529. * @function Highcharts.getDeferredAnimation
  7530. *
  7531. * @param {Highcharts.Chart} chart
  7532. * The chart instance.
  7533. *
  7534. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  7535. * An animation setting. Can be an object with duration, complete and
  7536. * easing properties, or a boolean to enable or disable.
  7537. *
  7538. * @param {Highcharts.Series} [series]
  7539. * Series to defer animation.
  7540. *
  7541. * @return {number}
  7542. * The numeric value.
  7543. */
  7544. function getDeferredAnimation(chart, animation, series) {
  7545. var labelAnimation = animObject(animation);
  7546. var s = series ? [series] : chart.series;
  7547. var defer = 0;
  7548. var duration = 0;
  7549. s.forEach(function (series) {
  7550. var seriesAnim = animObject(series.options.animation);
  7551. defer = animation && defined(animation.defer) ?
  7552. labelAnimation.defer :
  7553. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  7554. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  7555. });
  7556. // Disable defer for exporting
  7557. if (chart.renderer.forExport) {
  7558. defer = 0;
  7559. }
  7560. var anim = {
  7561. defer: Math.max(0,
  7562. defer - duration),
  7563. duration: Math.min(defer,
  7564. duration)
  7565. };
  7566. return anim;
  7567. }
  7568. /**
  7569. * The global animate method, which uses Fx to create individual animators.
  7570. *
  7571. * @function Highcharts.animate
  7572. *
  7573. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  7574. * The element to animate.
  7575. *
  7576. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  7577. * An object containing key-value pairs of the properties to animate.
  7578. * Supports numeric as pixel-based CSS properties for HTML objects and
  7579. * attributes for SVGElements.
  7580. *
  7581. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  7582. * Animation options.
  7583. *
  7584. * @return {void}
  7585. */
  7586. function animate(el, params, opt) {
  7587. var start,
  7588. unit = '',
  7589. end,
  7590. fx,
  7591. args;
  7592. if (!isObject(opt)) { // Number or undefined/null
  7593. args = arguments;
  7594. opt = {
  7595. duration: args[2],
  7596. easing: args[3],
  7597. complete: args[4]
  7598. };
  7599. }
  7600. if (!isNumber(opt.duration)) {
  7601. opt.duration = 400;
  7602. }
  7603. opt.easing = typeof opt.easing === 'function' ?
  7604. opt.easing :
  7605. (Math[opt.easing] || Math.easeInOutSine);
  7606. opt.curAnim = merge(params);
  7607. objectEach(params, function (val, prop) {
  7608. // Stop current running animation of this property
  7609. stop(el, prop);
  7610. fx = new Fx(el, opt, prop);
  7611. end = void 0;
  7612. if (prop === 'd' && isArray(params.d)) {
  7613. fx.paths = fx.initPath(el, el.pathArray, params.d);
  7614. fx.toD = params.d;
  7615. start = 0;
  7616. end = 1;
  7617. }
  7618. else if (el.attr) {
  7619. start = el.attr(prop);
  7620. }
  7621. else {
  7622. start = parseFloat(getStyle(el, prop)) || 0;
  7623. if (prop !== 'opacity') {
  7624. unit = 'px';
  7625. }
  7626. }
  7627. if (!end) {
  7628. end = val;
  7629. }
  7630. if (typeof end === 'string' && end.match('px')) {
  7631. end = end.replace(/px/g, ''); // #4351
  7632. }
  7633. fx.run(start, end, unit);
  7634. });
  7635. }
  7636. /**
  7637. * Stop running animation.
  7638. *
  7639. * @function Highcharts.stop
  7640. *
  7641. * @param {Highcharts.SVGElement} el
  7642. * The SVGElement to stop animation on.
  7643. *
  7644. * @param {string} [prop]
  7645. * The property to stop animating. If given, the stop method will stop a
  7646. * single property from animating, while others continue.
  7647. *
  7648. * @return {void}
  7649. *
  7650. * @todo
  7651. * A possible extension to this would be to stop a single property, when
  7652. * we want to continue animating others. Then assign the prop to the timer
  7653. * in the Fx.run method, and check for the prop here. This would be an
  7654. * improvement in all cases where we stop the animation from .attr. Instead of
  7655. * stopping everything, we can just stop the actual attributes we're setting.
  7656. */
  7657. function stop(el, prop) {
  7658. var i = Fx.timers.length;
  7659. // Remove timers related to this element (#4519)
  7660. while (i--) {
  7661. if (Fx.timers[i].elem === el && (!prop || prop === Fx.timers[i].prop)) {
  7662. Fx.timers[i].stopped = true; // #4667
  7663. }
  7664. }
  7665. }
  7666. var animationExports = {
  7667. animate: animate,
  7668. animObject: animObject,
  7669. getDeferredAnimation: getDeferredAnimation,
  7670. setAnimation: setAnimation,
  7671. stop: stop
  7672. };
  7673. return animationExports;
  7674. });
  7675. _registerModule(_modules, 'Core/Renderer/HTML/AST.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7676. /* *
  7677. *
  7678. * (c) 2010-2020 Torstein Honsi
  7679. *
  7680. * License: www.highcharts.com/license
  7681. *
  7682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7683. *
  7684. * */
  7685. var SVG_NS = H.SVG_NS;
  7686. var attr = U.attr,
  7687. createElement = U.createElement,
  7688. discardElement = U.discardElement,
  7689. error = U.error,
  7690. isString = U.isString,
  7691. objectEach = U.objectEach,
  7692. splat = U.splat;
  7693. /**
  7694. * Serialized form of an SVG/HTML definition, including children.
  7695. *
  7696. * @interface Highcharts.ASTNode
  7697. */ /**
  7698. * @name Highcharts.ASTNode#attributes
  7699. * @type {Highcharts.SVGAttributes|undefined}
  7700. */ /**
  7701. * @name Highcharts.ASTNode#children
  7702. * @type {Array<Highcharts.ASTNode>|undefined}
  7703. */ /**
  7704. * @name Highcharts.ASTNode#tagName
  7705. * @type {string|undefined}
  7706. */ /**
  7707. * @name Highcharts.ASTNode#textContent
  7708. * @type {string|undefined}
  7709. */
  7710. ''; // detach doclets above
  7711. // In IE8, DOMParser is undefined. IE9 and PhantomJS are only able to parse XML.
  7712. var hasValidDOMParser = false;
  7713. try {
  7714. hasValidDOMParser = Boolean(new DOMParser().parseFromString('', 'text/html'));
  7715. }
  7716. catch (e) { } // eslint-disable-line no-empty
  7717. /**
  7718. * The AST class represents an abstract syntax tree of HTML or SVG content. It
  7719. * can take HTML as an argument, parse it, optionally transform it to SVG, then
  7720. * perform sanitation before inserting it into the DOM.
  7721. *
  7722. * @class
  7723. * @name Highcharts.AST
  7724. * @param {string|Highcharts.ASTNode[]} source
  7725. * Either an HTML string or an ASTNode list
  7726. * to populate the tree
  7727. */
  7728. var AST = /** @class */ (function () {
  7729. // Construct an AST from HTML markup, or wrap an array of existing AST nodes
  7730. function AST(source) {
  7731. this.nodes = typeof source === 'string' ?
  7732. this.parseMarkup(source) : source;
  7733. }
  7734. /**
  7735. * Filter an object of SVG or HTML attributes against the allow list.
  7736. *
  7737. * @static
  7738. *
  7739. * @function Highcharts.AST#filterUserAttributes
  7740. *
  7741. * @param {Highcharts.SVGAttributes} attributes The attributes to filter
  7742. *
  7743. * @return {Highcharts.SVGAttributes}
  7744. * The filtered attributes
  7745. */
  7746. AST.filterUserAttributes = function (attributes) {
  7747. objectEach(attributes, function (val, key) {
  7748. var valid = true;
  7749. if (AST.allowedAttributes.indexOf(key) === -1) {
  7750. valid = false;
  7751. }
  7752. if (['background', 'dynsrc', 'href', 'lowsrc', 'src']
  7753. .indexOf(key) !== -1) {
  7754. valid = isString(val) && AST.allowedReferences.some(function (ref) { return val.indexOf(ref) === 0; });
  7755. }
  7756. if (!valid) {
  7757. error("Highcharts warning: Invalid attribute '" + key + "' in config");
  7758. delete attributes[key];
  7759. }
  7760. });
  7761. return attributes;
  7762. };
  7763. /**
  7764. * Utility function to set html content for an element by passing in a
  7765. * markup string. The markup is safely parsed by the AST class to avoid
  7766. * XSS vulnerabilities. This function should be used instead of setting
  7767. * `innerHTML` in all cases where the content is not fully trusted.
  7768. *
  7769. * @static
  7770. *
  7771. * @function Highcharts.AST#setElementHTML
  7772. *
  7773. * @param {SVGDOMElement|HTMLDOMElement} el The node to set content of
  7774. * @param {string} html The markup string
  7775. */
  7776. AST.setElementHTML = function (el, html) {
  7777. el.innerHTML = ''; // Clear previous
  7778. if (html) {
  7779. var ast = new AST(html);
  7780. ast.addToDOM(el);
  7781. }
  7782. };
  7783. /**
  7784. * Add the tree defined as a hierarchical JS structure to the DOM
  7785. *
  7786. * @function Highcharts.AST#addToDOM
  7787. *
  7788. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} parent
  7789. * The node where it should be added
  7790. *
  7791. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement}
  7792. * The inserted node.
  7793. */
  7794. AST.prototype.addToDOM = function (parent) {
  7795. /**
  7796. * @private
  7797. * @param {Highcharts.ASTNode} subtree - HTML/SVG definition
  7798. * @param {Element} [subParent] - parent node
  7799. * @return {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} The inserted node.
  7800. */
  7801. function recurse(subtree, subParent) {
  7802. var ret;
  7803. splat(subtree).forEach(function (item) {
  7804. var tagName = item.tagName;
  7805. var textNode = item.textContent ?
  7806. H.doc.createTextNode(item.textContent) :
  7807. void 0;
  7808. var node;
  7809. if (tagName) {
  7810. if (tagName === '#text') {
  7811. node = textNode;
  7812. }
  7813. else if (AST.allowedTags.indexOf(tagName) !== -1) {
  7814. var NS = tagName === 'svg' ?
  7815. SVG_NS :
  7816. (subParent.namespaceURI || SVG_NS);
  7817. var element = H.doc.createElementNS(NS,
  7818. tagName);
  7819. var attributes_1 = item.attributes || {};
  7820. // Apply attributes from root of AST node, legacy from
  7821. // from before TextBuilder
  7822. objectEach(item, function (val, key) {
  7823. if (key !== 'tagName' &&
  7824. key !== 'attributes' &&
  7825. key !== 'children' &&
  7826. key !== 'textContent') {
  7827. attributes_1[key] = val;
  7828. }
  7829. });
  7830. attr(element, AST.filterUserAttributes(attributes_1));
  7831. // Add text content
  7832. if (textNode) {
  7833. element.appendChild(textNode);
  7834. }
  7835. // Recurse
  7836. recurse(item.children || [], element);
  7837. node = element;
  7838. }
  7839. else {
  7840. error("Highcharts warning: Invalid tagName '" + tagName + "' in config");
  7841. }
  7842. }
  7843. // Add to the tree
  7844. if (node) {
  7845. subParent.appendChild(node);
  7846. }
  7847. ret = node;
  7848. });
  7849. // Return last node added (on top level it's the only one)
  7850. return ret;
  7851. }
  7852. return recurse(this.nodes, parent);
  7853. };
  7854. /**
  7855. * Parse HTML/SVG markup into AST Node objects. Used internally from the
  7856. * constructor.
  7857. *
  7858. * @private
  7859. *
  7860. * @function Highcharts.AST#getNodesFromMarkup
  7861. *
  7862. * @param {string} markup The markup string.
  7863. *
  7864. * @return {Array<Highcharts.ASTNode>} The parsed nodes.
  7865. */
  7866. AST.prototype.parseMarkup = function (markup) {
  7867. var nodes = [];
  7868. var doc;
  7869. var body;
  7870. if (hasValidDOMParser) {
  7871. doc = new DOMParser().parseFromString(markup, 'text/html');
  7872. }
  7873. else {
  7874. body = createElement('div');
  7875. body.innerHTML = markup;
  7876. doc = { body: body };
  7877. }
  7878. var appendChildNodes = function (node,
  7879. addTo) {
  7880. var tagName = node.nodeName.toLowerCase();
  7881. // Add allowed tags
  7882. var astNode = {
  7883. tagName: tagName
  7884. };
  7885. if (tagName === '#text') {
  7886. var textContent = node.textContent || '';
  7887. // Whitespace text node, don't append it to the AST
  7888. if (/^[\s]*$/.test(textContent)) {
  7889. return;
  7890. }
  7891. astNode.textContent = textContent;
  7892. }
  7893. var parsedAttributes = node.attributes;
  7894. // Add attributes
  7895. if (parsedAttributes) {
  7896. var attributes_2 = {};
  7897. [].forEach.call(parsedAttributes, function (attrib) {
  7898. attributes_2[attrib.name] = attrib.value;
  7899. });
  7900. astNode.attributes = attributes_2;
  7901. }
  7902. // Handle children
  7903. if (node.childNodes.length) {
  7904. var children_1 = [];
  7905. [].forEach.call(node.childNodes, function (childNode) {
  7906. appendChildNodes(childNode, children_1);
  7907. });
  7908. if (children_1.length) {
  7909. astNode.children = children_1;
  7910. }
  7911. }
  7912. addTo.push(astNode);
  7913. };
  7914. [].forEach.call(doc.body.childNodes, function (childNode) { return appendChildNodes(childNode, nodes); });
  7915. if (body) {
  7916. discardElement(body);
  7917. }
  7918. return nodes;
  7919. };
  7920. /**
  7921. * The list of allowed SVG or HTML tags, used for sanitizing potentially
  7922. * harmful content from the chart configuration before adding to the DOM.
  7923. *
  7924. * @example
  7925. * // Allow a custom, trusted tag
  7926. * Highcharts.AST.allowedTags.push('blink'); // ;)
  7927. *
  7928. * @name Highcharts.AST.allowedTags
  7929. * @static
  7930. */
  7931. AST.allowedTags = [
  7932. 'a',
  7933. 'b',
  7934. 'br',
  7935. 'button',
  7936. 'caption',
  7937. 'circle',
  7938. 'clipPath',
  7939. 'code',
  7940. 'dd',
  7941. 'defs',
  7942. 'div',
  7943. 'dl',
  7944. 'dt',
  7945. 'em',
  7946. 'feComponentTransfer',
  7947. 'feFuncA',
  7948. 'feFuncB',
  7949. 'feFuncG',
  7950. 'feFuncR',
  7951. 'feGaussianBlur',
  7952. 'feOffset',
  7953. 'feMerge',
  7954. 'feMergeNode',
  7955. 'filter',
  7956. 'h1',
  7957. 'h2',
  7958. 'h3',
  7959. 'h4',
  7960. 'h5',
  7961. 'h6',
  7962. 'hr',
  7963. 'i',
  7964. 'img',
  7965. 'li',
  7966. 'linearGradient',
  7967. 'marker',
  7968. 'ol',
  7969. 'p',
  7970. 'path',
  7971. 'pattern',
  7972. 'pre',
  7973. 'rect',
  7974. 'small',
  7975. 'span',
  7976. 'stop',
  7977. 'strong',
  7978. 'style',
  7979. 'sub',
  7980. 'sup',
  7981. 'svg',
  7982. 'table',
  7983. 'text',
  7984. 'thead',
  7985. 'tbody',
  7986. 'tspan',
  7987. 'td',
  7988. 'th',
  7989. 'tr',
  7990. 'u',
  7991. 'ul',
  7992. '#text'
  7993. ];
  7994. /**
  7995. * The list of allowed SVG or HTML attributes, used for sanitizing
  7996. * potentially harmful content from the chart configuration before adding to
  7997. * the DOM.
  7998. *
  7999. * @example
  8000. * // Allow a custom, trusted attribute
  8001. * Highcharts.AST.allowedAttributes.push('data-value');
  8002. *
  8003. * @name Highcharts.AST.allowedAttributes
  8004. * @static
  8005. */
  8006. AST.allowedAttributes = [
  8007. 'aria-controls',
  8008. 'aria-describedby',
  8009. 'aria-expanded',
  8010. 'aria-haspopup',
  8011. 'aria-hidden',
  8012. 'aria-label',
  8013. 'aria-labelledby',
  8014. 'aria-live',
  8015. 'aria-pressed',
  8016. 'aria-readonly',
  8017. 'aria-roledescription',
  8018. 'aria-selected',
  8019. 'class',
  8020. 'clip-path',
  8021. 'color',
  8022. 'colspan',
  8023. 'cx',
  8024. 'cy',
  8025. 'd',
  8026. 'dx',
  8027. 'dy',
  8028. 'disabled',
  8029. 'fill',
  8030. 'height',
  8031. 'href',
  8032. 'id',
  8033. 'in',
  8034. 'markerHeight',
  8035. 'markerWidth',
  8036. 'offset',
  8037. 'opacity',
  8038. 'orient',
  8039. 'padding',
  8040. 'paddingLeft',
  8041. 'patternUnits',
  8042. 'r',
  8043. 'refX',
  8044. 'refY',
  8045. 'role',
  8046. 'scope',
  8047. 'slope',
  8048. 'src',
  8049. 'startOffset',
  8050. 'stdDeviation',
  8051. 'stroke',
  8052. 'stroke-linecap',
  8053. 'stroke-width',
  8054. 'style',
  8055. 'result',
  8056. 'rowspan',
  8057. 'summary',
  8058. 'target',
  8059. 'tabindex',
  8060. 'text-align',
  8061. 'textAnchor',
  8062. 'textLength',
  8063. 'type',
  8064. 'valign',
  8065. 'width',
  8066. 'x',
  8067. 'x1',
  8068. 'x2',
  8069. 'y',
  8070. 'y1',
  8071. 'y2',
  8072. 'zIndex'
  8073. ];
  8074. /**
  8075. * The list of allowed references for referring attributes like `href` and
  8076. * `src`. Attribute values will only be allowed if they start with one of
  8077. * these strings.
  8078. *
  8079. * @example
  8080. * // Allow tel:
  8081. * Highcharts.AST.allowedReferences.push('tel:');
  8082. *
  8083. * @name Highcharts.AST.allowedReferences
  8084. * @static
  8085. */
  8086. AST.allowedReferences = [
  8087. 'https://',
  8088. 'http://',
  8089. 'mailto:',
  8090. '/',
  8091. '../',
  8092. './',
  8093. '#'
  8094. ];
  8095. return AST;
  8096. }());
  8097. return AST;
  8098. });
  8099. _registerModule(_modules, 'Core/FormatUtilities.js', [_modules['Core/Options.js'], _modules['Core/Utilities.js']], function (O, U) {
  8100. /* *
  8101. *
  8102. * (c) 2010-2021 Torstein Honsi
  8103. *
  8104. * License: www.highcharts.com/license
  8105. *
  8106. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8107. *
  8108. * */
  8109. var defaultOptions = O.defaultOptions,
  8110. defaultTime = O.defaultTime;
  8111. var getNestedProperty = U.getNestedProperty,
  8112. isNumber = U.isNumber,
  8113. pick = U.pick,
  8114. pInt = U.pInt;
  8115. /* *
  8116. *
  8117. * Functions
  8118. *
  8119. * */
  8120. /**
  8121. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  8122. * human readable date string. The format is a subset of the formats for PHP's
  8123. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  8124. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  8125. *
  8126. * Since v6.0.5, all internal dates are formatted through the
  8127. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  8128. * The `Highcharts.dateFormat` function only reflects global time settings set
  8129. * with `setOptions`.
  8130. *
  8131. * Supported format keys:
  8132. * - `%a`: Short weekday, like 'Mon'
  8133. * - `%A`: Long weekday, like 'Monday'
  8134. * - `%d`: Two digit day of the month, 01 to 31
  8135. * - `%e`: Day of the month, 1 through 31
  8136. * - `%w`: Day of the week, 0 through 6
  8137. * - `%b`: Short month, like 'Jan'
  8138. * - `%B`: Long month, like 'January'
  8139. * - `%m`: Two digit month number, 01 through 12
  8140. * - `%y`: Two digits year, like 09 for 2009
  8141. * - `%Y`: Four digits year, like 2009
  8142. * - `%H`: Two digits hours in 24h format, 00 through 23
  8143. * - `%k`: Hours in 24h format, 0 through 23
  8144. * - `%I`: Two digits hours in 12h format, 00 through 11
  8145. * - `%l`: Hours in 12h format, 1 through 12
  8146. * - `%M`: Two digits minutes, 00 through 59
  8147. * - `%p`: Upper case AM or PM
  8148. * - `%P`: Lower case AM or PM
  8149. * - `%S`: Two digits seconds, 00 through 59
  8150. * - `%L`: Milliseconds (naming from Ruby)
  8151. *
  8152. * @function Highcharts.dateFormat
  8153. *
  8154. * @param {string} format
  8155. * The desired format where various time representations are prefixed
  8156. * with `%`.
  8157. *
  8158. * @param {number} timestamp
  8159. * The JavaScript timestamp.
  8160. *
  8161. * @param {boolean} [capitalize=false]
  8162. * Upper case first letter in the return.
  8163. *
  8164. * @return {string}
  8165. * The formatted date.
  8166. */
  8167. function dateFormat(format, timestamp, capitalize) {
  8168. return defaultTime.dateFormat(format, timestamp, capitalize);
  8169. }
  8170. /**
  8171. * Format a string according to a subset of the rules of Python's String.format
  8172. * method.
  8173. *
  8174. * @example
  8175. * let s = Highcharts.format(
  8176. * 'The {color} fox was {len:.2f} feet long',
  8177. * { color: 'red', len: Math.PI }
  8178. * );
  8179. * // => The red fox was 3.14 feet long
  8180. *
  8181. * @function Highcharts.format
  8182. *
  8183. * @param {string} str
  8184. * The string to format.
  8185. *
  8186. * @param {Record<string, *>} ctx
  8187. * The context, a collection of key-value pairs where each key is
  8188. * replaced by its value.
  8189. *
  8190. * @param {Highcharts.Chart} [chart]
  8191. * A `Chart` instance used to get numberFormatter and time.
  8192. *
  8193. * @return {string}
  8194. * The formatted string.
  8195. */
  8196. function format(str, ctx, chart) {
  8197. var splitter = '{',
  8198. isInside = false,
  8199. segment,
  8200. valueAndFormat,
  8201. val,
  8202. index;
  8203. var floatRegex = /f$/;
  8204. var decRegex = /\.([0-9])/;
  8205. var lang = defaultOptions.lang;
  8206. var time = chart && chart.time || defaultTime;
  8207. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  8208. var ret = [];
  8209. while (str) {
  8210. index = str.indexOf(splitter);
  8211. if (index === -1) {
  8212. break;
  8213. }
  8214. segment = str.slice(0, index);
  8215. if (isInside) { // we're on the closing bracket looking back
  8216. valueAndFormat = segment.split(':');
  8217. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  8218. // Format the replacement
  8219. if (valueAndFormat.length && typeof val === 'number') {
  8220. segment = valueAndFormat.join(':');
  8221. if (floatRegex.test(segment)) { // float
  8222. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  8223. if (val !== null) {
  8224. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  8225. }
  8226. }
  8227. else {
  8228. val = time.dateFormat(segment, val);
  8229. }
  8230. }
  8231. // Push the result and advance the cursor
  8232. ret.push(val);
  8233. }
  8234. else {
  8235. ret.push(segment);
  8236. }
  8237. str = str.slice(index + 1); // the rest
  8238. isInside = !isInside; // toggle
  8239. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  8240. }
  8241. ret.push(str);
  8242. return ret.join('');
  8243. }
  8244. /**
  8245. * Format a number and return a string based on input settings.
  8246. *
  8247. * @sample highcharts/members/highcharts-numberformat/
  8248. * Custom number format
  8249. *
  8250. * @function Highcharts.numberFormat
  8251. *
  8252. * @param {number} number
  8253. * The input number to format.
  8254. *
  8255. * @param {number} decimals
  8256. * The amount of decimals. A value of -1 preserves the amount in the
  8257. * input number.
  8258. *
  8259. * @param {string} [decimalPoint]
  8260. * The decimal point, defaults to the one given in the lang options, or
  8261. * a dot.
  8262. *
  8263. * @param {string} [thousandsSep]
  8264. * The thousands separator, defaults to the one given in the lang
  8265. * options, or a space character.
  8266. *
  8267. * @return {string}
  8268. * The formatted number.
  8269. */
  8270. function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  8271. number = +number || 0;
  8272. decimals = +decimals;
  8273. var ret,
  8274. fractionDigits;
  8275. var lang = defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, exponent = number.toString().split('e'), firstDecimals = decimals;
  8276. if (decimals === -1) {
  8277. // Preserve decimals. Not huge numbers (#3793).
  8278. decimals = Math.min(origDec, 20);
  8279. }
  8280. else if (!isNumber(decimals)) {
  8281. decimals = 2;
  8282. }
  8283. else if (decimals && exponent[1] && exponent[1] < 0) {
  8284. // Expose decimals from exponential notation (#7042)
  8285. fractionDigits = decimals + +exponent[1];
  8286. if (fractionDigits >= 0) {
  8287. // remove too small part of the number while keeping the notation
  8288. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  8289. .split('e')[0];
  8290. decimals = fractionDigits;
  8291. }
  8292. else {
  8293. // fractionDigits < 0
  8294. exponent[0] = exponent[0].split('.')[0] || 0;
  8295. if (decimals < 20) {
  8296. // use number instead of exponential notation (#7405)
  8297. number = (exponent[0] * Math.pow(10, exponent[1]))
  8298. .toFixed(decimals);
  8299. }
  8300. else {
  8301. // or zero
  8302. number = 0;
  8303. }
  8304. exponent[1] = 0;
  8305. }
  8306. }
  8307. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  8308. // Then use toFixed to handle rounding.
  8309. var roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  8310. Math.pow(10, -Math.max(decimals,
  8311. origDec) - 1)).toFixed(decimals);
  8312. // A string containing the positive integer component of the number
  8313. var strinteger = String(pInt(roundedNumber));
  8314. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  8315. var thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  8316. // Language
  8317. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  8318. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  8319. // Start building the return
  8320. ret = number < 0 ? '-' : '';
  8321. // Add the leftover after grouping into thousands. For example, in the
  8322. // number 42 000 000, this line adds 42.
  8323. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  8324. if (+exponent[1] < 0 && !firstDecimals) {
  8325. ret = '0';
  8326. }
  8327. else {
  8328. // Add the remaining thousands groups, joined by the thousands separator
  8329. ret += strinteger
  8330. .substr(thousands)
  8331. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  8332. }
  8333. // Add the decimal point and the decimal component
  8334. if (decimals) {
  8335. // Get the decimal component
  8336. ret += decimalPoint + roundedNumber.slice(-decimals);
  8337. }
  8338. if (exponent[1] && +ret !== 0) {
  8339. ret += 'e' + exponent[1];
  8340. }
  8341. return ret;
  8342. }
  8343. /* *
  8344. *
  8345. * Default Export
  8346. *
  8347. * */
  8348. var exports = {
  8349. dateFormat: dateFormat,
  8350. format: format,
  8351. numberFormat: numberFormat
  8352. };
  8353. return exports;
  8354. });
  8355. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (A, AST, Color, H, palette, U) {
  8356. /* *
  8357. *
  8358. * (c) 2010-2021 Torstein Honsi
  8359. *
  8360. * License: www.highcharts.com/license
  8361. *
  8362. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8363. *
  8364. * */
  8365. var animate = A.animate,
  8366. animObject = A.animObject,
  8367. stop = A.stop;
  8368. var deg2rad = H.deg2rad,
  8369. doc = H.doc,
  8370. hasTouch = H.hasTouch,
  8371. noop = H.noop,
  8372. svg = H.svg,
  8373. SVG_NS = H.SVG_NS,
  8374. win = H.win;
  8375. var addEvent = U.addEvent,
  8376. attr = U.attr,
  8377. createElement = U.createElement,
  8378. css = U.css,
  8379. defined = U.defined,
  8380. erase = U.erase,
  8381. extend = U.extend,
  8382. fireEvent = U.fireEvent,
  8383. isArray = U.isArray,
  8384. isFunction = U.isFunction,
  8385. isNumber = U.isNumber,
  8386. isString = U.isString,
  8387. merge = U.merge,
  8388. objectEach = U.objectEach,
  8389. pick = U.pick,
  8390. pInt = U.pInt,
  8391. syncTimeout = U.syncTimeout,
  8392. uniqueKey = U.uniqueKey;
  8393. /* *
  8394. *
  8395. * Class
  8396. *
  8397. * */
  8398. /* eslint-disable no-invalid-this, valid-jsdoc */
  8399. /**
  8400. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  8401. * rendering layer of Highcharts. Combined with the
  8402. * {@link Highcharts.SVGRenderer}
  8403. * object, these prototypes allow freeform annotation in the charts or even in
  8404. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  8405. * labels, when `text` or `label` elements are created with the `useHTML`
  8406. * parameter.
  8407. *
  8408. * The SVGElement instances are created through factory functions on the
  8409. * {@link Highcharts.SVGRenderer}
  8410. * object, like
  8411. * {@link Highcharts.SVGRenderer#rect|rect},
  8412. * {@link Highcharts.SVGRenderer#path|path},
  8413. * {@link Highcharts.SVGRenderer#text|text},
  8414. * {@link Highcharts.SVGRenderer#label|label},
  8415. * {@link Highcharts.SVGRenderer#g|g}
  8416. * and more.
  8417. *
  8418. * @class
  8419. * @name Highcharts.SVGElement
  8420. */
  8421. var SVGElement = /** @class */ (function () {
  8422. function SVGElement() {
  8423. /* *
  8424. *
  8425. * Properties
  8426. *
  8427. * */
  8428. this.element = void 0;
  8429. this.onEvents = {};
  8430. this.opacity = 1; // Default base for animation
  8431. this.renderer = void 0;
  8432. this.SVG_NS = SVG_NS;
  8433. // Custom attributes used for symbols, these should be filtered out when
  8434. // setting SVGElement attributes (#9375).
  8435. this.symbolCustomAttribs = [
  8436. 'x',
  8437. 'y',
  8438. 'width',
  8439. 'height',
  8440. 'r',
  8441. 'start',
  8442. 'end',
  8443. 'innerR',
  8444. 'anchorX',
  8445. 'anchorY',
  8446. 'rounded'
  8447. ];
  8448. }
  8449. // @todo public zIndex?: number;
  8450. /* *
  8451. *
  8452. * Functions
  8453. *
  8454. * */
  8455. /**
  8456. * Get the current value of an attribute or pseudo attribute,
  8457. * used mainly for animation. Called internally from
  8458. * the {@link Highcharts.SVGRenderer#attr} function.
  8459. *
  8460. * @private
  8461. * @function Highcharts.SVGElement#_defaultGetter
  8462. *
  8463. * @param {string} key
  8464. * Property key.
  8465. *
  8466. * @return {number|string}
  8467. * Property value.
  8468. */
  8469. SVGElement.prototype._defaultGetter = function (key) {
  8470. var ret = pick(this[key + 'Value'], // align getter
  8471. this[key],
  8472. this.element ? this.element.getAttribute(key) : null, 0);
  8473. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  8474. ret = parseFloat(ret);
  8475. }
  8476. return ret;
  8477. };
  8478. /**
  8479. * @private
  8480. * @function Highcharts.SVGElement#_defaultSetter
  8481. *
  8482. * @param {string} value
  8483. *
  8484. * @param {string} key
  8485. *
  8486. * @param {Highcharts.SVGDOMElement} element
  8487. *
  8488. * @return {void}
  8489. */
  8490. SVGElement.prototype._defaultSetter = function (value, key, element) {
  8491. element.setAttribute(key, value);
  8492. };
  8493. /**
  8494. * Add the element to the DOM. All elements must be added this way.
  8495. *
  8496. * @sample highcharts/members/renderer-g
  8497. * Elements added to a group
  8498. *
  8499. * @function Highcharts.SVGElement#add
  8500. *
  8501. * @param {Highcharts.SVGElement} [parent]
  8502. * The parent item to add it to. If undefined, the element is added
  8503. * to the {@link Highcharts.SVGRenderer.box}.
  8504. *
  8505. * @return {Highcharts.SVGElement}
  8506. * Returns the SVGElement for chaining.
  8507. */
  8508. SVGElement.prototype.add = function (parent) {
  8509. var renderer = this.renderer,
  8510. element = this.element;
  8511. var inserted;
  8512. if (parent) {
  8513. this.parentGroup = parent;
  8514. }
  8515. // Mark as inverted
  8516. this.parentInverted = parent && parent.inverted;
  8517. // Build formatted text
  8518. if (typeof this.textStr !== 'undefined' &&
  8519. this.element.nodeName === 'text' // Not for SVGLabel instances
  8520. ) {
  8521. renderer.buildText(this);
  8522. }
  8523. // Mark as added
  8524. this.added = true;
  8525. // If we're adding to renderer root, or other elements in the group
  8526. // have a z index, we need to handle it
  8527. if (!parent || parent.handleZ || this.zIndex) {
  8528. inserted = this.zIndexSetter();
  8529. }
  8530. // If zIndex is not handled, append at the end
  8531. if (!inserted) {
  8532. (parent ?
  8533. parent.element :
  8534. renderer.box).appendChild(element);
  8535. }
  8536. // fire an event for internal hooks
  8537. if (this.onAdd) {
  8538. this.onAdd();
  8539. }
  8540. return this;
  8541. };
  8542. /**
  8543. * Add a class name to an element.
  8544. *
  8545. * @function Highcharts.SVGElement#addClass
  8546. *
  8547. * @param {string} className
  8548. * The new class name to add.
  8549. *
  8550. * @param {boolean} [replace=false]
  8551. * When true, the existing class name(s) will be overwritten with the new
  8552. * one. When false, the new one is added.
  8553. *
  8554. * @return {Highcharts.SVGElement}
  8555. * Return the SVG element for chainability.
  8556. */
  8557. SVGElement.prototype.addClass = function (className, replace) {
  8558. var currentClassName = replace ? '' : (this.attr('class') || '');
  8559. // Trim the string and remove duplicates
  8560. className = (className || '')
  8561. .split(/ /g)
  8562. .reduce(function (newClassName, name) {
  8563. if (currentClassName.indexOf(name) === -1) {
  8564. newClassName.push(name);
  8565. }
  8566. return newClassName;
  8567. }, (currentClassName ?
  8568. [currentClassName] :
  8569. []))
  8570. .join(' ');
  8571. if (className !== currentClassName) {
  8572. this.attr('class', className);
  8573. }
  8574. return this;
  8575. };
  8576. /**
  8577. * This method is executed in the end of `attr()`, after setting all
  8578. * attributes in the hash. In can be used to efficiently consolidate
  8579. * multiple attributes in one SVG property -- e.g., translate, rotate and
  8580. * scale are merged in one "transform" attribute in the SVG node.
  8581. *
  8582. * @private
  8583. * @function Highcharts.SVGElement#afterSetters
  8584. */
  8585. SVGElement.prototype.afterSetters = function () {
  8586. // Update transform. Do this outside the loop to prevent redundant
  8587. // updating for batch setting of attributes.
  8588. if (this.doTransform) {
  8589. this.updateTransform();
  8590. this.doTransform = false;
  8591. }
  8592. };
  8593. /**
  8594. * Align the element relative to the chart or another box.
  8595. *
  8596. * @function Highcharts.SVGElement#align
  8597. *
  8598. * @param {Highcharts.AlignObject} [alignOptions]
  8599. * The alignment options. The function can be called without this
  8600. * parameter in order to re-align an element after the box has been
  8601. * updated.
  8602. *
  8603. * @param {boolean} [alignByTranslate]
  8604. * Align element by translation.
  8605. *
  8606. * @param {string|Highcharts.BBoxObject} [box]
  8607. * The box to align to, needs a width and height. When the box is a
  8608. * string, it refers to an object in the Renderer. For example, when
  8609. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  8610. * holds `width`, `height`, `x` and `y` properties.
  8611. *
  8612. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  8613. */
  8614. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  8615. var attribs = {},
  8616. renderer = this.renderer,
  8617. alignedObjects = renderer.alignedObjects;
  8618. var x,
  8619. y,
  8620. alignTo,
  8621. alignFactor,
  8622. vAlignFactor;
  8623. // First call on instanciate
  8624. if (alignOptions) {
  8625. this.alignOptions = alignOptions;
  8626. this.alignByTranslate = alignByTranslate;
  8627. if (!box || isString(box)) {
  8628. this.alignTo = alignTo = box || 'renderer';
  8629. // prevent duplicates, like legendGroup after resize
  8630. erase(alignedObjects, this);
  8631. alignedObjects.push(this);
  8632. box = void 0; // reassign it below
  8633. }
  8634. // When called on resize, no arguments are supplied
  8635. }
  8636. else {
  8637. alignOptions = this.alignOptions;
  8638. alignByTranslate = this.alignByTranslate;
  8639. alignTo = this.alignTo;
  8640. }
  8641. box = pick(box, renderer[alignTo], alignTo === 'scrollablePlotBox' ? renderer.plotBox : void 0, renderer);
  8642. // Assign variables
  8643. var align = alignOptions.align,
  8644. vAlign = alignOptions.verticalAlign;
  8645. // default: left align
  8646. x = (box.x || 0) + (alignOptions.x || 0);
  8647. // default: top align
  8648. y = (box.y || 0) + (alignOptions.y || 0);
  8649. // Align
  8650. if (align === 'right') {
  8651. alignFactor = 1;
  8652. }
  8653. else if (align === 'center') {
  8654. alignFactor = 2;
  8655. }
  8656. if (alignFactor) {
  8657. x += (box.width - (alignOptions.width || 0)) /
  8658. alignFactor;
  8659. }
  8660. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  8661. // Vertical align
  8662. if (vAlign === 'bottom') {
  8663. vAlignFactor = 1;
  8664. }
  8665. else if (vAlign === 'middle') {
  8666. vAlignFactor = 2;
  8667. }
  8668. if (vAlignFactor) {
  8669. y += (box.height - (alignOptions.height || 0)) /
  8670. vAlignFactor;
  8671. }
  8672. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  8673. // Animate only if already placed
  8674. this[this.placed ? 'animate' : 'attr'](attribs);
  8675. this.placed = true;
  8676. this.alignAttr = attribs;
  8677. return this;
  8678. };
  8679. /**
  8680. * @private
  8681. * @function Highcharts.SVGElement#alignSetter
  8682. * @param {"left"|"center"|"right"} value
  8683. */
  8684. SVGElement.prototype.alignSetter = function (value) {
  8685. var convert = {
  8686. left: 'start',
  8687. center: 'middle',
  8688. right: 'end'
  8689. };
  8690. if (convert[value]) {
  8691. this.alignValue = value;
  8692. this.element.setAttribute('text-anchor', convert[value]);
  8693. }
  8694. };
  8695. /**
  8696. * Animate to given attributes or CSS properties.
  8697. *
  8698. * @sample highcharts/members/element-on/
  8699. * Setting some attributes by animation
  8700. *
  8701. * @function Highcharts.SVGElement#animate
  8702. *
  8703. * @param {Highcharts.SVGAttributes} params
  8704. * SVG attributes or CSS to animate.
  8705. *
  8706. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  8707. * Animation options.
  8708. *
  8709. * @param {Function} [complete]
  8710. * Function to perform at the end of animation.
  8711. *
  8712. * @return {Highcharts.SVGElement}
  8713. * Returns the SVGElement for chaining.
  8714. */
  8715. SVGElement.prototype.animate = function (params, options, complete) {
  8716. var _this = this;
  8717. var animOptions = animObject(pick(options,
  8718. this.renderer.globalAnimation,
  8719. true)),
  8720. deferTime = animOptions.defer;
  8721. // When the page is hidden save resources in the background by not
  8722. // running animation at all (#9749).
  8723. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  8724. animOptions.duration = 0;
  8725. }
  8726. if (animOptions.duration !== 0) {
  8727. // allows using a callback with the global animation without
  8728. // overwriting it
  8729. if (complete) {
  8730. animOptions.complete = complete;
  8731. }
  8732. // If defer option is defined delay the animation #12901
  8733. syncTimeout(function () {
  8734. if (_this.element) {
  8735. animate(_this, params, animOptions);
  8736. }
  8737. }, deferTime);
  8738. }
  8739. else {
  8740. this.attr(params, void 0, complete);
  8741. // Call the end step synchronously
  8742. objectEach(params, function (val, prop) {
  8743. if (animOptions.step) {
  8744. animOptions.step.call(this, val, { prop: prop, pos: 1, elem: this });
  8745. }
  8746. }, this);
  8747. }
  8748. return this;
  8749. };
  8750. /**
  8751. * Apply a text outline through a custom CSS property, by copying the text
  8752. * element and apply stroke to the copy. Used internally. Contrast checks at
  8753. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  8754. *
  8755. * @example
  8756. * // Specific color
  8757. * text.css({
  8758. * textOutline: '1px black'
  8759. * });
  8760. * // Automatic contrast
  8761. * text.css({
  8762. * color: '#000000', // black text
  8763. * textOutline: '1px contrast' // => white outline
  8764. * });
  8765. *
  8766. * @private
  8767. * @function Highcharts.SVGElement#applyTextOutline
  8768. *
  8769. * @param {string} textOutline
  8770. * A custom CSS `text-outline` setting, defined by `width color`.
  8771. */
  8772. SVGElement.prototype.applyTextOutline = function (textOutline) {
  8773. var elem = this.element,
  8774. hasContrast = textOutline.indexOf('contrast') !== -1,
  8775. styles = {};
  8776. // When the text shadow is set to contrast, use dark stroke for light
  8777. // text and vice versa.
  8778. if (hasContrast) {
  8779. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  8780. }
  8781. // Extract the stroke width and color
  8782. var parts = textOutline.split(' ');
  8783. var color = parts[parts.length - 1];
  8784. var strokeWidth = parts[0];
  8785. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  8786. this.fakeTS = true; // Fake text shadow
  8787. // In order to get the right y position of the clone,
  8788. // copy over the y setter
  8789. this.ySetter = this.xSetter;
  8790. // Since the stroke is applied on center of the actual outline, we
  8791. // need to double it to get the correct stroke-width outside the
  8792. // glyphs.
  8793. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  8794. return (2 * Number(digit)) + unit;
  8795. });
  8796. // Remove shadows from previous runs.
  8797. this.removeTextOutline();
  8798. var outline_1 = doc.createElementNS(SVG_NS, 'tspan');
  8799. attr(outline_1, {
  8800. 'class': 'highcharts-text-outline',
  8801. fill: color,
  8802. stroke: color,
  8803. 'stroke-width': strokeWidth,
  8804. 'stroke-linejoin': 'round'
  8805. });
  8806. // For each of the tspans and text nodes, create a copy in the
  8807. // outline.
  8808. [].forEach.call(elem.childNodes, function (childNode) {
  8809. var clone = childNode.cloneNode(true);
  8810. if (clone.removeAttribute) {
  8811. ['fill', 'stroke', 'stroke-width', 'stroke'].forEach(function (prop) { return clone.removeAttribute(prop); });
  8812. }
  8813. outline_1.appendChild(clone);
  8814. });
  8815. // Insert an absolutely positioned break before the original text
  8816. // to keep it in place
  8817. var br_1 = doc.createElementNS(SVG_NS, 'tspan');
  8818. br_1.textContent = '\u200B';
  8819. // Copy x and y if not null
  8820. ['x', 'y'].forEach(function (key) {
  8821. var value = elem.getAttribute(key);
  8822. if (value) {
  8823. br_1.setAttribute(key, value);
  8824. }
  8825. });
  8826. // Insert the outline
  8827. outline_1.appendChild(br_1);
  8828. elem.insertBefore(outline_1, elem.firstChild);
  8829. }
  8830. };
  8831. /**
  8832. * @function Highcharts.SVGElement#attr
  8833. * @param {string} key
  8834. * @return {number|string}
  8835. */ /**
  8836. * Apply native and custom attributes to the SVG elements.
  8837. *
  8838. * In order to set the rotation center for rotation, set x and y to 0 and
  8839. * use `translateX` and `translateY` attributes to position the element
  8840. * instead.
  8841. *
  8842. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  8843. * `stroke-width`.
  8844. *
  8845. * @sample highcharts/members/renderer-rect/
  8846. * Setting some attributes
  8847. *
  8848. * @example
  8849. * // Set multiple attributes
  8850. * element.attr({
  8851. * stroke: 'red',
  8852. * fill: 'blue',
  8853. * x: 10,
  8854. * y: 10
  8855. * });
  8856. *
  8857. * // Set a single attribute
  8858. * element.attr('stroke', 'red');
  8859. *
  8860. * // Get an attribute
  8861. * element.attr('stroke'); // => 'red'
  8862. *
  8863. * @function Highcharts.SVGElement#attr
  8864. *
  8865. * @param {string|Highcharts.SVGAttributes} [hash]
  8866. * The native and custom SVG attributes.
  8867. *
  8868. * @param {number|string|Highcharts.SVGPathArray} [val]
  8869. * If the type of the first argument is `string`, the second can be a
  8870. * value, which will serve as a single attribute setter. If the first
  8871. * argument is a string and the second is undefined, the function
  8872. * serves as a getter and the current value of the property is
  8873. * returned.
  8874. *
  8875. * @param {Function} [complete]
  8876. * A callback function to execute after setting the attributes. This
  8877. * makes the function compliant and interchangeable with the
  8878. * {@link SVGElement#animate} function.
  8879. *
  8880. * @param {boolean} [continueAnimation=true]
  8881. * Used internally when `.attr` is called as part of an animation
  8882. * step. Otherwise, calling `.attr` for an attribute will stop
  8883. * animation for that attribute.
  8884. *
  8885. * @return {Highcharts.SVGElement}
  8886. * If used as a setter, it returns the current
  8887. * {@link Highcharts.SVGElement} so the calls can be chained. If
  8888. * used as a getter, the current value of the attribute is returned.
  8889. */
  8890. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  8891. var element = this.element,
  8892. symbolCustomAttribs = this.symbolCustomAttribs;
  8893. var key,
  8894. hasSetSymbolSize,
  8895. ret = this,
  8896. skipAttr,
  8897. setter;
  8898. // single key-value pair
  8899. if (typeof hash === 'string' && typeof val !== 'undefined') {
  8900. key = hash;
  8901. hash = {};
  8902. hash[key] = val;
  8903. }
  8904. // used as a getter: first argument is a string, second is undefined
  8905. if (typeof hash === 'string') {
  8906. ret = (this[hash + 'Getter'] ||
  8907. this._defaultGetter).call(this, hash, element);
  8908. // setter
  8909. }
  8910. else {
  8911. objectEach(hash, function eachAttribute(val, key) {
  8912. skipAttr = false;
  8913. // Unless .attr is from the animator update, stop current
  8914. // running animation of this property
  8915. if (!continueAnimation) {
  8916. stop(this, key);
  8917. }
  8918. // Special handling of symbol attributes
  8919. if (this.symbolName &&
  8920. symbolCustomAttribs.indexOf(key) !== -1) {
  8921. if (!hasSetSymbolSize) {
  8922. this.symbolAttr(hash);
  8923. hasSetSymbolSize = true;
  8924. }
  8925. skipAttr = true;
  8926. }
  8927. if (this.rotation && (key === 'x' || key === 'y')) {
  8928. this.doTransform = true;
  8929. }
  8930. if (!skipAttr) {
  8931. setter = (this[key + 'Setter'] ||
  8932. this._defaultSetter);
  8933. setter.call(this, val, key, element);
  8934. // Let the shadow follow the main element
  8935. if (!this.styledMode &&
  8936. this.shadows &&
  8937. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  8938. this.updateShadows(key, val, setter);
  8939. }
  8940. }
  8941. }, this);
  8942. this.afterSetters();
  8943. }
  8944. // In accordance with animate, run a complete callback
  8945. if (complete) {
  8946. complete.call(this);
  8947. }
  8948. return ret;
  8949. };
  8950. /**
  8951. * Apply a clipping rectangle to this element.
  8952. *
  8953. * @function Highcharts.SVGElement#clip
  8954. *
  8955. * @param {Highcharts.ClipRectElement} [clipRect]
  8956. * The clipping rectangle. If skipped, the current clip is removed.
  8957. *
  8958. * @return {Highcharts.SVGElement}
  8959. * Returns the SVG element to allow chaining.
  8960. */
  8961. SVGElement.prototype.clip = function (clipRect) {
  8962. return this.attr('clip-path', clipRect ?
  8963. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  8964. 'none');
  8965. };
  8966. /**
  8967. * Calculate the coordinates needed for drawing a rectangle crisply and
  8968. * return the calculated attributes.
  8969. *
  8970. * @function Highcharts.SVGElement#crisp
  8971. *
  8972. * @param {Highcharts.RectangleObject} rect
  8973. * Rectangle to crisp.
  8974. *
  8975. * @param {number} [strokeWidth]
  8976. * The stroke width to consider when computing crisp positioning. It can
  8977. * also be set directly on the rect parameter.
  8978. *
  8979. * @return {Highcharts.RectangleObject}
  8980. * The modified rectangle arguments.
  8981. */
  8982. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  8983. var wrapper = this;
  8984. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  8985. // Math.round because strokeWidth can sometimes have roundoff errors
  8986. var normalizer = Math.round(strokeWidth) % 2 / 2;
  8987. // normalize for crisp edges
  8988. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  8989. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  8990. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  8991. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  8992. if (defined(rect.strokeWidth)) {
  8993. rect.strokeWidth = strokeWidth;
  8994. }
  8995. return rect;
  8996. };
  8997. /**
  8998. * Build and apply an SVG gradient out of a common JavaScript configuration
  8999. * object. This function is called from the attribute setters. An event
  9000. * hook is added for supporting other complex color types.
  9001. *
  9002. * @private
  9003. * @function Highcharts.SVGElement#complexColor
  9004. *
  9005. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  9006. * The gradient or pattern options structure.
  9007. *
  9008. * @param {string} prop
  9009. * The property to apply, can either be `fill` or `stroke`.
  9010. *
  9011. * @param {Highcharts.SVGDOMElement} elem
  9012. * SVG element to apply the gradient on.
  9013. */
  9014. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  9015. var renderer = this.renderer;
  9016. var colorObject,
  9017. gradName,
  9018. gradAttr,
  9019. radAttr,
  9020. gradients,
  9021. stops,
  9022. stopColor,
  9023. stopOpacity,
  9024. radialReference,
  9025. id,
  9026. key = [],
  9027. value;
  9028. fireEvent(this.renderer, 'complexColor', {
  9029. args: arguments
  9030. }, function () {
  9031. // Apply linear or radial gradients
  9032. if (colorOptions.radialGradient) {
  9033. gradName = 'radialGradient';
  9034. }
  9035. else if (colorOptions.linearGradient) {
  9036. gradName = 'linearGradient';
  9037. }
  9038. if (gradName) {
  9039. gradAttr = colorOptions[gradName];
  9040. gradients = renderer.gradients;
  9041. stops = colorOptions.stops;
  9042. radialReference = elem.radialReference;
  9043. // Keep < 2.2 kompatibility
  9044. if (isArray(gradAttr)) {
  9045. colorOptions[gradName] = gradAttr = {
  9046. x1: gradAttr[0],
  9047. y1: gradAttr[1],
  9048. x2: gradAttr[2],
  9049. y2: gradAttr[3],
  9050. gradientUnits: 'userSpaceOnUse'
  9051. };
  9052. }
  9053. // Correct the radial gradient for the radial reference system
  9054. if (gradName === 'radialGradient' &&
  9055. radialReference &&
  9056. !defined(gradAttr.gradientUnits)) {
  9057. // Save the radial attributes for updating
  9058. radAttr = gradAttr;
  9059. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  9060. }
  9061. // Build the unique key to detect whether we need to create a
  9062. // new element (#1282)
  9063. objectEach(gradAttr, function (value, n) {
  9064. if (n !== 'id') {
  9065. key.push(n, value);
  9066. }
  9067. });
  9068. objectEach(stops, function (val) {
  9069. key.push(val);
  9070. });
  9071. key = key.join(',');
  9072. // Check if a gradient object with the same config object is
  9073. // created within this renderer
  9074. if (gradients[key]) {
  9075. id = gradients[key].attr('id');
  9076. }
  9077. else {
  9078. // Set the id and create the element
  9079. gradAttr.id = id = uniqueKey();
  9080. var gradientObject_1 = gradients[key] =
  9081. renderer.createElement(gradName)
  9082. .attr(gradAttr)
  9083. .add(renderer.defs);
  9084. gradientObject_1.radAttr = radAttr;
  9085. // The gradient needs to keep a list of stops to be able to
  9086. // destroy them
  9087. gradientObject_1.stops = [];
  9088. stops.forEach(function (stop) {
  9089. if (stop[1].indexOf('rgba') === 0) {
  9090. colorObject = Color.parse(stop[1]);
  9091. stopColor = colorObject.get('rgb');
  9092. stopOpacity = colorObject.get('a');
  9093. }
  9094. else {
  9095. stopColor = stop[1];
  9096. stopOpacity = 1;
  9097. }
  9098. var stopObject = renderer.createElement('stop').attr({
  9099. offset: stop[0],
  9100. 'stop-color': stopColor,
  9101. 'stop-opacity': stopOpacity
  9102. }).add(gradientObject_1);
  9103. // Add the stop element to the gradient
  9104. gradientObject_1.stops.push(stopObject);
  9105. });
  9106. }
  9107. // Set the reference to the gradient object
  9108. value = 'url(' + renderer.url + '#' + id + ')';
  9109. elem.setAttribute(prop, value);
  9110. elem.gradient = key;
  9111. // Allow the color to be concatenated into tooltips formatters
  9112. // etc. (#2995)
  9113. colorOptions.toString = function () {
  9114. return value;
  9115. };
  9116. }
  9117. });
  9118. };
  9119. /**
  9120. * Set styles for the element. In addition to CSS styles supported by
  9121. * native SVG and HTML elements, there are also some custom made for
  9122. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  9123. * elements.
  9124. *
  9125. * @sample highcharts/members/renderer-text-on-chart/
  9126. * Styled text
  9127. *
  9128. * @function Highcharts.SVGElement#css
  9129. *
  9130. * @param {Highcharts.CSSObject} styles
  9131. * The new CSS styles.
  9132. *
  9133. * @return {Highcharts.SVGElement}
  9134. * Return the SVG element for chaining.
  9135. */
  9136. SVGElement.prototype.css = function (styles) {
  9137. var oldStyles = this.styles, newStyles = {}, elem = this.element,
  9138. // These CSS properties are interpreted internally by the SVG
  9139. // renderer, but are not supported by SVG and should not be added to
  9140. // the DOM. In styled mode, no CSS should find its way to the DOM
  9141. // whatsoever (#6173, #6474).
  9142. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  9143. var textWidth,
  9144. serializedCss = '',
  9145. hyphenate,
  9146. hasNew = !oldStyles;
  9147. // convert legacy
  9148. if (styles && styles.color) {
  9149. styles.fill = styles.color;
  9150. }
  9151. // Filter out existing styles to increase performance (#2640)
  9152. if (oldStyles) {
  9153. objectEach(styles, function (style, n) {
  9154. if (oldStyles && oldStyles[n] !== style) {
  9155. newStyles[n] = style;
  9156. hasNew = true;
  9157. }
  9158. });
  9159. }
  9160. if (hasNew) {
  9161. // Merge the new styles with the old ones
  9162. if (oldStyles) {
  9163. styles = extend(oldStyles, newStyles);
  9164. }
  9165. // Get the text width from style
  9166. if (styles) {
  9167. // Previously set, unset it (#8234)
  9168. if (styles.width === null || styles.width === 'auto') {
  9169. delete this.textWidth;
  9170. // Apply new
  9171. }
  9172. else if (elem.nodeName.toLowerCase() === 'text' &&
  9173. styles.width) {
  9174. textWidth = this.textWidth = pInt(styles.width);
  9175. }
  9176. }
  9177. // store object
  9178. this.styles = styles;
  9179. if (textWidth && (!svg && this.renderer.forExport)) {
  9180. delete styles.width;
  9181. }
  9182. // Serialize and set style attribute
  9183. if (elem.namespaceURI === this.SVG_NS) { // #7633
  9184. hyphenate = function (a, b) {
  9185. return '-' + b.toLowerCase();
  9186. };
  9187. objectEach(styles, function (style, n) {
  9188. if (svgPseudoProps.indexOf(n) === -1) {
  9189. serializedCss +=
  9190. n.replace(/([A-Z])/g, hyphenate) + ':' +
  9191. style + ';';
  9192. }
  9193. });
  9194. if (serializedCss) {
  9195. attr(elem, 'style', serializedCss); // #1881
  9196. }
  9197. }
  9198. else {
  9199. css(elem, styles);
  9200. }
  9201. if (this.added) {
  9202. // Rebuild text after added. Cache mechanisms in the buildText
  9203. // will prevent building if there are no significant changes.
  9204. if (this.element.nodeName === 'text') {
  9205. this.renderer.buildText(this);
  9206. }
  9207. // Apply text outline after added
  9208. if (styles && styles.textOutline) {
  9209. this.applyTextOutline(styles.textOutline);
  9210. }
  9211. }
  9212. }
  9213. return this;
  9214. };
  9215. /**
  9216. * @private
  9217. * @function Highcharts.SVGElement#dashstyleSetter
  9218. * @param {string} value
  9219. */
  9220. SVGElement.prototype.dashstyleSetter = function (value) {
  9221. var i,
  9222. strokeWidth = this['stroke-width'];
  9223. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  9224. // strokeWidth function, we should be able to use that instead.
  9225. if (strokeWidth === 'inherit') {
  9226. strokeWidth = 1;
  9227. }
  9228. value = value && value.toLowerCase();
  9229. if (value) {
  9230. var v = value
  9231. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  9232. .replace('shortdashdot', '3,1,1,1')
  9233. .replace('shortdot', '1,1,')
  9234. .replace('shortdash', '3,1,')
  9235. .replace('longdash', '8,3,')
  9236. .replace(/dot/g, '1,3,')
  9237. .replace('dash', '4,3,')
  9238. .replace(/,$/, '')
  9239. .split(','); // ending comma
  9240. i = v.length;
  9241. while (i--) {
  9242. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  9243. }
  9244. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  9245. this.element.setAttribute('stroke-dasharray', value);
  9246. }
  9247. };
  9248. /**
  9249. * Destroy the element and element wrapper and clear up the DOM and event
  9250. * hooks.
  9251. *
  9252. * @function Highcharts.SVGElement#destroy
  9253. */
  9254. SVGElement.prototype.destroy = function () {
  9255. var wrapper = this,
  9256. element = wrapper.element || {},
  9257. renderer = wrapper.renderer,
  9258. ownerSVGElement = element.ownerSVGElement;
  9259. var parentToClean = (renderer.isSVG &&
  9260. element.nodeName === 'SPAN' &&
  9261. wrapper.parentGroup ||
  9262. void 0),
  9263. grandParent,
  9264. i;
  9265. // remove events
  9266. element.onclick = element.onmouseout = element.onmouseover =
  9267. element.onmousemove = element.point = null;
  9268. stop(wrapper); // stop running animations
  9269. if (wrapper.clipPath && ownerSVGElement) {
  9270. var clipPath_1 = wrapper.clipPath;
  9271. // Look for existing references to this clipPath and remove them
  9272. // before destroying the element (#6196).
  9273. // The upper case version is for Edge
  9274. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  9275. if (el.getAttribute('clip-path').indexOf(clipPath_1.element.id) > -1) {
  9276. el.removeAttribute('clip-path');
  9277. }
  9278. });
  9279. wrapper.clipPath = clipPath_1.destroy();
  9280. }
  9281. // Destroy stops in case this is a gradient object @todo old code?
  9282. if (wrapper.stops) {
  9283. for (i = 0; i < wrapper.stops.length; i++) {
  9284. wrapper.stops[i].destroy();
  9285. }
  9286. wrapper.stops.length = 0;
  9287. wrapper.stops = void 0;
  9288. }
  9289. // remove element
  9290. wrapper.safeRemoveChild(element);
  9291. if (!renderer.styledMode) {
  9292. wrapper.destroyShadows();
  9293. }
  9294. // In case of useHTML, clean up empty containers emulating SVG groups
  9295. // (#1960, #2393, #2697).
  9296. while (parentToClean &&
  9297. parentToClean.div &&
  9298. parentToClean.div.childNodes.length === 0) {
  9299. grandParent = parentToClean.parentGroup;
  9300. wrapper.safeRemoveChild(parentToClean.div);
  9301. delete parentToClean.div;
  9302. parentToClean = grandParent;
  9303. }
  9304. // remove from alignObjects
  9305. if (wrapper.alignTo) {
  9306. erase(renderer.alignedObjects, wrapper);
  9307. }
  9308. objectEach(wrapper, function (val, key) {
  9309. // Destroy child elements of a group
  9310. if (wrapper[key] &&
  9311. wrapper[key].parentGroup === wrapper &&
  9312. wrapper[key].destroy) {
  9313. wrapper[key].destroy();
  9314. }
  9315. // Delete all properties
  9316. delete wrapper[key];
  9317. });
  9318. return;
  9319. };
  9320. /**
  9321. * Destroy shadows on the element.
  9322. *
  9323. * @private
  9324. * @function Highcharts.SVGElement#destroyShadows
  9325. *
  9326. * @return {void}
  9327. */
  9328. SVGElement.prototype.destroyShadows = function () {
  9329. (this.shadows || []).forEach(function (shadow) {
  9330. this.safeRemoveChild(shadow);
  9331. }, this);
  9332. this.shadows = void 0;
  9333. };
  9334. /**
  9335. * @private
  9336. */
  9337. SVGElement.prototype.destroyTextPath = function (elem, path) {
  9338. var textElement = elem.getElementsByTagName('text')[0];
  9339. var childNodes;
  9340. if (textElement) {
  9341. // Remove textPath attributes
  9342. textElement.removeAttribute('dx');
  9343. textElement.removeAttribute('dy');
  9344. // Remove ID's:
  9345. path.element.setAttribute('id', '');
  9346. // Check if textElement includes textPath,
  9347. if (this.textPathWrapper &&
  9348. textElement.getElementsByTagName('textPath').length) {
  9349. // Move nodes to <text>
  9350. childNodes = this.textPathWrapper.element.childNodes;
  9351. // Now move all <tspan>'s and text nodes to the <textPath> node
  9352. while (childNodes.length) {
  9353. textElement.appendChild(childNodes[0]);
  9354. }
  9355. // Remove <textPath> from the DOM
  9356. textElement.removeChild(this.textPathWrapper.element);
  9357. }
  9358. }
  9359. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  9360. // Remove textPath attributes from elem
  9361. // to get correct text-outline position
  9362. elem.removeAttribute('dx');
  9363. elem.removeAttribute('dy');
  9364. }
  9365. if (this.textPathWrapper) {
  9366. // Set textPathWrapper to undefined and destroy it
  9367. this.textPathWrapper = this.textPathWrapper.destroy();
  9368. }
  9369. };
  9370. /**
  9371. * @private
  9372. * @function Highcharts.SVGElement#dSettter
  9373. * @param {number|string|Highcharts.SVGPathArray} value
  9374. * @param {string} key
  9375. * @param {Highcharts.SVGDOMElement} element
  9376. */
  9377. SVGElement.prototype.dSetter = function (value, key, element) {
  9378. if (isArray(value)) {
  9379. // Backwards compatibility, convert one-dimensional array into an
  9380. // array of segments
  9381. if (typeof value[0] === 'string') {
  9382. value = this.renderer.pathToSegments(value);
  9383. }
  9384. this.pathArray = value;
  9385. value = value.reduce(function (acc, seg, i) {
  9386. if (!seg || !seg.join) {
  9387. return (seg || '').toString();
  9388. }
  9389. return (i ? acc + ' ' : '') + seg.join(' ');
  9390. }, '');
  9391. }
  9392. if (/(NaN| {2}|^$)/.test(value)) {
  9393. value = 'M 0 0';
  9394. }
  9395. // Check for cache before resetting. Resetting causes disturbance in the
  9396. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  9397. // possible performance gain.
  9398. if (this[key] !== value) {
  9399. element.setAttribute(key, value);
  9400. this[key] = value;
  9401. }
  9402. };
  9403. /**
  9404. * Fade out an element by animating its opacity down to 0, and hide it on
  9405. * complete. Used internally for the tooltip.
  9406. *
  9407. * @function Highcharts.SVGElement#fadeOut
  9408. *
  9409. * @param {number} [duration=150]
  9410. * The fade duration in milliseconds.
  9411. */
  9412. SVGElement.prototype.fadeOut = function (duration) {
  9413. var elemWrapper = this;
  9414. elemWrapper.animate({
  9415. opacity: 0
  9416. }, {
  9417. duration: pick(duration, 150),
  9418. complete: function () {
  9419. // #3088, assuming we're only using this for tooltips
  9420. elemWrapper.attr({ y: -9999 }).hide();
  9421. }
  9422. });
  9423. };
  9424. /**
  9425. * @private
  9426. * @function Highcharts.SVGElement#fillSetter
  9427. * @param {Highcharts.ColorType} value
  9428. * @param {string} key
  9429. * @param {Highcharts.SVGDOMElement} element
  9430. */
  9431. SVGElement.prototype.fillSetter = function (value, key, element) {
  9432. if (typeof value === 'string') {
  9433. element.setAttribute(key, value);
  9434. }
  9435. else if (value) {
  9436. this.complexColor(value, key, element);
  9437. }
  9438. };
  9439. /**
  9440. * Get the bounding box (width, height, x and y) for the element. Generally
  9441. * used to get rendered text size. Since this is called a lot in charts,
  9442. * the results are cached based on text properties, in order to save DOM
  9443. * traffic. The returned bounding box includes the rotation, so for example
  9444. * a single text line of rotation 90 will report a greater height, and a
  9445. * width corresponding to the line-height.
  9446. *
  9447. * @sample highcharts/members/renderer-on-chart/
  9448. * Draw a rectangle based on a text's bounding box
  9449. *
  9450. * @function Highcharts.SVGElement#getBBox
  9451. *
  9452. * @param {boolean} [reload]
  9453. * Skip the cache and get the updated DOM bouding box.
  9454. *
  9455. * @param {number} [rot]
  9456. * Override the element's rotation. This is internally used on axis
  9457. * labels with a value of 0 to find out what the bounding box would
  9458. * be have been if it were not rotated.
  9459. *
  9460. * @return {Highcharts.BBoxObject}
  9461. * The bounding box with `x`, `y`, `width` and `height` properties.
  9462. */
  9463. SVGElement.prototype.getBBox = function (reload, rot) {
  9464. var wrapper = this,
  9465. renderer = wrapper.renderer,
  9466. element = wrapper.element,
  9467. styles = wrapper.styles,
  9468. textStr = wrapper.textStr,
  9469. cache = renderer.cache,
  9470. cacheKeys = renderer.cacheKeys,
  9471. isSVG = element.namespaceURI === wrapper.SVG_NS,
  9472. rotation = pick(rot,
  9473. wrapper.rotation, 0),
  9474. fontSize = renderer.styledMode ? (element &&
  9475. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  9476. var bBox, // = wrapper.bBox,
  9477. width,
  9478. height,
  9479. toggleTextShadowShim,
  9480. cacheKey;
  9481. // Avoid undefined and null (#7316)
  9482. if (defined(textStr)) {
  9483. cacheKey = textStr.toString();
  9484. // Since numbers are monospaced, and numerical labels appear a lot
  9485. // in a chart, we assume that a label of n characters has the same
  9486. // bounding box as others of the same length. Unless there is inner
  9487. // HTML in the label. In that case, leave the numbers as is (#5899).
  9488. if (cacheKey.indexOf('<') === -1) {
  9489. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  9490. }
  9491. // Properties that affect bounding box
  9492. cacheKey += [
  9493. '',
  9494. rotation,
  9495. fontSize,
  9496. wrapper.textWidth,
  9497. styles && styles.textOverflow,
  9498. styles && styles.fontWeight // #12163
  9499. ].join(',');
  9500. }
  9501. if (cacheKey && !reload) {
  9502. bBox = cache[cacheKey];
  9503. }
  9504. // No cache found
  9505. if (!bBox) {
  9506. // SVG elements
  9507. if (isSVG || renderer.forExport) {
  9508. try { // Fails in Firefox if the container has display: none.
  9509. // When the text shadow shim is used, we need to hide the
  9510. // fake shadows to get the correct bounding box (#3872)
  9511. toggleTextShadowShim = this.fakeTS && function (display) {
  9512. var outline = element.querySelector('.highcharts-text-outline');
  9513. if (outline) {
  9514. css(outline, { display: display });
  9515. }
  9516. };
  9517. // Workaround for #3842, Firefox reporting wrong bounding
  9518. // box for shadows
  9519. if (isFunction(toggleTextShadowShim)) {
  9520. toggleTextShadowShim('none');
  9521. }
  9522. bBox = element.getBBox ?
  9523. // SVG: use extend because IE9 is not allowed to change
  9524. // width and height in case of rotation (below)
  9525. extend({}, element.getBBox()) : {
  9526. // Legacy IE in export mode
  9527. width: element.offsetWidth,
  9528. height: element.offsetHeight
  9529. };
  9530. // #3842
  9531. if (isFunction(toggleTextShadowShim)) {
  9532. toggleTextShadowShim('');
  9533. }
  9534. }
  9535. catch (e) {
  9536. '';
  9537. }
  9538. // If the bBox is not set, the try-catch block above failed. The
  9539. // other condition is for Opera that returns a width of
  9540. // -Infinity on hidden elements.
  9541. if (!bBox || bBox.width < 0) {
  9542. bBox = { width: 0, height: 0 };
  9543. }
  9544. // VML Renderer or useHTML within SVG
  9545. }
  9546. else {
  9547. bBox = wrapper.htmlGetBBox();
  9548. }
  9549. // True SVG elements as well as HTML elements in modern browsers
  9550. // using the .useHTML option need to compensated for rotation
  9551. if (renderer.isSVG) {
  9552. width = bBox.width;
  9553. height = bBox.height;
  9554. // Workaround for wrong bounding box in IE, Edge and Chrome on
  9555. // Windows. With Highcharts' default font, IE and Edge report
  9556. // a box height of 16.899 and Chrome rounds it to 17. If this
  9557. // stands uncorrected, it results in more padding added below
  9558. // the text than above when adding a label border or background.
  9559. // Also vertical positioning is affected.
  9560. // https://jsfiddle.net/highcharts/em37nvuj/
  9561. // (#1101, #1505, #1669, #2568, #6213).
  9562. if (isSVG) {
  9563. bBox.height = height = ({
  9564. '11px,17': 14,
  9565. '13px,20': 16
  9566. }[styles &&
  9567. styles.fontSize + ',' + Math.round(height)] ||
  9568. height);
  9569. }
  9570. // Adjust for rotated text
  9571. if (rotation) {
  9572. var rad = rotation * deg2rad;
  9573. bBox.width = Math.abs(height * Math.sin(rad)) +
  9574. Math.abs(width * Math.cos(rad));
  9575. bBox.height = Math.abs(height * Math.cos(rad)) +
  9576. Math.abs(width * Math.sin(rad));
  9577. }
  9578. }
  9579. // Cache it. When loading a chart in a hidden iframe in Firefox and
  9580. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  9581. if (cacheKey && bBox.height > 0) {
  9582. // Rotate (#4681)
  9583. while (cacheKeys.length > 250) {
  9584. delete cache[cacheKeys.shift()];
  9585. }
  9586. if (!cache[cacheKey]) {
  9587. cacheKeys.push(cacheKey);
  9588. }
  9589. cache[cacheKey] = bBox;
  9590. }
  9591. }
  9592. return bBox;
  9593. };
  9594. /**
  9595. * Get the computed style. Only in styled mode.
  9596. *
  9597. * @example
  9598. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  9599. *
  9600. * @function Highcharts.SVGElement#getStyle
  9601. *
  9602. * @param {string} prop
  9603. * The property name to check for.
  9604. *
  9605. * @return {string}
  9606. * The current computed value.
  9607. */
  9608. SVGElement.prototype.getStyle = function (prop) {
  9609. return win
  9610. .getComputedStyle(this.element || this, '')
  9611. .getPropertyValue(prop);
  9612. };
  9613. /**
  9614. * Check if an element has the given class name.
  9615. *
  9616. * @function Highcharts.SVGElement#hasClass
  9617. *
  9618. * @param {string} className
  9619. * The class name to check for.
  9620. *
  9621. * @return {boolean}
  9622. * Whether the class name is found.
  9623. */
  9624. SVGElement.prototype.hasClass = function (className) {
  9625. return ('' + this.attr('class'))
  9626. .split(' ')
  9627. .indexOf(className) !== -1;
  9628. };
  9629. /**
  9630. * Hide the element, similar to setting the `visibility` attribute to
  9631. * `hidden`.
  9632. *
  9633. * @function Highcharts.SVGElement#hide
  9634. *
  9635. * @param {boolean} [hideByTranslation=false]
  9636. * The flag to determine if element should be hidden by moving out
  9637. * of the viewport. Used for example for dataLabels.
  9638. *
  9639. * @return {Highcharts.SVGElement}
  9640. * Returns the SVGElement for chaining.
  9641. */
  9642. SVGElement.prototype.hide = function (hideByTranslation) {
  9643. if (hideByTranslation) {
  9644. this.attr({ y: -9999 });
  9645. }
  9646. else {
  9647. this.attr({ visibility: 'hidden' });
  9648. }
  9649. return this;
  9650. };
  9651. /**
  9652. * @private
  9653. */
  9654. SVGElement.prototype.htmlGetBBox = function () {
  9655. return { height: 0, width: 0, x: 0, y: 0 };
  9656. };
  9657. /**
  9658. * Initialize the SVG element. This function only exists to make the
  9659. * initialization process overridable. It should not be called directly.
  9660. *
  9661. * @function Highcharts.SVGElement#init
  9662. *
  9663. * @param {Highcharts.SVGRenderer} renderer
  9664. * The SVGRenderer instance to initialize to.
  9665. *
  9666. * @param {string} nodeName
  9667. * The SVG node name.
  9668. */
  9669. SVGElement.prototype.init = function (renderer, nodeName) {
  9670. /**
  9671. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  9672. * node, but may also represent more nodes.
  9673. *
  9674. * @name Highcharts.SVGElement#element
  9675. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  9676. */
  9677. this.element = nodeName === 'span' ?
  9678. createElement(nodeName) :
  9679. doc.createElementNS(this.SVG_NS, nodeName);
  9680. /**
  9681. * The renderer that the SVGElement belongs to.
  9682. *
  9683. * @name Highcharts.SVGElement#renderer
  9684. * @type {Highcharts.SVGRenderer}
  9685. */
  9686. this.renderer = renderer;
  9687. fireEvent(this, 'afterInit');
  9688. };
  9689. /**
  9690. * Invert a group, rotate and flip. This is used internally on inverted
  9691. * charts, where the points and graphs are drawn as if not inverted, then
  9692. * the series group elements are inverted.
  9693. *
  9694. * @function Highcharts.SVGElement#invert
  9695. *
  9696. * @param {boolean} inverted
  9697. * Whether to invert or not. An inverted shape can be un-inverted by
  9698. * setting it to false.
  9699. *
  9700. * @return {Highcharts.SVGElement}
  9701. * Return the SVGElement for chaining.
  9702. */
  9703. SVGElement.prototype.invert = function (inverted) {
  9704. this.inverted = inverted;
  9705. this.updateTransform();
  9706. return this;
  9707. };
  9708. /**
  9709. * Add an event listener. This is a simple setter that replaces the
  9710. * previous event of the same type added by this function, as opposed to
  9711. * the {@link Highcharts#addEvent} function.
  9712. *
  9713. * @sample highcharts/members/element-on/
  9714. * A clickable rectangle
  9715. *
  9716. * @function Highcharts.SVGElement#on
  9717. *
  9718. * @param {string} eventType
  9719. * The event type.
  9720. *
  9721. * @param {Function} handler
  9722. * The handler callback.
  9723. *
  9724. * @return {Highcharts.SVGElement}
  9725. * The SVGElement for chaining.
  9726. */
  9727. SVGElement.prototype.on = function (eventType, handler) {
  9728. var onEvents = this.onEvents;
  9729. if (onEvents[eventType]) {
  9730. // Unbind existing event
  9731. onEvents[eventType]();
  9732. }
  9733. onEvents[eventType] = addEvent(this.element, eventType, handler);
  9734. return this;
  9735. };
  9736. /**
  9737. * @private
  9738. * @function Highcharts.SVGElement#opacitySetter
  9739. * @param {string} value
  9740. * @param {string} key
  9741. * @param {Highcharts.SVGDOMElement} element
  9742. */
  9743. SVGElement.prototype.opacitySetter = function (value, key, element) {
  9744. // Round off to avoid float errors, like tests where opacity lands on
  9745. // 9.86957e-06 instead of 0
  9746. var opacity = Number(Number(value).toFixed(3));
  9747. this.opacity = opacity;
  9748. element.setAttribute(key, opacity);
  9749. };
  9750. /**
  9751. * Remove a class name from the element.
  9752. *
  9753. * @function Highcharts.SVGElement#removeClass
  9754. *
  9755. * @param {string|RegExp} className
  9756. * The class name to remove.
  9757. *
  9758. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  9759. */
  9760. SVGElement.prototype.removeClass = function (className) {
  9761. return this.attr('class', ('' + this.attr('class'))
  9762. .replace(isString(className) ?
  9763. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  9764. className, ' ')
  9765. .replace(/ +/g, ' ')
  9766. .trim());
  9767. };
  9768. /**
  9769. *
  9770. * @private
  9771. */
  9772. SVGElement.prototype.removeTextOutline = function () {
  9773. var outline = this.element
  9774. .querySelector('tspan.highcharts-text-outline');
  9775. if (outline) {
  9776. this.safeRemoveChild(outline);
  9777. }
  9778. };
  9779. /**
  9780. * Removes an element from the DOM.
  9781. *
  9782. * @private
  9783. * @function Highcharts.SVGElement#safeRemoveChild
  9784. *
  9785. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  9786. * The DOM node to remove.
  9787. */
  9788. SVGElement.prototype.safeRemoveChild = function (element) {
  9789. var parentNode = element.parentNode;
  9790. if (parentNode) {
  9791. parentNode.removeChild(element);
  9792. }
  9793. };
  9794. /**
  9795. * Set the coordinates needed to draw a consistent radial gradient across
  9796. * a shape regardless of positioning inside the chart. Used on pie slices
  9797. * to make all the slices have the same radial reference point.
  9798. *
  9799. * @function Highcharts.SVGElement#setRadialReference
  9800. *
  9801. * @param {Array<number>} coordinates
  9802. * The center reference. The format is `[centerX, centerY, diameter]` in
  9803. * pixels.
  9804. *
  9805. * @return {Highcharts.SVGElement}
  9806. * Returns the SVGElement for chaining.
  9807. */
  9808. SVGElement.prototype.setRadialReference = function (coordinates) {
  9809. var existingGradient = (this.element.gradient &&
  9810. this.renderer.gradients[this.element.gradient]);
  9811. this.element.radialReference = coordinates;
  9812. // On redrawing objects with an existing gradient, the gradient needs
  9813. // to be repositioned (#3801)
  9814. if (existingGradient && existingGradient.radAttr) {
  9815. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  9816. }
  9817. return this;
  9818. };
  9819. /**
  9820. * @private
  9821. * @function Highcharts.SVGElement#setTextPath
  9822. * @param {Highcharts.SVGElement} path
  9823. * Path to follow.
  9824. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  9825. * Options.
  9826. * @return {Highcharts.SVGElement}
  9827. * Returns the SVGElement for chaining.
  9828. */
  9829. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  9830. var elem = this.element,
  9831. textNode = this.text ? this.text.element : elem,
  9832. attribsMap = {
  9833. textAnchor: 'text-anchor'
  9834. };
  9835. var adder = false,
  9836. textPathElement,
  9837. textPathId,
  9838. textPathWrapper = this.textPathWrapper,
  9839. firstTime = !textPathWrapper;
  9840. // Defaults
  9841. textPathOptions = merge(true, {
  9842. enabled: true,
  9843. attributes: {
  9844. dy: -5,
  9845. startOffset: '50%',
  9846. textAnchor: 'middle'
  9847. }
  9848. }, textPathOptions);
  9849. var attrs = AST.filterUserAttributes(textPathOptions.attributes);
  9850. if (path && textPathOptions && textPathOptions.enabled) {
  9851. // In case of fixed width for a text, string is rebuilt
  9852. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  9853. if (textPathWrapper &&
  9854. textPathWrapper.element.parentNode === null) {
  9855. // When buildText functionality was triggered again
  9856. // and deletes textPathWrapper parentNode
  9857. firstTime = true;
  9858. textPathWrapper = textPathWrapper.destroy();
  9859. }
  9860. else if (textPathWrapper) {
  9861. // Case after drillup when spans were added into
  9862. // the DOM outside the textPathWrapper parentGroup
  9863. this.removeTextOutline.call(textPathWrapper.parentGroup);
  9864. }
  9865. // label() has padding, text() doesn't
  9866. if (this.options && this.options.padding) {
  9867. attrs.dx = -this.options.padding;
  9868. }
  9869. if (!textPathWrapper) {
  9870. // Create <textPath>, defer the DOM adder
  9871. this.textPathWrapper = textPathWrapper =
  9872. this.renderer.createElement('textPath');
  9873. adder = true;
  9874. }
  9875. textPathElement = textPathWrapper.element;
  9876. // Set ID for the path
  9877. textPathId = path.element.getAttribute('id');
  9878. if (!textPathId) {
  9879. path.element.setAttribute('id', textPathId = uniqueKey());
  9880. }
  9881. // Change DOM structure, by placing <textPath> tag in <text>
  9882. if (firstTime) {
  9883. // Adjust the position
  9884. textNode.setAttribute('y', 0); // Firefox
  9885. if (isNumber(attrs.dx)) {
  9886. textNode.setAttribute('x', -attrs.dx);
  9887. }
  9888. // Move all <tspan>'s and text nodes to the <textPath> node. Do
  9889. // not move other elements like <title> or <path>
  9890. var childNodes = [].slice.call(textNode.childNodes);
  9891. for (var i = 0; i < childNodes.length; i++) {
  9892. var childNode = childNodes[i];
  9893. if (childNode.nodeType === Node.TEXT_NODE ||
  9894. childNode.nodeName === 'tspan') {
  9895. textPathElement.appendChild(childNode);
  9896. }
  9897. }
  9898. }
  9899. // Add <textPath> to the DOM
  9900. if (adder && textPathWrapper) {
  9901. textPathWrapper.add({ element: textNode });
  9902. }
  9903. // Set basic options:
  9904. // Use `setAttributeNS` because Safari needs this..
  9905. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  9906. // Presentation attributes:
  9907. // dx/dy options must by set on <text> (parent),
  9908. // the rest should be set on <textPath>
  9909. if (defined(attrs.dy)) {
  9910. textPathElement.parentNode
  9911. .setAttribute('dy', attrs.dy);
  9912. delete attrs.dy;
  9913. }
  9914. if (defined(attrs.dx)) {
  9915. textPathElement.parentNode
  9916. .setAttribute('dx', attrs.dx);
  9917. delete attrs.dx;
  9918. }
  9919. // Additional attributes
  9920. objectEach(attrs, function (val, key) {
  9921. textPathElement.setAttribute(attribsMap[key] || key, val);
  9922. });
  9923. // Remove translation, text that follows path does not need that
  9924. elem.removeAttribute('transform');
  9925. // Remove shadows and text outlines
  9926. this.removeTextOutline.call(textPathWrapper);
  9927. // Remove background and border for label(), see #10545
  9928. // Alternatively, we can disable setting background rects in
  9929. // series.drawDataLabels()
  9930. if (this.text && !this.renderer.styledMode) {
  9931. this.attr({
  9932. fill: 'none',
  9933. 'stroke-width': 0
  9934. });
  9935. }
  9936. // Disable some functions
  9937. this.updateTransform = noop;
  9938. this.applyTextOutline = noop;
  9939. }
  9940. else if (textPathWrapper) {
  9941. // Reset to prototype
  9942. delete this.updateTransform;
  9943. delete this.applyTextOutline;
  9944. // Restore DOM structure:
  9945. this.destroyTextPath(elem, path);
  9946. // Bring attributes back
  9947. this.updateTransform();
  9948. // Set textOutline back for text()
  9949. if (this.options && this.options.rotation) {
  9950. this.applyTextOutline(this.options.style.textOutline);
  9951. }
  9952. }
  9953. return this;
  9954. };
  9955. /**
  9956. * Add a shadow to the element. Must be called after the element is added to
  9957. * the DOM. In styled mode, this method is not used, instead use `defs` and
  9958. * filters.
  9959. *
  9960. * @example
  9961. * renderer.rect(10, 100, 100, 100)
  9962. * .attr({ fill: 'red' })
  9963. * .shadow(true);
  9964. *
  9965. * @function Highcharts.SVGElement#shadow
  9966. *
  9967. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  9968. * The shadow options. If `true`, the default options are applied. If
  9969. * `false`, the current shadow will be removed.
  9970. *
  9971. * @param {Highcharts.SVGElement} [group]
  9972. * The SVG group element where the shadows will be applied. The
  9973. * default is to add it to the same parent as the current element.
  9974. * Internally, this is ised for pie slices, where all the shadows are
  9975. * added to an element behind all the slices.
  9976. *
  9977. * @param {boolean} [cutOff]
  9978. * Used internally for column shadows.
  9979. *
  9980. * @return {Highcharts.SVGElement}
  9981. * Returns the SVGElement for chaining.
  9982. */
  9983. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  9984. var shadows = [],
  9985. element = this.element,
  9986. oldShadowOptions = this.oldShadowOptions,
  9987. defaultShadowOptions = {
  9988. color: palette.neutralColor100,
  9989. offsetX: 1,
  9990. offsetY: 1,
  9991. opacity: 0.15,
  9992. width: 3
  9993. };
  9994. var i,
  9995. shadow,
  9996. strokeWidth,
  9997. shadowElementOpacity,
  9998. update = false,
  9999. // compensate for inverted plot area
  10000. transform,
  10001. options;
  10002. if (shadowOptions === true) {
  10003. options = defaultShadowOptions;
  10004. }
  10005. else if (typeof shadowOptions === 'object') {
  10006. options = extend(defaultShadowOptions, shadowOptions);
  10007. }
  10008. // Update shadow when options change (#12091).
  10009. if (options) {
  10010. // Go over each key to look for change
  10011. if (options && oldShadowOptions) {
  10012. objectEach(options, function (value, key) {
  10013. if (value !== oldShadowOptions[key]) {
  10014. update = true;
  10015. }
  10016. });
  10017. }
  10018. if (update) {
  10019. this.destroyShadows();
  10020. }
  10021. this.oldShadowOptions = options;
  10022. }
  10023. if (!options) {
  10024. this.destroyShadows();
  10025. }
  10026. else if (!this.shadows) {
  10027. shadowElementOpacity = options.opacity / options.width;
  10028. transform = this.parentInverted ?
  10029. 'translate(-1,-1)' :
  10030. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  10031. for (i = 1; i <= options.width; i++) {
  10032. shadow = element.cloneNode(false);
  10033. strokeWidth = (options.width * 2) + 1 - (2 * i);
  10034. attr(shadow, {
  10035. stroke: (shadowOptions.color ||
  10036. palette.neutralColor100),
  10037. 'stroke-opacity': shadowElementOpacity * i,
  10038. 'stroke-width': strokeWidth,
  10039. transform: transform,
  10040. fill: 'none'
  10041. });
  10042. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  10043. if (cutOff) {
  10044. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  10045. shadow.cutHeight = strokeWidth;
  10046. }
  10047. if (group) {
  10048. group.element.appendChild(shadow);
  10049. }
  10050. else if (element.parentNode) {
  10051. element.parentNode.insertBefore(shadow, element);
  10052. }
  10053. shadows.push(shadow);
  10054. }
  10055. this.shadows = shadows;
  10056. }
  10057. return this;
  10058. };
  10059. /**
  10060. * Show the element after it has been hidden.
  10061. *
  10062. * @function Highcharts.SVGElement#show
  10063. *
  10064. * @param {boolean} [inherit=false]
  10065. * Set the visibility attribute to `inherit` rather than `visible`.
  10066. * The difference is that an element with `visibility="visible"`
  10067. * will be visible even if the parent is hidden.
  10068. *
  10069. * @return {Highcharts.SVGElement}
  10070. * Returns the SVGElement for chaining.
  10071. */
  10072. SVGElement.prototype.show = function (inherit) {
  10073. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  10074. };
  10075. /**
  10076. * WebKit and Batik have problems with a stroke-width of zero, so in this
  10077. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  10078. * #3072.
  10079. *
  10080. * @private
  10081. * @function Highcharts.SVGElement#strokeSetter
  10082. * @param {number|string} value
  10083. * @param {string} key
  10084. * @param {Highcharts.SVGDOMElement} element
  10085. */
  10086. SVGElement.prototype.strokeSetter = function (value, key, element) {
  10087. this[key] = value;
  10088. // Only apply the stroke attribute if the stroke width is defined and
  10089. // larger than 0
  10090. if (this.stroke && this['stroke-width']) {
  10091. // Use prototype as instance may be overridden
  10092. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  10093. element.setAttribute('stroke-width', this['stroke-width']);
  10094. this.hasStroke = true;
  10095. }
  10096. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  10097. element.removeAttribute('stroke');
  10098. this.hasStroke = false;
  10099. }
  10100. else if (this.renderer.styledMode && this['stroke-width']) {
  10101. element.setAttribute('stroke-width', this['stroke-width']);
  10102. this.hasStroke = true;
  10103. }
  10104. };
  10105. /**
  10106. * Get the computed stroke width in pixel values. This is used extensively
  10107. * when drawing shapes to ensure the shapes are rendered crisp and
  10108. * positioned correctly relative to each other. Using
  10109. * `shape-rendering: crispEdges` leaves us less control over positioning,
  10110. * for example when we want to stack columns next to each other, or position
  10111. * things pixel-perfectly within the plot box.
  10112. *
  10113. * The common pattern when placing a shape is:
  10114. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  10115. * now receive a stroke width from the style sheet. In classic mode we
  10116. * will add the `stroke-width` attribute.
  10117. * - Read the computed `elem.strokeWidth()`.
  10118. * - Place it based on the stroke width.
  10119. *
  10120. * @function Highcharts.SVGElement#strokeWidth
  10121. *
  10122. * @return {number}
  10123. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  10124. * attributes) is based on `em` or other units, the pixel size is returned.
  10125. */
  10126. SVGElement.prototype.strokeWidth = function () {
  10127. // In non-styled mode, read the stroke width as set by .attr
  10128. if (!this.renderer.styledMode) {
  10129. return this['stroke-width'] || 0;
  10130. }
  10131. // In styled mode, read computed stroke width
  10132. var val = this.getStyle('stroke-width');
  10133. var ret = 0,
  10134. dummy;
  10135. // Read pixel values directly
  10136. if (val.indexOf('px') === val.length - 2) {
  10137. ret = pInt(val);
  10138. // Other values like em, pt etc need to be measured
  10139. }
  10140. else if (val !== '') {
  10141. dummy = doc.createElementNS(SVG_NS, 'rect');
  10142. attr(dummy, {
  10143. width: val,
  10144. 'stroke-width': 0
  10145. });
  10146. this.element.parentNode.appendChild(dummy);
  10147. ret = dummy.getBBox().width;
  10148. dummy.parentNode.removeChild(dummy);
  10149. }
  10150. return ret;
  10151. };
  10152. /**
  10153. * If one of the symbol size affecting parameters are changed,
  10154. * check all the others only once for each call to an element's
  10155. * .attr() method
  10156. *
  10157. * @private
  10158. * @function Highcharts.SVGElement#symbolAttr
  10159. *
  10160. * @param {Highcharts.SVGAttributes} hash
  10161. * The attributes to set.
  10162. */
  10163. SVGElement.prototype.symbolAttr = function (hash) {
  10164. var wrapper = this;
  10165. [
  10166. 'x',
  10167. 'y',
  10168. 'r',
  10169. 'start',
  10170. 'end',
  10171. 'width',
  10172. 'height',
  10173. 'innerR',
  10174. 'anchorX',
  10175. 'anchorY',
  10176. 'clockwise'
  10177. ].forEach(function (key) {
  10178. wrapper[key] = pick(hash[key], wrapper[key]);
  10179. });
  10180. wrapper.attr({
  10181. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  10182. });
  10183. };
  10184. /**
  10185. * @private
  10186. * @function Highcharts.SVGElement#textSetter
  10187. * @param {string} value
  10188. */
  10189. SVGElement.prototype.textSetter = function (value) {
  10190. if (value !== this.textStr) {
  10191. // Delete size caches when the text changes
  10192. // delete this.bBox; // old code in series-label
  10193. delete this.textPxLength;
  10194. this.textStr = value;
  10195. if (this.added) {
  10196. this.renderer.buildText(this);
  10197. }
  10198. }
  10199. };
  10200. /**
  10201. * @private
  10202. * @function Highcharts.SVGElement#titleSetter
  10203. * @param {string} value
  10204. */
  10205. SVGElement.prototype.titleSetter = function (value) {
  10206. var el = this.element;
  10207. var titleNode = el.getElementsByTagName('title')[0] ||
  10208. doc.createElementNS(this.SVG_NS, 'title');
  10209. // Move to first child
  10210. if (el.insertBefore) {
  10211. el.insertBefore(titleNode, el.firstChild);
  10212. }
  10213. else {
  10214. el.appendChild(titleNode);
  10215. }
  10216. // Replace text content and escape markup
  10217. titleNode.textContent =
  10218. // #3276, #3895
  10219. String(pick(value, ''))
  10220. .replace(/<[^>]*>/g, '')
  10221. .replace(/&lt;/g, '<')
  10222. .replace(/&gt;/g, '>');
  10223. };
  10224. /**
  10225. * Bring the element to the front. Alternatively, a new zIndex can be set.
  10226. *
  10227. * @sample highcharts/members/element-tofront/
  10228. * Click an element to bring it to front
  10229. *
  10230. * @function Highcharts.SVGElement#toFront
  10231. *
  10232. * @return {Highcharts.SVGElement}
  10233. * Returns the SVGElement for chaining.
  10234. */
  10235. SVGElement.prototype.toFront = function () {
  10236. var element = this.element;
  10237. element.parentNode.appendChild(element);
  10238. return this;
  10239. };
  10240. /**
  10241. * Move an object and its children by x and y values.
  10242. *
  10243. * @function Highcharts.SVGElement#translate
  10244. *
  10245. * @param {number} x
  10246. * The x value.
  10247. *
  10248. * @param {number} y
  10249. * The y value.
  10250. *
  10251. * @return {Highcharts.SVGElement}
  10252. */
  10253. SVGElement.prototype.translate = function (x, y) {
  10254. return this.attr({
  10255. translateX: x,
  10256. translateY: y
  10257. });
  10258. };
  10259. /**
  10260. * Update the shadow elements with new attributes.
  10261. *
  10262. * @private
  10263. * @function Highcharts.SVGElement#updateShadows
  10264. *
  10265. * @param {string} key
  10266. * The attribute name.
  10267. *
  10268. * @param {number} value
  10269. * The value of the attribute.
  10270. *
  10271. * @param {Function} setter
  10272. * The setter function, inherited from the parent wrapper.
  10273. */
  10274. SVGElement.prototype.updateShadows = function (key, value, setter) {
  10275. var shadows = this.shadows;
  10276. if (shadows) {
  10277. var i = shadows.length;
  10278. while (i--) {
  10279. setter.call(shadows[i], key === 'height' ?
  10280. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  10281. key === 'd' ? this.d : value, key, shadows[i]);
  10282. }
  10283. }
  10284. };
  10285. /**
  10286. * Update the transform attribute based on internal properties. Deals with
  10287. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  10288. * attributes and updates the SVG `transform` attribute.
  10289. *
  10290. * @private
  10291. * @function Highcharts.SVGElement#updateTransform
  10292. */
  10293. SVGElement.prototype.updateTransform = function () {
  10294. var wrapper = this,
  10295. scaleX = wrapper.scaleX,
  10296. scaleY = wrapper.scaleY,
  10297. inverted = wrapper.inverted,
  10298. rotation = wrapper.rotation,
  10299. matrix = wrapper.matrix,
  10300. element = wrapper.element;
  10301. var translateX = wrapper.translateX || 0,
  10302. translateY = wrapper.translateY || 0;
  10303. // Flipping affects translate as adjustment for flipping around the
  10304. // group's axis
  10305. if (inverted) {
  10306. translateX += wrapper.width;
  10307. translateY += wrapper.height;
  10308. }
  10309. // Apply translate. Nearly all transformed elements have translation,
  10310. // so instead of checking for translate = 0, do it always (#1767,
  10311. // #1846).
  10312. var transform = ['translate(' + translateX + ',' + translateY + ')'];
  10313. // apply matrix
  10314. if (defined(matrix)) {
  10315. transform.push('matrix(' + matrix.join(',') + ')');
  10316. }
  10317. // apply rotation
  10318. if (inverted) {
  10319. transform.push('rotate(90) scale(-1,1)');
  10320. }
  10321. else if (rotation) { // text rotation
  10322. transform.push('rotate(' + rotation + ' ' +
  10323. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  10324. ' ' +
  10325. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  10326. }
  10327. // apply scale
  10328. if (defined(scaleX) || defined(scaleY)) {
  10329. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  10330. }
  10331. if (transform.length) {
  10332. element.setAttribute('transform', transform.join(' '));
  10333. }
  10334. };
  10335. /**
  10336. * @private
  10337. * @function Highcharts.SVGElement#visibilitySetter
  10338. *
  10339. * @param {string} value
  10340. *
  10341. * @param {string} key
  10342. *
  10343. * @param {Highcharts.SVGDOMElement} element
  10344. *
  10345. * @return {void}
  10346. */
  10347. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  10348. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  10349. // attribute instead (#2881, #3909)
  10350. if (value === 'inherit') {
  10351. element.removeAttribute(key);
  10352. }
  10353. else if (this[key] !== value) { // #6747
  10354. element.setAttribute(key, value);
  10355. }
  10356. this[key] = value;
  10357. };
  10358. /**
  10359. * @private
  10360. * @function Highcharts.SVGElement#xGetter
  10361. *
  10362. * @param {string} key
  10363. *
  10364. * @return {number|string|null}
  10365. */
  10366. SVGElement.prototype.xGetter = function (key) {
  10367. if (this.element.nodeName === 'circle') {
  10368. if (key === 'x') {
  10369. key = 'cx';
  10370. }
  10371. else if (key === 'y') {
  10372. key = 'cy';
  10373. }
  10374. }
  10375. return this._defaultGetter(key);
  10376. };
  10377. /**
  10378. * @private
  10379. * @function Highcharts.SVGElement#zIndexSetter
  10380. * @param {number} [value]
  10381. * @param {string} [key]
  10382. * @return {boolean}
  10383. */
  10384. SVGElement.prototype.zIndexSetter = function (value, key) {
  10385. var renderer = this.renderer,
  10386. parentGroup = this.parentGroup,
  10387. parentWrapper = parentGroup || renderer,
  10388. parentNode = parentWrapper.element || renderer.box,
  10389. element = this.element,
  10390. svgParent = parentNode === renderer.box;
  10391. var childNodes,
  10392. otherElement,
  10393. otherZIndex,
  10394. inserted = false,
  10395. undefinedOtherZIndex,
  10396. run = this.added,
  10397. i;
  10398. if (defined(value)) {
  10399. // So we can read it for other elements in the group
  10400. element.setAttribute('data-z-index', value);
  10401. value = +value;
  10402. if (this[key] === value) {
  10403. // Only update when needed (#3865)
  10404. run = false;
  10405. }
  10406. }
  10407. else if (defined(this[key])) {
  10408. element.removeAttribute('data-z-index');
  10409. }
  10410. this[key] = value;
  10411. // Insert according to this and other elements' zIndex. Before .add() is
  10412. // called, nothing is done. Then on add, or by later calls to
  10413. // zIndexSetter, the node is placed on the right place in the DOM.
  10414. if (run) {
  10415. value = this.zIndex;
  10416. if (value && parentGroup) {
  10417. parentGroup.handleZ = true;
  10418. }
  10419. childNodes = parentNode.childNodes;
  10420. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  10421. otherElement = childNodes[i];
  10422. otherZIndex = otherElement.getAttribute('data-z-index');
  10423. undefinedOtherZIndex = !defined(otherZIndex);
  10424. if (otherElement !== element) {
  10425. if (
  10426. // Negative zIndex versus no zIndex:
  10427. // On all levels except the highest. If the parent is
  10428. // <svg>, then we don't want to put items before <desc>
  10429. // or <defs>
  10430. value < 0 &&
  10431. undefinedOtherZIndex &&
  10432. !svgParent &&
  10433. !i) {
  10434. parentNode.insertBefore(element, childNodes[i]);
  10435. inserted = true;
  10436. }
  10437. else if (
  10438. // Insert after the first element with a lower zIndex
  10439. pInt(otherZIndex) <= value ||
  10440. // If negative zIndex, add this before first undefined
  10441. // zIndex element
  10442. (undefinedOtherZIndex &&
  10443. (!defined(value) || value >= 0))) {
  10444. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  10445. );
  10446. inserted = true;
  10447. }
  10448. }
  10449. }
  10450. if (!inserted) {
  10451. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  10452. );
  10453. inserted = true;
  10454. }
  10455. }
  10456. return inserted;
  10457. };
  10458. return SVGElement;
  10459. }());
  10460. // Some shared setters and getters
  10461. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  10462. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  10463. SVGElement.prototype.matrixSetter =
  10464. SVGElement.prototype.rotationOriginXSetter =
  10465. SVGElement.prototype.rotationOriginYSetter =
  10466. SVGElement.prototype.rotationSetter =
  10467. SVGElement.prototype.scaleXSetter =
  10468. SVGElement.prototype.scaleYSetter =
  10469. SVGElement.prototype.translateXSetter =
  10470. SVGElement.prototype.translateYSetter =
  10471. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  10472. this[key] = value;
  10473. this.doTransform = true;
  10474. };
  10475. /* *
  10476. *
  10477. * API Declarations
  10478. *
  10479. * */
  10480. /**
  10481. * Reference to the global SVGElement class as a workaround for a name conflict
  10482. * in the Highcharts namespace.
  10483. *
  10484. * @global
  10485. * @typedef {global.SVGElement} GlobalSVGElement
  10486. *
  10487. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10488. */
  10489. /**
  10490. * The horizontal alignment of an element.
  10491. *
  10492. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  10493. */
  10494. /**
  10495. * Options to align the element relative to the chart or another box.
  10496. *
  10497. * @interface Highcharts.AlignObject
  10498. */ /**
  10499. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  10500. *
  10501. * @name Highcharts.AlignObject#align
  10502. * @type {Highcharts.AlignValue|undefined}
  10503. *
  10504. * @default left
  10505. */ /**
  10506. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  10507. *
  10508. * @name Highcharts.AlignObject#verticalAlign
  10509. * @type {Highcharts.VerticalAlignValue|undefined}
  10510. *
  10511. * @default top
  10512. */ /**
  10513. * Horizontal pixel offset from alignment.
  10514. *
  10515. * @name Highcharts.AlignObject#x
  10516. * @type {number|undefined}
  10517. *
  10518. * @default 0
  10519. */ /**
  10520. * Vertical pixel offset from alignment.
  10521. *
  10522. * @name Highcharts.AlignObject#y
  10523. * @type {number|undefined}
  10524. *
  10525. * @default 0
  10526. */ /**
  10527. * Use the `transform` attribute with translateX and translateY custom
  10528. * attributes to align this elements rather than `x` and `y` attributes.
  10529. *
  10530. * @name Highcharts.AlignObject#alignByTranslate
  10531. * @type {boolean|undefined}
  10532. *
  10533. * @default false
  10534. */
  10535. /**
  10536. * Bounding box of an element.
  10537. *
  10538. * @interface Highcharts.BBoxObject
  10539. * @extends Highcharts.PositionObject
  10540. */ /**
  10541. * Height of the bounding box.
  10542. *
  10543. * @name Highcharts.BBoxObject#height
  10544. * @type {number}
  10545. */ /**
  10546. * Width of the bounding box.
  10547. *
  10548. * @name Highcharts.BBoxObject#width
  10549. * @type {number}
  10550. */ /**
  10551. * Horizontal position of the bounding box.
  10552. *
  10553. * @name Highcharts.BBoxObject#x
  10554. * @type {number}
  10555. */ /**
  10556. * Vertical position of the bounding box.
  10557. *
  10558. * @name Highcharts.BBoxObject#y
  10559. * @type {number}
  10560. */
  10561. /**
  10562. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  10563. * elements for the most parts correspond to SVG, but some are specific to
  10564. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  10565. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  10566. * attributes containing a hyphen are _not_ camel-cased, they should be
  10567. * quoted to preserve the hyphen.
  10568. *
  10569. * @example
  10570. * {
  10571. * 'stroke': '#ff0000', // basic
  10572. * 'stroke-width': 2, // hyphenated
  10573. * 'rotation': 45 // custom
  10574. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  10575. * }
  10576. *
  10577. * @interface Highcharts.SVGAttributes
  10578. */ /**
  10579. * @name Highcharts.SVGAttributes#[key:string]
  10580. * @type {*}
  10581. */ /**
  10582. * @name Highcharts.SVGAttributes#d
  10583. * @type {string|Highcharts.SVGPathArray|undefined}
  10584. */ /**
  10585. * @name Highcharts.SVGAttributes#fill
  10586. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10587. */ /**
  10588. * @name Highcharts.SVGAttributes#inverted
  10589. * @type {boolean|undefined}
  10590. */ /**
  10591. * @name Highcharts.SVGAttributes#matrix
  10592. * @type {Array<number>|undefined}
  10593. */ /**
  10594. * @name Highcharts.SVGAttributes#rotation
  10595. * @type {number|undefined}
  10596. */ /**
  10597. * @name Highcharts.SVGAttributes#rotationOriginX
  10598. * @type {number|undefined}
  10599. */ /**
  10600. * @name Highcharts.SVGAttributes#rotationOriginY
  10601. * @type {number|undefined}
  10602. */ /**
  10603. * @name Highcharts.SVGAttributes#scaleX
  10604. * @type {number|undefined}
  10605. */ /**
  10606. * @name Highcharts.SVGAttributes#scaleY
  10607. * @type {number|undefined}
  10608. */ /**
  10609. * @name Highcharts.SVGAttributes#stroke
  10610. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10611. */ /**
  10612. * @name Highcharts.SVGAttributes#style
  10613. * @type {string|Highcharts.CSSObject|undefined}
  10614. */ /**
  10615. * @name Highcharts.SVGAttributes#translateX
  10616. * @type {number|undefined}
  10617. */ /**
  10618. * @name Highcharts.SVGAttributes#translateY
  10619. * @type {number|undefined}
  10620. */ /**
  10621. * @name Highcharts.SVGAttributes#zIndex
  10622. * @type {number|undefined}
  10623. */
  10624. /**
  10625. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  10626. * global scope.
  10627. *
  10628. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  10629. *
  10630. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10631. */
  10632. /**
  10633. * The vertical alignment of an element.
  10634. *
  10635. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  10636. */
  10637. ''; // detach doclets above
  10638. return SVGElement;
  10639. });
  10640. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  10641. /* *
  10642. *
  10643. * (c) 2010-2021 Torstein Honsi
  10644. *
  10645. * License: www.highcharts.com/license
  10646. *
  10647. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10648. *
  10649. * */
  10650. var __extends = (this && this.__extends) || (function () {
  10651. var extendStatics = function (d,
  10652. b) {
  10653. extendStatics = Object.setPrototypeOf ||
  10654. ({ __proto__: [] } instanceof Array && function (d,
  10655. b) { d.__proto__ = b; }) ||
  10656. function (d,
  10657. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10658. return extendStatics(d, b);
  10659. };
  10660. return function (d, b) {
  10661. extendStatics(d, b);
  10662. function __() { this.constructor = d; }
  10663. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10664. };
  10665. })();
  10666. var defined = U.defined,
  10667. extend = U.extend,
  10668. isNumber = U.isNumber,
  10669. merge = U.merge,
  10670. pick = U.pick,
  10671. removeEvent = U.removeEvent;
  10672. /* eslint require-jsdoc: 0, no-invalid-this: 0 */
  10673. function paddingSetter(value, key) {
  10674. if (!isNumber(value)) {
  10675. this[key] = void 0;
  10676. }
  10677. else if (value !== this[key]) {
  10678. this[key] = value;
  10679. this.updateTextPadding();
  10680. }
  10681. }
  10682. /**
  10683. * SVG label to render text.
  10684. * @private
  10685. * @class
  10686. * @name Highcharts.SVGLabel
  10687. * @augments Highcharts.SVGElement
  10688. */
  10689. var SVGLabel = /** @class */ (function (_super) {
  10690. __extends(SVGLabel, _super);
  10691. /* *
  10692. *
  10693. * Constructors
  10694. *
  10695. * */
  10696. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  10697. var _this = _super.call(this) || this;
  10698. _this.paddingSetter = paddingSetter;
  10699. _this.paddingLeftSetter = paddingSetter;
  10700. _this.paddingRightSetter = paddingSetter;
  10701. _this.init(renderer, 'g');
  10702. _this.textStr = str;
  10703. _this.x = x;
  10704. _this.y = y;
  10705. _this.anchorX = anchorX;
  10706. _this.anchorY = anchorY;
  10707. _this.baseline = baseline;
  10708. _this.className = className;
  10709. if (className !== 'button') {
  10710. _this.addClass('highcharts-label');
  10711. }
  10712. if (className) {
  10713. _this.addClass('highcharts-' + className);
  10714. }
  10715. _this.text = renderer.text('', 0, 0, useHTML).attr({ zIndex: 1 });
  10716. // Validate the shape argument
  10717. var hasBGImage;
  10718. if (typeof shape === 'string') {
  10719. hasBGImage = /^url\((.*?)\)$/.test(shape);
  10720. if (_this.renderer.symbols[shape] || hasBGImage) {
  10721. _this.symbolKey = shape;
  10722. }
  10723. }
  10724. _this.bBox = SVGLabel.emptyBBox;
  10725. _this.padding = 3;
  10726. _this.baselineOffset = 0;
  10727. _this.needsBox = renderer.styledMode || hasBGImage;
  10728. _this.deferredAttr = {};
  10729. _this.alignFactor = 0;
  10730. return _this;
  10731. }
  10732. /* *
  10733. *
  10734. * Functions
  10735. *
  10736. * */
  10737. SVGLabel.prototype.alignSetter = function (value) {
  10738. var alignFactor = ({
  10739. left: 0,
  10740. center: 0.5,
  10741. right: 1
  10742. })[value];
  10743. if (alignFactor !== this.alignFactor) {
  10744. this.alignFactor = alignFactor;
  10745. // Bounding box exists, means we're dynamically changing
  10746. if (this.bBox && isNumber(this.xSetting)) {
  10747. this.attr({ x: this.xSetting }); // #5134
  10748. }
  10749. }
  10750. };
  10751. SVGLabel.prototype.anchorXSetter = function (value, key) {
  10752. this.anchorX = value;
  10753. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  10754. };
  10755. SVGLabel.prototype.anchorYSetter = function (value, key) {
  10756. this.anchorY = value;
  10757. this.boxAttr(key, value - this.ySetting);
  10758. };
  10759. /*
  10760. * Set a box attribute, or defer it if the box is not yet created
  10761. */
  10762. SVGLabel.prototype.boxAttr = function (key, value) {
  10763. if (this.box) {
  10764. this.box.attr(key, value);
  10765. }
  10766. else {
  10767. this.deferredAttr[key] = value;
  10768. }
  10769. };
  10770. /*
  10771. * Pick up some properties and apply them to the text instead of the
  10772. * wrapper.
  10773. */
  10774. SVGLabel.prototype.css = function (styles) {
  10775. if (styles) {
  10776. var textStyles_1 = {},
  10777. isWidth = void 0,
  10778. isFontStyle = void 0;
  10779. // Create a copy to avoid altering the original object
  10780. // (#537)
  10781. styles = merge(styles);
  10782. SVGLabel.textProps.forEach(function (prop) {
  10783. if (typeof styles[prop] !== 'undefined') {
  10784. textStyles_1[prop] = styles[prop];
  10785. delete styles[prop];
  10786. }
  10787. });
  10788. this.text.css(textStyles_1);
  10789. isWidth = 'width' in textStyles_1;
  10790. isFontStyle = 'fontSize' in textStyles_1 ||
  10791. 'fontWeight' in textStyles_1;
  10792. // Update existing text, box (#9400, #12163)
  10793. if (isFontStyle) {
  10794. this.updateTextPadding();
  10795. }
  10796. else if (isWidth) {
  10797. this.updateBoxSize();
  10798. }
  10799. }
  10800. return SVGElement.prototype.css.call(this, styles);
  10801. };
  10802. /*
  10803. * Destroy and release memory.
  10804. */
  10805. SVGLabel.prototype.destroy = function () {
  10806. // Added by button implementation
  10807. removeEvent(this.element, 'mouseenter');
  10808. removeEvent(this.element, 'mouseleave');
  10809. if (this.text) {
  10810. this.text.destroy();
  10811. }
  10812. if (this.box) {
  10813. this.box = this.box.destroy();
  10814. }
  10815. // Call base implementation to destroy the rest
  10816. SVGElement.prototype.destroy.call(this);
  10817. return void 0;
  10818. };
  10819. SVGLabel.prototype.fillSetter = function (value, key) {
  10820. if (value) {
  10821. this.needsBox = true;
  10822. }
  10823. // for animation getter (#6776)
  10824. this.fill = value;
  10825. this.boxAttr(key, value);
  10826. };
  10827. /*
  10828. * Return the bounding box of the box, not the group.
  10829. */
  10830. SVGLabel.prototype.getBBox = function () {
  10831. // If we have a text string and the DOM bBox was 0, it typically means
  10832. // that the label was first rendered hidden, so we need to update the
  10833. // bBox (#15246)
  10834. if (this.textStr && this.bBox.width === 0 && this.bBox.height === 0) {
  10835. this.updateBoxSize();
  10836. }
  10837. var padding = this.padding;
  10838. var paddingLeft = pick(this.paddingLeft,
  10839. padding);
  10840. return {
  10841. width: this.width,
  10842. height: this.height,
  10843. x: this.bBox.x - paddingLeft,
  10844. y: this.bBox.y - padding
  10845. };
  10846. };
  10847. SVGLabel.prototype.getCrispAdjust = function () {
  10848. return this.renderer.styledMode && this.box ?
  10849. this.box.strokeWidth() % 2 / 2 :
  10850. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  10851. };
  10852. SVGLabel.prototype.heightSetter = function (value) {
  10853. this.heightSetting = value;
  10854. };
  10855. // Event handling. In case of useHTML, we need to make sure that events
  10856. // are captured on the span as well, and that mouseenter/mouseleave
  10857. // between the SVG group and the HTML span are not treated as real
  10858. // enter/leave events. #13310.
  10859. SVGLabel.prototype.on = function (eventType, handler) {
  10860. var label = this;
  10861. var text = label.text;
  10862. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  10863. var selectiveHandler;
  10864. if (span) {
  10865. selectiveHandler = function (e) {
  10866. if ((eventType === 'mouseenter' ||
  10867. eventType === 'mouseleave') &&
  10868. e.relatedTarget instanceof Element &&
  10869. (
  10870. // #14110
  10871. label.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY ||
  10872. span.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
  10873. return;
  10874. }
  10875. handler.call(label.element, e);
  10876. };
  10877. span.on(eventType, selectiveHandler);
  10878. }
  10879. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  10880. return label;
  10881. };
  10882. /*
  10883. * After the text element is added, get the desired size of the border
  10884. * box and add it before the text in the DOM.
  10885. */
  10886. SVGLabel.prototype.onAdd = function () {
  10887. var str = this.textStr;
  10888. this.text.add(this);
  10889. this.attr({
  10890. // Alignment is available now (#3295, 0 not rendered if given
  10891. // as a value)
  10892. text: (defined(str) ? str : ''),
  10893. x: this.x,
  10894. y: this.y
  10895. });
  10896. if (this.box && defined(this.anchorX)) {
  10897. this.attr({
  10898. anchorX: this.anchorX,
  10899. anchorY: this.anchorY
  10900. });
  10901. }
  10902. };
  10903. SVGLabel.prototype.rSetter = function (value, key) {
  10904. this.boxAttr(key, value);
  10905. };
  10906. SVGLabel.prototype.shadow = function (b) {
  10907. if (b && !this.renderer.styledMode) {
  10908. this.updateBoxSize();
  10909. if (this.box) {
  10910. this.box.shadow(b);
  10911. }
  10912. }
  10913. return this;
  10914. };
  10915. SVGLabel.prototype.strokeSetter = function (value, key) {
  10916. // for animation getter (#6776)
  10917. this.stroke = value;
  10918. this.boxAttr(key, value);
  10919. };
  10920. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  10921. if (value) {
  10922. this.needsBox = true;
  10923. }
  10924. this['stroke-width'] = value;
  10925. this.boxAttr(key, value);
  10926. };
  10927. SVGLabel.prototype['text-alignSetter'] = function (value) {
  10928. this.textAlign = value;
  10929. };
  10930. SVGLabel.prototype.textSetter = function (text) {
  10931. if (typeof text !== 'undefined') {
  10932. // Must use .attr to ensure transforms are done (#10009)
  10933. this.text.attr({ text: text });
  10934. }
  10935. this.updateTextPadding();
  10936. };
  10937. /*
  10938. * This function runs after the label is added to the DOM (when the bounding
  10939. * box is available), and after the text of the label is updated to detect
  10940. * the new bounding box and reflect it in the border box.
  10941. */
  10942. SVGLabel.prototype.updateBoxSize = function () {
  10943. var style = this.text.element.style,
  10944. crispAdjust,
  10945. attribs = {};
  10946. var padding = this.padding;
  10947. // #12165 error when width is null (auto)
  10948. // #12163 when fontweight: bold, recalculate bBox withot cache
  10949. // #3295 && 3514 box failure when string equals 0
  10950. var bBox = this.bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  10951. defined(this.text.textStr)) ?
  10952. this.text.getBBox() : SVGLabel.emptyBBox;
  10953. this.width = this.getPaddedWidth();
  10954. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  10955. // Update the label-scoped y offset. Math.min because of inline
  10956. // style (#9400)
  10957. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  10958. // When the height is 0, there is no bBox, so go with the font
  10959. // metrics. Highmaps CSS demos.
  10960. bBox.height || Infinity);
  10961. if (this.needsBox) {
  10962. // Create the border box if it is not already present
  10963. if (!this.box) {
  10964. // Symbol definition exists (#5324)
  10965. var box = this.box = this.symbolKey ?
  10966. this.renderer.symbol(this.symbolKey) :
  10967. this.renderer.rect();
  10968. box.addClass(// Don't use label className for buttons
  10969. (this.className === 'button' ? '' : 'highcharts-label-box') +
  10970. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  10971. box.add(this);
  10972. }
  10973. crispAdjust = this.getCrispAdjust();
  10974. attribs.x = crispAdjust;
  10975. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  10976. // Apply the box attributes
  10977. attribs.width = Math.round(this.width);
  10978. attribs.height = Math.round(this.height);
  10979. this.box.attr(extend(attribs, this.deferredAttr));
  10980. this.deferredAttr = {};
  10981. }
  10982. };
  10983. /*
  10984. * This function runs after setting text or padding, but only if padding
  10985. * is changed.
  10986. */
  10987. SVGLabel.prototype.updateTextPadding = function () {
  10988. var text = this.text;
  10989. this.updateBoxSize();
  10990. // Determine y based on the baseline
  10991. var textY = this.baseline ? 0 : this.baselineOffset;
  10992. var textX = pick(this.paddingLeft,
  10993. this.padding);
  10994. // compensate for alignment
  10995. if (defined(this.widthSetting) &&
  10996. this.bBox &&
  10997. (this.textAlign === 'center' || this.textAlign === 'right')) {
  10998. textX += { center: 0.5, right: 1 }[this.textAlign] *
  10999. (this.widthSetting - this.bBox.width);
  11000. }
  11001. // update if anything changed
  11002. if (textX !== text.x || textY !== text.y) {
  11003. text.attr('x', textX);
  11004. // #8159 - prevent misplaced data labels in treemap
  11005. // (useHTML: true)
  11006. if (text.hasBoxWidthChanged) {
  11007. this.bBox = text.getBBox(true);
  11008. }
  11009. if (typeof textY !== 'undefined') {
  11010. text.attr('y', textY);
  11011. }
  11012. }
  11013. // record current values
  11014. text.x = textX;
  11015. text.y = textY;
  11016. };
  11017. SVGLabel.prototype.widthSetter = function (value) {
  11018. // width:auto => null
  11019. this.widthSetting = isNumber(value) ? value : void 0;
  11020. };
  11021. SVGLabel.prototype.getPaddedWidth = function () {
  11022. var padding = this.padding;
  11023. var paddingLeft = pick(this.paddingLeft,
  11024. padding);
  11025. var paddingRight = pick(this.paddingRight,
  11026. padding);
  11027. return (this.widthSetting || this.bBox.width || 0) + paddingLeft + paddingRight;
  11028. };
  11029. SVGLabel.prototype.xSetter = function (value) {
  11030. this.x = value; // for animation getter
  11031. if (this.alignFactor) {
  11032. value -= this.alignFactor * this.getPaddedWidth();
  11033. // Force animation even when setting to the same value (#7898)
  11034. this['forceAnimate:x'] = true;
  11035. }
  11036. this.xSetting = Math.round(value);
  11037. this.attr('translateX', this.xSetting);
  11038. };
  11039. SVGLabel.prototype.ySetter = function (value) {
  11040. this.ySetting = this.y = Math.round(value);
  11041. this.attr('translateY', this.ySetting);
  11042. };
  11043. /* *
  11044. *
  11045. * Static Properties
  11046. *
  11047. * */
  11048. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  11049. /**
  11050. * For labels, these CSS properties are applied to the `text` node directly.
  11051. *
  11052. * @private
  11053. * @name Highcharts.SVGLabel#textProps
  11054. * @type {Array<string>}
  11055. */
  11056. SVGLabel.textProps = [
  11057. 'color', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  11058. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  11059. 'textOutline', 'textOverflow', 'width'
  11060. ];
  11061. return SVGLabel;
  11062. }(SVGElement));
  11063. return SVGLabel;
  11064. });
  11065. _registerModule(_modules, 'Core/Renderer/SVG/TextBuilder.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (H, U, AST) {
  11066. /* *
  11067. *
  11068. * (c) 2010-2020 Torstein Honsi
  11069. *
  11070. * License: www.highcharts.com/license
  11071. *
  11072. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11073. *
  11074. * */
  11075. var doc = H.doc,
  11076. SVG_NS = H.SVG_NS;
  11077. var attr = U.attr,
  11078. erase = U.erase,
  11079. isString = U.isString,
  11080. objectEach = U.objectEach,
  11081. pick = U.pick;
  11082. /**
  11083. * SVG Text Builder
  11084. * @private
  11085. * @class
  11086. * @name Highcharts.TextBuilder
  11087. */
  11088. var TextBuilder = /** @class */ (function () {
  11089. function TextBuilder(svgElement) {
  11090. var textStyles = svgElement.styles;
  11091. this.renderer = svgElement.renderer;
  11092. this.svgElement = svgElement;
  11093. this.width = svgElement.textWidth;
  11094. this.textLineHeight = textStyles && textStyles.lineHeight;
  11095. this.textOutline = textStyles && textStyles.textOutline;
  11096. this.ellipsis = Boolean(textStyles && textStyles.textOverflow === 'ellipsis');
  11097. this.noWrap = Boolean(textStyles && textStyles.whiteSpace === 'nowrap');
  11098. this.fontSize = textStyles && textStyles.fontSize;
  11099. }
  11100. /**
  11101. * Build an SVG representation of the pseudo HTML given in the object's
  11102. * svgElement.
  11103. *
  11104. * @private
  11105. *
  11106. * @return {void}.
  11107. */
  11108. TextBuilder.prototype.buildSVG = function () {
  11109. var wrapper = this.svgElement;
  11110. var textNode = wrapper.element, renderer = wrapper.renderer, textStr = pick(wrapper.textStr, '').toString(), hasMarkup = textStr.indexOf('<') !== -1, childNodes = textNode.childNodes, textCache, i = childNodes.length, tempParent = this.width && !wrapper.added && renderer.box;
  11111. var regexMatchBreaks = /<br.*?>/g;
  11112. // The buildText code is quite heavy, so if we're not changing something
  11113. // that affects the text, skip it (#6113).
  11114. textCache = [
  11115. textStr,
  11116. this.ellipsis,
  11117. this.noWrap,
  11118. this.textLineHeight,
  11119. this.textOutline,
  11120. this.fontSize,
  11121. this.width
  11122. ].join(',');
  11123. if (textCache === wrapper.textCache) {
  11124. return;
  11125. }
  11126. wrapper.textCache = textCache;
  11127. delete wrapper.actualWidth;
  11128. // Remove old text
  11129. while (i--) {
  11130. textNode.removeChild(childNodes[i]);
  11131. }
  11132. // Simple strings, add text directly and return
  11133. if (!hasMarkup &&
  11134. !this.ellipsis &&
  11135. !this.width &&
  11136. (textStr.indexOf(' ') === -1 ||
  11137. (this.noWrap && !regexMatchBreaks.test(textStr)))) {
  11138. textNode.appendChild(doc.createTextNode(this.unescapeEntities(textStr)));
  11139. // Complex strings, add more logic
  11140. }
  11141. else if (textStr !== '') {
  11142. if (tempParent) {
  11143. // attach it to the DOM to read offset width
  11144. tempParent.appendChild(textNode);
  11145. }
  11146. // Step 1. Parse the markup safely and directly into a tree
  11147. // structure.
  11148. var ast = new AST(textStr);
  11149. // Step 2. Do as many as we can of the modifications to the tree
  11150. // structure before it is added to the DOM
  11151. this.modifyTree(ast.nodes);
  11152. ast.addToDOM(wrapper.element);
  11153. // Step 3. Some modifications can't be done until the structure is
  11154. // in the DOM, because we need to read computed metrics.
  11155. this.modifyDOM();
  11156. // Add title if an ellipsis was added
  11157. if (this.ellipsis &&
  11158. (textNode.textContent || '').indexOf('\u2026') !== -1) {
  11159. wrapper.attr('title', this.unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  11160. );
  11161. }
  11162. if (tempParent) {
  11163. tempParent.removeChild(textNode);
  11164. }
  11165. }
  11166. // Apply the text outline
  11167. if (isString(this.textOutline) && wrapper.applyTextOutline) {
  11168. wrapper.applyTextOutline(this.textOutline);
  11169. }
  11170. };
  11171. /**
  11172. * Modify the DOM of the generated SVG structure. This function only does
  11173. * operations that cannot be done until the elements are attached to the
  11174. * DOM, like doing layout based on rendered metrics of the added elements.
  11175. *
  11176. * @private
  11177. *
  11178. * @return {void}
  11179. */
  11180. TextBuilder.prototype.modifyDOM = function () {
  11181. var _this = this;
  11182. var wrapper = this.svgElement;
  11183. var x = attr(wrapper.element, 'x');
  11184. // Modify hard line breaks by applying the rendered line height
  11185. [].forEach.call(wrapper.element.querySelectorAll('tspan.highcharts-br'), function (br) {
  11186. if (br.nextSibling && br.previousSibling) { // #5261
  11187. attr(br, {
  11188. // Since the break is inserted in front of the next
  11189. // line, we need to use the next sibling for the line
  11190. // height
  11191. dy: _this.getLineHeight(br.nextSibling),
  11192. x: x
  11193. });
  11194. }
  11195. });
  11196. // Constrain the line width, either by ellipsis or wrapping
  11197. var width = this.width || 0;
  11198. if (!width) {
  11199. return;
  11200. }
  11201. // Insert soft line breaks into each text node
  11202. var modifyTextNode = function (textNode,
  11203. parentElement) {
  11204. var text = textNode.textContent || '';
  11205. var words = text
  11206. .replace(/([^\^])-/g, '$1- ') // Split on hyphens
  11207. // .trim()
  11208. .split(' '); // #1273
  11209. var hasWhiteSpace = !_this.noWrap && (words.length > 1 || wrapper.element.childNodes.length > 1);
  11210. var dy = _this.getLineHeight(parentElement);
  11211. var lineNo = 0;
  11212. var startAt = wrapper.actualWidth;
  11213. if (_this.ellipsis) {
  11214. if (text) {
  11215. _this.truncate(textNode, text, void 0, 0,
  11216. // Target width
  11217. Math.max(0,
  11218. // Substract the font face to make room for the
  11219. // ellipsis itself
  11220. width - parseInt(_this.fontSize || 12, 10)),
  11221. // Build the text to test for
  11222. function (text, currentIndex) {
  11223. return text.substring(0, currentIndex) + '\u2026';
  11224. });
  11225. }
  11226. }
  11227. else if (hasWhiteSpace) {
  11228. var lines = [];
  11229. // Remove preceding siblings in order to make the text length
  11230. // calculation correct in the truncate function
  11231. var precedingSiblings = [];
  11232. while (parentElement.firstChild &&
  11233. parentElement.firstChild !== textNode) {
  11234. precedingSiblings.push(parentElement.firstChild);
  11235. parentElement.removeChild(parentElement.firstChild);
  11236. }
  11237. while (words.length) {
  11238. // Apply the previous line
  11239. if (words.length && !_this.noWrap && lineNo > 0) {
  11240. lines.push(textNode.textContent || '');
  11241. textNode.textContent = words.join(' ')
  11242. .replace(/- /g, '-');
  11243. }
  11244. // For each line, truncate the remaining
  11245. // words into the line length.
  11246. _this.truncate(textNode, void 0, words, lineNo === 0 ? (startAt || 0) : 0, width,
  11247. // Build the text to test for
  11248. function (t, currentIndex) {
  11249. return words
  11250. .slice(0, currentIndex)
  11251. .join(' ')
  11252. .replace(/- /g, '-');
  11253. });
  11254. startAt = wrapper.actualWidth;
  11255. lineNo++;
  11256. }
  11257. // Reinsert the preceding child nodes
  11258. precedingSiblings.forEach(function (childNode) {
  11259. parentElement.insertBefore(childNode, textNode);
  11260. });
  11261. // Insert the previous lines before the original text node
  11262. lines.forEach(function (line) {
  11263. // Insert the line
  11264. parentElement.insertBefore(doc.createTextNode(line), textNode);
  11265. // Insert a break
  11266. var br = doc.createElementNS(SVG_NS, 'tspan');
  11267. br.textContent = '\u200B'; // zero-width space
  11268. attr(br, { dy: dy, x: x });
  11269. parentElement.insertBefore(br, textNode);
  11270. });
  11271. }
  11272. };
  11273. // Recurse down the DOM tree and handle line breaks for each text node
  11274. var modifyChildren = (function (node) {
  11275. var childNodes = [].slice.call(node.childNodes);
  11276. childNodes.forEach(function (childNode) {
  11277. if (childNode.nodeType === Node.TEXT_NODE) {
  11278. modifyTextNode(childNode, node);
  11279. }
  11280. else {
  11281. // Reset word-wrap width readings after hard breaks
  11282. if (childNode.className.baseVal
  11283. .indexOf('highcharts-br') !== -1) {
  11284. wrapper.actualWidth = 0;
  11285. }
  11286. // Recurse down to child node
  11287. modifyChildren(childNode);
  11288. }
  11289. });
  11290. });
  11291. modifyChildren(wrapper.element);
  11292. };
  11293. /**
  11294. * Get the rendered line height of a <text>, <tspan> or pure text node.
  11295. *
  11296. * @param {DOMElementType|Text} node The node to check for
  11297. *
  11298. * @return {number} The rendered line height
  11299. */
  11300. TextBuilder.prototype.getLineHeight = function (node) {
  11301. var fontSizeStyle;
  11302. // If the node is a text node, use its parent
  11303. var element = node.nodeType === Node.TEXT_NODE ?
  11304. node.parentElement :
  11305. node;
  11306. if (!this.renderer.styledMode) {
  11307. fontSizeStyle =
  11308. element && /(px|em)$/.test(element.style.fontSize) ?
  11309. element.style.fontSize :
  11310. (this.fontSize || this.renderer.style.fontSize || 12);
  11311. }
  11312. return this.textLineHeight ?
  11313. parseInt(this.textLineHeight.toString(), 10) :
  11314. this.renderer.fontMetrics(fontSizeStyle, element || this.svgElement.element).h;
  11315. };
  11316. /**
  11317. * Transform a pseudo HTML AST node tree into an SVG structure. We do as
  11318. * much heavy lifting as we can here, before doing the final processing in
  11319. * the modifyDOM function. The original data is mutated.
  11320. *
  11321. * @private
  11322. *
  11323. * @param {ASTNode[]} nodes The AST nodes
  11324. *
  11325. * @return {void}
  11326. */
  11327. TextBuilder.prototype.modifyTree = function (nodes) {
  11328. var _this = this;
  11329. var modifyChild = function (node,
  11330. i) {
  11331. var tagName = node.tagName;
  11332. var styledMode = _this.renderer.styledMode;
  11333. var attributes = node.attributes || {};
  11334. // Apply styling to text tags
  11335. if (tagName === 'b' || tagName === 'strong') {
  11336. if (styledMode) {
  11337. attributes['class'] = 'highcharts-strong'; // eslint-disable-line dot-notation
  11338. }
  11339. else {
  11340. attributes.style = 'font-weight:bold;' + (attributes.style || '');
  11341. }
  11342. }
  11343. else if (tagName === 'i' || tagName === 'em') {
  11344. if (styledMode) {
  11345. attributes['class'] = 'highcharts-emphasized'; // eslint-disable-line dot-notation
  11346. }
  11347. else {
  11348. attributes.style = 'font-style:italic;' + (attributes.style || '');
  11349. }
  11350. }
  11351. // Modify attributes
  11352. if (isString(attributes.style)) {
  11353. attributes.style = attributes.style.replace(/(;| |^)color([ :])/, '$1fill$2');
  11354. }
  11355. if (tagName === 'br') {
  11356. attributes['class'] = 'highcharts-br'; // eslint-disable-line dot-notation
  11357. node.textContent = '\u200B'; // zero-width space
  11358. // Trim whitespace off the beginning of new lines
  11359. var nextNode = nodes[i + 1];
  11360. if (nextNode && nextNode.textContent) {
  11361. nextNode.textContent =
  11362. nextNode.textContent.replace(/^ +/gm, '');
  11363. }
  11364. }
  11365. if (tagName !== '#text' && tagName !== 'a') {
  11366. node.tagName = 'tspan';
  11367. }
  11368. node.attributes = attributes;
  11369. // Recurse
  11370. if (node.children) {
  11371. node.children
  11372. .filter(function (c) { return c.tagName !== '#text'; })
  11373. .forEach(modifyChild);
  11374. }
  11375. };
  11376. nodes.forEach(modifyChild);
  11377. // Remove empty spans from the beginning because SVG's getBBox doesn't
  11378. // count empty lines. The use case is tooltip where the header is empty.
  11379. while (nodes[0]) {
  11380. if (nodes[0].tagName === 'tspan' && !nodes[0].children) {
  11381. nodes.splice(0, 1);
  11382. }
  11383. else {
  11384. break;
  11385. }
  11386. }
  11387. };
  11388. /*
  11389. * Truncate the text node contents to a given length. Used when the css
  11390. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  11391. * character by character to the given length. If not, the text is
  11392. * word-wrapped line by line.
  11393. */
  11394. TextBuilder.prototype.truncate = function (textNode, text, words, startAt, width, getString) {
  11395. var svgElement = this.svgElement;
  11396. var renderer = svgElement.renderer,
  11397. rotation = svgElement.rotation;
  11398. // Cache the lengths to avoid checking the same twice
  11399. var lengths = [];
  11400. // Word wrap can not be truncated to shorter than one word, ellipsis
  11401. // text can be completely blank.
  11402. var minIndex = words ? 1 : 0;
  11403. var maxIndex = (text || words || '').length;
  11404. var currentIndex = maxIndex;
  11405. var str;
  11406. var actualWidth;
  11407. var getSubStringLength = function (charEnd,
  11408. concatenatedEnd) {
  11409. // charEnd is used when finding the character-by-character
  11410. // break for ellipsis, concatenatedEnd is used for word-by-word
  11411. // break for word wrapping.
  11412. var end = concatenatedEnd || charEnd;
  11413. var parentNode = textNode.parentNode;
  11414. if (parentNode && typeof lengths[end] === 'undefined') {
  11415. // Modern browsers
  11416. if (parentNode.getSubStringLength) {
  11417. // Fails with DOM exception on unit-tests/legend/members
  11418. // of unknown reason. Desired width is 0, text content
  11419. // is "5" and end is 1.
  11420. try {
  11421. lengths[end] = startAt +
  11422. parentNode.getSubStringLength(0, words ? end + 1 : end);
  11423. }
  11424. catch (e) {
  11425. '';
  11426. }
  11427. // Legacy
  11428. }
  11429. else if (renderer.getSpanWidth) { // #9058 jsdom
  11430. textNode.textContent = getString(text || words, charEnd);
  11431. lengths[end] = startAt +
  11432. renderer.getSpanWidth(svgElement, textNode);
  11433. }
  11434. }
  11435. return lengths[end];
  11436. };
  11437. svgElement.rotation = 0; // discard rotation when computing box
  11438. actualWidth = getSubStringLength(textNode.textContent.length);
  11439. if (startAt + actualWidth > width) {
  11440. // Do a binary search for the index where to truncate the text
  11441. while (minIndex <= maxIndex) {
  11442. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  11443. // When checking words for word-wrap, we need to build the
  11444. // string and measure the subStringLength at the concatenated
  11445. // word length.
  11446. if (words) {
  11447. str = getString(words, currentIndex);
  11448. }
  11449. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  11450. if (minIndex === maxIndex) {
  11451. // Complete
  11452. minIndex = maxIndex + 1;
  11453. }
  11454. else if (actualWidth > width) {
  11455. // Too large. Set max index to current.
  11456. maxIndex = currentIndex - 1;
  11457. }
  11458. else {
  11459. // Within width. Set min index to current.
  11460. minIndex = currentIndex;
  11461. }
  11462. }
  11463. // If max index was 0 it means the shortest possible text was also
  11464. // too large. For ellipsis that means only the ellipsis, while for
  11465. // word wrap it means the whole first word.
  11466. if (maxIndex === 0) {
  11467. // Remove ellipsis
  11468. textNode.textContent = '';
  11469. // If the new text length is one less than the original, we don't
  11470. // need the ellipsis
  11471. }
  11472. else if (!(text && maxIndex === text.length - 1)) {
  11473. textNode.textContent = str || getString(text || words, currentIndex);
  11474. }
  11475. }
  11476. // When doing line wrapping, prepare for the next line by removing the
  11477. // items from this line.
  11478. if (words) {
  11479. words.splice(0, currentIndex);
  11480. }
  11481. svgElement.actualWidth = actualWidth;
  11482. svgElement.rotation = rotation; // Apply rotation again.
  11483. };
  11484. /*
  11485. * Un-escape HTML entities based on the public `renderer.escapes` list
  11486. *
  11487. * @private
  11488. *
  11489. * @param {string} inputStr The string to unescape
  11490. * @param {Array<string>} [except] Exceptions
  11491. *
  11492. * @return {string} The processed string
  11493. */
  11494. TextBuilder.prototype.unescapeEntities = function (inputStr, except) {
  11495. objectEach(this.renderer.escapes, function (value, key) {
  11496. if (!except || except.indexOf(value) === -1) {
  11497. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  11498. }
  11499. });
  11500. return inputStr;
  11501. };
  11502. return TextBuilder;
  11503. }());
  11504. return TextBuilder;
  11505. });
  11506. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/TextBuilder.js'], _modules['Core/Utilities.js']], function (Color, H, palette, SVGElement, SVGLabel, AST, TextBuilder, U) {
  11507. /* *
  11508. *
  11509. * (c) 2010-2021 Torstein Honsi
  11510. *
  11511. * License: www.highcharts.com/license
  11512. *
  11513. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11514. *
  11515. * */
  11516. var addEvent = U.addEvent,
  11517. attr = U.attr,
  11518. createElement = U.createElement,
  11519. css = U.css,
  11520. defined = U.defined,
  11521. destroyObjectProperties = U.destroyObjectProperties,
  11522. extend = U.extend,
  11523. isArray = U.isArray,
  11524. isNumber = U.isNumber,
  11525. isObject = U.isObject,
  11526. isString = U.isString,
  11527. merge = U.merge,
  11528. pick = U.pick,
  11529. pInt = U.pInt,
  11530. uniqueKey = U.uniqueKey;
  11531. /**
  11532. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  11533. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  11534. * and applied with the {@link SVGElement#clip} function.
  11535. *
  11536. * @example
  11537. * let circle = renderer.circle(100, 100, 100)
  11538. * .attr({ fill: 'red' })
  11539. * .add();
  11540. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  11541. *
  11542. * // Leave only the lower right quarter visible
  11543. * circle.clip(clipRect);
  11544. *
  11545. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  11546. */
  11547. /**
  11548. * The font metrics.
  11549. *
  11550. * @interface Highcharts.FontMetricsObject
  11551. */ /**
  11552. * The baseline relative to the top of the box.
  11553. *
  11554. * @name Highcharts.FontMetricsObject#b
  11555. * @type {number}
  11556. */ /**
  11557. * The font size.
  11558. *
  11559. * @name Highcharts.FontMetricsObject#f
  11560. * @type {number}
  11561. */ /**
  11562. * The line height.
  11563. *
  11564. * @name Highcharts.FontMetricsObject#h
  11565. * @type {number}
  11566. */
  11567. /**
  11568. * An object containing `x` and `y` properties for the position of an element.
  11569. *
  11570. * @interface Highcharts.PositionObject
  11571. */ /**
  11572. * X position of the element.
  11573. * @name Highcharts.PositionObject#x
  11574. * @type {number}
  11575. */ /**
  11576. * Y position of the element.
  11577. * @name Highcharts.PositionObject#y
  11578. * @type {number}
  11579. */
  11580. /**
  11581. * A rectangle.
  11582. *
  11583. * @interface Highcharts.RectangleObject
  11584. */ /**
  11585. * Height of the rectangle.
  11586. * @name Highcharts.RectangleObject#height
  11587. * @type {number}
  11588. */ /**
  11589. * Width of the rectangle.
  11590. * @name Highcharts.RectangleObject#width
  11591. * @type {number}
  11592. */ /**
  11593. * Horizontal position of the rectangle.
  11594. * @name Highcharts.RectangleObject#x
  11595. * @type {number}
  11596. */ /**
  11597. * Vertical position of the rectangle.
  11598. * @name Highcharts.RectangleObject#y
  11599. * @type {number}
  11600. */
  11601. /**
  11602. * The shadow options.
  11603. *
  11604. * @interface Highcharts.ShadowOptionsObject
  11605. */ /**
  11606. * The shadow color.
  11607. * @name Highcharts.ShadowOptionsObject#color
  11608. * @type {Highcharts.ColorString|undefined}
  11609. * @default ${palette.neutralColor100}
  11610. */ /**
  11611. * The horizontal offset from the element.
  11612. *
  11613. * @name Highcharts.ShadowOptionsObject#offsetX
  11614. * @type {number|undefined}
  11615. * @default 1
  11616. */ /**
  11617. * The vertical offset from the element.
  11618. * @name Highcharts.ShadowOptionsObject#offsetY
  11619. * @type {number|undefined}
  11620. * @default 1
  11621. */ /**
  11622. * The shadow opacity.
  11623. *
  11624. * @name Highcharts.ShadowOptionsObject#opacity
  11625. * @type {number|undefined}
  11626. * @default 0.15
  11627. */ /**
  11628. * The shadow width or distance from the element.
  11629. * @name Highcharts.ShadowOptionsObject#width
  11630. * @type {number|undefined}
  11631. * @default 3
  11632. */
  11633. /**
  11634. * @interface Highcharts.SizeObject
  11635. */ /**
  11636. * @name Highcharts.SizeObject#height
  11637. * @type {number}
  11638. */ /**
  11639. * @name Highcharts.SizeObject#width
  11640. * @type {number}
  11641. */
  11642. /**
  11643. * Array of path commands, that will go into the `d` attribute of an SVG
  11644. * element.
  11645. *
  11646. * @typedef {Array<(Array<Highcharts.SVGPathCommand>|Array<Highcharts.SVGPathCommand,number>|Array<Highcharts.SVGPathCommand,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number,number>)>} Highcharts.SVGPathArray
  11647. */
  11648. /**
  11649. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  11650. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  11651. *
  11652. * @typedef {string} Highcharts.SVGPathCommand
  11653. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  11654. */
  11655. /**
  11656. * An extendable collection of functions for defining symbol paths. Symbols are
  11657. * used internally for point markers, button and label borders and backgrounds,
  11658. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  11659. *
  11660. * @interface Highcharts.SymbolDictionary
  11661. */ /**
  11662. * @name Highcharts.SymbolDictionary#[key:string]
  11663. * @type {Function|undefined}
  11664. */ /**
  11665. * @name Highcharts.SymbolDictionary#arc
  11666. * @type {Function|undefined}
  11667. */ /**
  11668. * @name Highcharts.SymbolDictionary#callout
  11669. * @type {Function|undefined}
  11670. */ /**
  11671. * @name Highcharts.SymbolDictionary#circle
  11672. * @type {Function|undefined}
  11673. */ /**
  11674. * @name Highcharts.SymbolDictionary#diamond
  11675. * @type {Function|undefined}
  11676. */ /**
  11677. * @name Highcharts.SymbolDictionary#square
  11678. * @type {Function|undefined}
  11679. */ /**
  11680. * @name Highcharts.SymbolDictionary#triangle
  11681. * @type {Function|undefined}
  11682. */
  11683. /**
  11684. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  11685. * and `triangle-down`. Symbols are used internally for point markers, button
  11686. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  11687. * {@link SVGRenderer#symbols}.
  11688. *
  11689. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  11690. */
  11691. /**
  11692. * Additional options, depending on the actual symbol drawn.
  11693. *
  11694. * @interface Highcharts.SymbolOptionsObject
  11695. */ /**
  11696. * The anchor X position for the `callout` symbol. This is where the chevron
  11697. * points to.
  11698. *
  11699. * @name Highcharts.SymbolOptionsObject#anchorX
  11700. * @type {number|undefined}
  11701. */ /**
  11702. * The anchor Y position for the `callout` symbol. This is where the chevron
  11703. * points to.
  11704. *
  11705. * @name Highcharts.SymbolOptionsObject#anchorY
  11706. * @type {number|undefined}
  11707. */ /**
  11708. * The end angle of an `arc` symbol.
  11709. *
  11710. * @name Highcharts.SymbolOptionsObject#end
  11711. * @type {number|undefined}
  11712. */ /**
  11713. * Whether to draw `arc` symbol open or closed.
  11714. *
  11715. * @name Highcharts.SymbolOptionsObject#open
  11716. * @type {boolean|undefined}
  11717. */ /**
  11718. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  11719. *
  11720. * @name Highcharts.SymbolOptionsObject#r
  11721. * @type {number|undefined}
  11722. */ /**
  11723. * The start angle of an `arc` symbol.
  11724. *
  11725. * @name Highcharts.SymbolOptionsObject#start
  11726. * @type {number|undefined}
  11727. */
  11728. /* eslint-disable no-invalid-this, valid-jsdoc */
  11729. var charts = H.charts,
  11730. deg2rad = H.deg2rad,
  11731. doc = H.doc,
  11732. isFirefox = H.isFirefox,
  11733. isMS = H.isMS,
  11734. isWebKit = H.isWebKit,
  11735. noop = H.noop,
  11736. SVG_NS = H.SVG_NS,
  11737. symbolSizes = H.symbolSizes,
  11738. win = H.win,
  11739. hasInternalReferenceBug;
  11740. /**
  11741. * Allows direct access to the Highcharts rendering layer in order to draw
  11742. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  11743. * or independent from any chart. The SVGRenderer represents a wrapper object
  11744. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  11745. * module, it also brings vector graphics to IE <= 8.
  11746. *
  11747. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  11748. * The renderer can also be used completely decoupled from a chart.
  11749. *
  11750. * @sample highcharts/members/renderer-on-chart
  11751. * Annotating a chart programmatically.
  11752. * @sample highcharts/members/renderer-basic
  11753. * Independent SVG drawing.
  11754. *
  11755. * @example
  11756. * // Use directly without a chart object.
  11757. * let renderer = new Highcharts.Renderer(parentNode, 600, 400);
  11758. *
  11759. * @class
  11760. * @name Highcharts.SVGRenderer
  11761. *
  11762. * @param {Highcharts.HTMLDOMElement} container
  11763. * Where to put the SVG in the web page.
  11764. *
  11765. * @param {number} width
  11766. * The width of the SVG.
  11767. *
  11768. * @param {number} height
  11769. * The height of the SVG.
  11770. *
  11771. * @param {Highcharts.CSSObject} [style]
  11772. * The box style, if not in styleMode
  11773. *
  11774. * @param {boolean} [forExport=false]
  11775. * Whether the rendered content is intended for export.
  11776. *
  11777. * @param {boolean} [allowHTML=true]
  11778. * Whether the renderer is allowed to include HTML text, which will be
  11779. * projected on top of the SVG.
  11780. *
  11781. * @param {boolean} [styledMode=false]
  11782. * Whether the renderer belongs to a chart that is in styled mode.
  11783. * If it does, it will avoid setting presentational attributes in
  11784. * some cases, but not when set explicitly through `.attr` and `.css`
  11785. * etc.
  11786. */
  11787. var SVGRenderer = /** @class */ (function () {
  11788. /* *
  11789. *
  11790. * Constructors
  11791. *
  11792. * */
  11793. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  11794. /* *
  11795. *
  11796. * Properties
  11797. *
  11798. * */
  11799. this.alignedObjects = void 0;
  11800. /**
  11801. * The root `svg` node of the renderer.
  11802. *
  11803. * @name Highcharts.SVGRenderer#box
  11804. * @type {Highcharts.SVGDOMElement}
  11805. */
  11806. this.box = void 0;
  11807. /**
  11808. * The wrapper for the root `svg` node of the renderer.
  11809. *
  11810. * @name Highcharts.SVGRenderer#boxWrapper
  11811. * @type {Highcharts.SVGElement}
  11812. */
  11813. this.boxWrapper = void 0;
  11814. this.cache = void 0;
  11815. this.cacheKeys = void 0;
  11816. this.chartIndex = void 0;
  11817. /**
  11818. * A pointer to the `defs` node of the root SVG.
  11819. *
  11820. * @name Highcharts.SVGRenderer#defs
  11821. * @type {Highcharts.SVGElement}
  11822. */
  11823. this.defs = void 0;
  11824. this.globalAnimation = void 0;
  11825. this.gradients = void 0;
  11826. this.height = void 0;
  11827. this.imgCount = void 0;
  11828. this.isSVG = void 0;
  11829. this.style = void 0;
  11830. /**
  11831. * Page url used for internal references.
  11832. *
  11833. * @private
  11834. * @name Highcharts.SVGRenderer#url
  11835. * @type {string}
  11836. */
  11837. this.url = void 0;
  11838. this.width = void 0;
  11839. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  11840. }
  11841. /* *
  11842. *
  11843. * Functions
  11844. *
  11845. * */
  11846. /**
  11847. * Initialize the SVGRenderer. Overridable initializer function that takes
  11848. * the same parameters as the constructor.
  11849. *
  11850. * @function Highcharts.SVGRenderer#init
  11851. *
  11852. * @param {Highcharts.HTMLDOMElement} container
  11853. * Where to put the SVG in the web page.
  11854. *
  11855. * @param {number} width
  11856. * The width of the SVG.
  11857. *
  11858. * @param {number} height
  11859. * The height of the SVG.
  11860. *
  11861. * @param {Highcharts.CSSObject} [style]
  11862. * The box style, if not in styleMode
  11863. *
  11864. * @param {boolean} [forExport=false]
  11865. * Whether the rendered content is intended for export.
  11866. *
  11867. * @param {boolean} [allowHTML=true]
  11868. * Whether the renderer is allowed to include HTML text, which will be
  11869. * projected on top of the SVG.
  11870. *
  11871. * @param {boolean} [styledMode=false]
  11872. * Whether the renderer belongs to a chart that is in styled mode. If it
  11873. * does, it will avoid setting presentational attributes in some cases, but
  11874. * not when set explicitly through `.attr` and `.css` etc.
  11875. */
  11876. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  11877. var renderer = this,
  11878. boxWrapper,
  11879. element,
  11880. desc;
  11881. boxWrapper = renderer.createElement('svg')
  11882. .attr({
  11883. version: '1.1',
  11884. 'class': 'highcharts-root'
  11885. });
  11886. if (!styledMode) {
  11887. boxWrapper.css(this.getStyle(style));
  11888. }
  11889. element = boxWrapper.element;
  11890. container.appendChild(element);
  11891. // Always use ltr on the container, otherwise text-anchor will be
  11892. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  11893. attr(container, 'dir', 'ltr');
  11894. // For browsers other than IE, add the namespace attribute (#1978)
  11895. if (container.innerHTML.indexOf('xmlns') === -1) {
  11896. attr(element, 'xmlns', this.SVG_NS);
  11897. }
  11898. // object properties
  11899. renderer.isSVG = true;
  11900. this.box = element;
  11901. this.boxWrapper = boxWrapper;
  11902. renderer.alignedObjects = [];
  11903. this.url = this.getReferenceURL();
  11904. // Add description
  11905. desc = this.createElement('desc').add();
  11906. desc.element.appendChild(doc.createTextNode('Created with Highcharts 9.1.0'));
  11907. renderer.defs = this.createElement('defs').add();
  11908. renderer.allowHTML = allowHTML;
  11909. renderer.forExport = forExport;
  11910. renderer.styledMode = styledMode;
  11911. renderer.gradients = {}; // Object where gradient SvgElements are stored
  11912. renderer.cache = {}; // Cache for numerical bounding boxes
  11913. renderer.cacheKeys = [];
  11914. renderer.imgCount = 0;
  11915. renderer.setSize(width, height, false);
  11916. // Issue 110 workaround:
  11917. // In Firefox, if a div is positioned by percentage, its pixel position
  11918. // may land between pixels. The container itself doesn't display this,
  11919. // but an SVG element inside this container will be drawn at subpixel
  11920. // precision. In order to draw sharp lines, this must be compensated
  11921. // for. This doesn't seem to work inside iframes though (like in
  11922. // jsFiddle).
  11923. var subPixelFix,
  11924. rect;
  11925. if (isFirefox && container.getBoundingClientRect) {
  11926. subPixelFix = function () {
  11927. css(container, { left: 0, top: 0 });
  11928. rect = container.getBoundingClientRect();
  11929. css(container, {
  11930. left: (Math.ceil(rect.left) - rect.left) + 'px',
  11931. top: (Math.ceil(rect.top) - rect.top) + 'px'
  11932. });
  11933. };
  11934. // run the fix now
  11935. subPixelFix();
  11936. // run it on resize
  11937. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  11938. }
  11939. };
  11940. /**
  11941. * General method for adding a definition to the SVG `defs` tag. Can be used
  11942. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  11943. * general definitions to the SVG's defs tag. Definitions can be referenced
  11944. * from the CSS by its `id`. Read more in
  11945. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  11946. * Styled mode only.
  11947. *
  11948. * @function Highcharts.SVGRenderer#definition
  11949. *
  11950. * @param {Highcharts.ASTNode} def
  11951. * A serialized form of an SVG definition, including children.
  11952. *
  11953. * @return {Highcharts.SVGElement}
  11954. * The inserted node.
  11955. */
  11956. SVGRenderer.prototype.definition = function (def) {
  11957. var ast = new AST([def]);
  11958. return ast.addToDOM(this.defs.element);
  11959. };
  11960. /**
  11961. * Get the prefix needed for internal URL references to work in certain
  11962. * cases. Some older browser versions had a bug where internal url
  11963. * references in SVG attributes, on the form `url(#some-id)`, would fail if
  11964. * a base tag was present in the page. There were also issues with
  11965. * `history.pushState` related to this prefix.
  11966. *
  11967. * Related issues: #24, #672, #1070, #5244.
  11968. *
  11969. * The affected browsers are:
  11970. * - Chrome <= 53 (May 2018)
  11971. * - Firefox <= 51 (January 2017)
  11972. * - Safari/Mac <= 12.1 (2018 or 2019)
  11973. * - Safari/iOS <= 13
  11974. *
  11975. * @todo Remove this hack when time has passed. All the affected browsers
  11976. * are evergreens, so it is increasingly unlikely that users are affected by
  11977. * the bug.
  11978. *
  11979. * @return {string}
  11980. * The prefix to use. An empty string for modern browsers.
  11981. */
  11982. SVGRenderer.prototype.getReferenceURL = function () {
  11983. if ((isFirefox || isWebKit) &&
  11984. doc.getElementsByTagName('base').length) {
  11985. // Detect if a clip path is taking effect by performing a hit test
  11986. // outside the clipped area. If the hit element is the rectangle
  11987. // that was supposed to be clipped, the bug is present. This only
  11988. // has to be performed once per page load, so we store the result
  11989. // locally in the module.
  11990. if (!defined(hasInternalReferenceBug)) {
  11991. var id = uniqueKey();
  11992. var ast = new AST([{
  11993. tagName: 'svg',
  11994. attributes: {
  11995. width: 8,
  11996. height: 8
  11997. },
  11998. children: [{
  11999. tagName: 'defs',
  12000. children: [{
  12001. tagName: 'clipPath',
  12002. attributes: {
  12003. id: id
  12004. },
  12005. children: [{
  12006. tagName: 'rect',
  12007. attributes: {
  12008. width: 4,
  12009. height: 4
  12010. }
  12011. }]
  12012. }]
  12013. }, {
  12014. tagName: 'rect',
  12015. attributes: {
  12016. id: 'hitme',
  12017. width: 8,
  12018. height: 8,
  12019. 'clip-path': "url(#" + id + ")",
  12020. fill: 'rgba(0,0,0,0.001)'
  12021. }
  12022. }]
  12023. }]);
  12024. var svg = ast.addToDOM(doc.body);
  12025. css(svg, {
  12026. position: 'fixed',
  12027. top: 0,
  12028. left: 0,
  12029. zIndex: 9e5
  12030. });
  12031. var hitElement = doc.elementFromPoint(6, 6);
  12032. hasInternalReferenceBug =
  12033. (hitElement && hitElement.id) === 'hitme';
  12034. doc.body.removeChild(svg);
  12035. }
  12036. if (hasInternalReferenceBug) {
  12037. return win.location.href
  12038. .split('#')[0] // remove the hash
  12039. .replace(/<[^>]*>/g, '') // wing cut HTML
  12040. // escape parantheses and quotes
  12041. .replace(/([\('\)])/g, '\\$1')
  12042. // replace spaces (needed for Safari only)
  12043. .replace(/ /g, '%20');
  12044. }
  12045. }
  12046. return '';
  12047. };
  12048. /**
  12049. * Get the global style setting for the renderer.
  12050. *
  12051. * @private
  12052. * @function Highcharts.SVGRenderer#getStyle
  12053. *
  12054. * @param {Highcharts.CSSObject} style
  12055. * Style settings.
  12056. *
  12057. * @return {Highcharts.CSSObject}
  12058. * The style settings mixed with defaults.
  12059. */
  12060. SVGRenderer.prototype.getStyle = function (style) {
  12061. this.style = extend({
  12062. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  12063. 'Arial, Helvetica, sans-serif',
  12064. fontSize: '12px'
  12065. }, style);
  12066. return this.style;
  12067. };
  12068. /**
  12069. * Apply the global style on the renderer, mixed with the default styles.
  12070. *
  12071. * @function Highcharts.SVGRenderer#setStyle
  12072. *
  12073. * @param {Highcharts.CSSObject} style
  12074. * CSS to apply.
  12075. */
  12076. SVGRenderer.prototype.setStyle = function (style) {
  12077. this.boxWrapper.css(this.getStyle(style));
  12078. };
  12079. /**
  12080. * Detect whether the renderer is hidden. This happens when one of the
  12081. * parent elements has `display: none`. Used internally to detect when we
  12082. * needto render preliminarily in another div to get the text bounding boxes
  12083. * right.
  12084. *
  12085. * @function Highcharts.SVGRenderer#isHidden
  12086. *
  12087. * @return {boolean}
  12088. * True if it is hidden.
  12089. */
  12090. SVGRenderer.prototype.isHidden = function () {
  12091. return !this.boxWrapper.getBBox().width;
  12092. };
  12093. /**
  12094. * Destroys the renderer and its allocated members.
  12095. *
  12096. * @function Highcharts.SVGRenderer#destroy
  12097. *
  12098. * @return {null}
  12099. */
  12100. SVGRenderer.prototype.destroy = function () {
  12101. var renderer = this,
  12102. rendererDefs = renderer.defs;
  12103. renderer.box = null;
  12104. renderer.boxWrapper = renderer.boxWrapper.destroy();
  12105. // Call destroy on all gradient elements
  12106. destroyObjectProperties(renderer.gradients || {});
  12107. renderer.gradients = null;
  12108. // Defs are null in VMLRenderer
  12109. // Otherwise, destroy them here.
  12110. if (rendererDefs) {
  12111. renderer.defs = rendererDefs.destroy();
  12112. }
  12113. // Remove sub pixel fix handler (#982)
  12114. if (renderer.unSubPixelFix) {
  12115. renderer.unSubPixelFix();
  12116. }
  12117. renderer.alignedObjects = null;
  12118. return null;
  12119. };
  12120. /**
  12121. * Create a wrapper for an SVG element. Serves as a factory for
  12122. * {@link SVGElement}, but this function is itself mostly called from
  12123. * primitive factories like {@link SVGRenderer#path}, {@link
  12124. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  12125. *
  12126. * @function Highcharts.SVGRenderer#createElement
  12127. *
  12128. * @param {string} nodeName
  12129. * The node name, for example `rect`, `g` etc.
  12130. *
  12131. * @return {Highcharts.SVGElement}
  12132. * The generated SVGElement.
  12133. */
  12134. SVGRenderer.prototype.createElement = function (nodeName) {
  12135. var wrapper = new this.Element();
  12136. wrapper.init(this, nodeName);
  12137. return wrapper;
  12138. };
  12139. /**
  12140. * Get converted radial gradient attributes according to the radial
  12141. * reference. Used internally from the {@link SVGElement#colorGradient}
  12142. * function.
  12143. *
  12144. * @private
  12145. * @function Highcharts.SVGRenderer#getRadialAttr
  12146. */
  12147. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  12148. return {
  12149. cx: (radialReference[0] - radialReference[2] / 2) +
  12150. (gradAttr.cx || 0) * radialReference[2],
  12151. cy: (radialReference[1] - radialReference[2] / 2) +
  12152. (gradAttr.cy || 0) * radialReference[2],
  12153. r: (gradAttr.r || 0) * radialReference[2]
  12154. };
  12155. };
  12156. /**
  12157. * Parse a simple HTML string into SVG tspans. Called internally when text
  12158. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  12159. * text features like `width`, `text-overflow`, `white-space`, and also
  12160. * attributes like `href` and `style`.
  12161. *
  12162. * @private
  12163. * @function Highcharts.SVGRenderer#buildText
  12164. *
  12165. * @param {Highcharts.SVGElement} wrapper
  12166. * The parent SVGElement.
  12167. */
  12168. SVGRenderer.prototype.buildText = function (wrapper) {
  12169. new TextBuilder(wrapper).buildSVG();
  12170. };
  12171. /**
  12172. * Returns white for dark colors and black for bright colors.
  12173. *
  12174. * @function Highcharts.SVGRenderer#getContrast
  12175. *
  12176. * @param {Highcharts.ColorString} rgba
  12177. * The color to get the contrast for.
  12178. *
  12179. * @return {Highcharts.ColorString}
  12180. * The contrast color, either `#000000` or `#FFFFFF`.
  12181. */
  12182. SVGRenderer.prototype.getContrast = function (rgba) {
  12183. rgba = Color.parse(rgba).rgba;
  12184. // The threshold may be discussed. Here's a proposal for adding
  12185. // different weight to the color channels (#6216)
  12186. rgba[0] *= 1; // red
  12187. rgba[1] *= 1.2; // green
  12188. rgba[2] *= 0.5; // blue
  12189. return rgba[0] + rgba[1] + rgba[2] >
  12190. 1.8 * 255 ?
  12191. '#000000' :
  12192. '#FFFFFF';
  12193. };
  12194. /**
  12195. * Create a button with preset states.
  12196. *
  12197. * @function Highcharts.SVGRenderer#button
  12198. *
  12199. * @param {string} text
  12200. * The text or HTML to draw.
  12201. *
  12202. * @param {number} x
  12203. * The x position of the button's left side.
  12204. *
  12205. * @param {number} y
  12206. * The y position of the button's top side.
  12207. *
  12208. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  12209. * The function to execute on button click or touch.
  12210. *
  12211. * @param {Highcharts.SVGAttributes} [theme]
  12212. * SVG attributes for the normal state.
  12213. *
  12214. * @param {Highcharts.SVGAttributes} [hoverState]
  12215. * SVG attributes for the hover state.
  12216. *
  12217. * @param {Highcharts.SVGAttributes} [pressedState]
  12218. * SVG attributes for the pressed state.
  12219. *
  12220. * @param {Highcharts.SVGAttributes} [disabledState]
  12221. * SVG attributes for the disabled state.
  12222. *
  12223. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  12224. * The shape type.
  12225. *
  12226. * @param {boolean} [useHTML=false]
  12227. * Wether to use HTML to render the label.
  12228. *
  12229. * @return {Highcharts.SVGElement}
  12230. * The button element.
  12231. */
  12232. SVGRenderer.prototype.button = function (text, x, y, callback, theme, hoverState, pressedState, disabledState, shape, useHTML) {
  12233. var label = this.label(text,
  12234. x,
  12235. y,
  12236. shape,
  12237. void 0,
  12238. void 0,
  12239. useHTML,
  12240. void 0, 'button'),
  12241. curState = 0,
  12242. styledMode = this.styledMode,
  12243. // Make a copy of normalState (#13798)
  12244. // (reference to options.rangeSelector.buttonTheme)
  12245. normalState = theme ? merge(theme) : {},
  12246. userNormalStyle = normalState && normalState.style || {};
  12247. // Remove stylable attributes
  12248. normalState = AST.filterUserAttributes(normalState);
  12249. // Default, non-stylable attributes
  12250. label.attr(merge({ padding: 8, r: 2 }, normalState));
  12251. // Presentational
  12252. var normalStyle,
  12253. hoverStyle,
  12254. pressedStyle,
  12255. disabledStyle;
  12256. if (!styledMode) {
  12257. // Normal state - prepare the attributes
  12258. normalState = merge({
  12259. fill: palette.neutralColor3,
  12260. stroke: palette.neutralColor20,
  12261. 'stroke-width': 1,
  12262. style: {
  12263. color: palette.neutralColor80,
  12264. cursor: 'pointer',
  12265. fontWeight: 'normal'
  12266. }
  12267. }, {
  12268. style: userNormalStyle
  12269. }, normalState);
  12270. normalStyle = normalState.style;
  12271. delete normalState.style;
  12272. // Hover state
  12273. hoverState = merge(normalState, {
  12274. fill: palette.neutralColor10
  12275. }, AST.filterUserAttributes(hoverState || {}));
  12276. hoverStyle = hoverState.style;
  12277. delete hoverState.style;
  12278. // Pressed state
  12279. pressedState = merge(normalState, {
  12280. fill: palette.highlightColor10,
  12281. style: {
  12282. color: palette.neutralColor100,
  12283. fontWeight: 'bold'
  12284. }
  12285. }, AST.filterUserAttributes(pressedState || {}));
  12286. pressedStyle = pressedState.style;
  12287. delete pressedState.style;
  12288. // Disabled state
  12289. disabledState = merge(normalState, {
  12290. style: {
  12291. color: palette.neutralColor20
  12292. }
  12293. }, AST.filterUserAttributes(disabledState || {}));
  12294. disabledStyle = disabledState.style;
  12295. delete disabledState.style;
  12296. }
  12297. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  12298. // (#667).
  12299. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  12300. if (curState !== 3) {
  12301. label.setState(1);
  12302. }
  12303. });
  12304. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  12305. if (curState !== 3) {
  12306. label.setState(curState);
  12307. }
  12308. });
  12309. label.setState = function (state) {
  12310. // Hover state is temporary, don't record it
  12311. if (state !== 1) {
  12312. label.state = curState = state;
  12313. }
  12314. // Update visuals
  12315. label
  12316. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  12317. .addClass('highcharts-button-' +
  12318. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  12319. if (!styledMode) {
  12320. label
  12321. .attr([
  12322. normalState,
  12323. hoverState,
  12324. pressedState,
  12325. disabledState
  12326. ][state || 0])
  12327. .css([
  12328. normalStyle,
  12329. hoverStyle,
  12330. pressedStyle,
  12331. disabledStyle
  12332. ][state || 0]);
  12333. }
  12334. };
  12335. // Presentational attributes
  12336. if (!styledMode) {
  12337. label
  12338. .attr(normalState)
  12339. .css(extend({ cursor: 'default' }, normalStyle));
  12340. }
  12341. return label
  12342. .on('touchstart', function (e) { return e.stopPropagation(); })
  12343. .on('click', function (e) {
  12344. if (curState !== 3) {
  12345. callback.call(label, e);
  12346. }
  12347. });
  12348. };
  12349. /**
  12350. * Make a straight line crisper by not spilling out to neighbour pixels.
  12351. *
  12352. * @function Highcharts.SVGRenderer#crispLine
  12353. *
  12354. * @param {Highcharts.SVGPathArray} points
  12355. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  12356. *
  12357. * @param {number} width
  12358. * The width of the line.
  12359. *
  12360. * @param {string} roundingFunction
  12361. * The rounding function name on the `Math` object, can be one of
  12362. * `round`, `floor` or `ceil`.
  12363. *
  12364. * @return {Highcharts.SVGPathArray}
  12365. * The original points array, but modified to render crisply.
  12366. */
  12367. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  12368. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  12369. var start = points[0];
  12370. var end = points[1];
  12371. // Normalize to a crisp line
  12372. if (start[1] === end[1]) {
  12373. // Substract due to #1129. Now bottom and left axis gridlines behave
  12374. // the same.
  12375. start[1] = end[1] =
  12376. Math[roundingFunction](start[1]) - (width % 2 / 2);
  12377. }
  12378. if (start[2] === end[2]) {
  12379. start[2] = end[2] =
  12380. Math[roundingFunction](start[2]) + (width % 2 / 2);
  12381. }
  12382. return points;
  12383. };
  12384. /**
  12385. * Draw a path, wraps the SVG `path` element.
  12386. *
  12387. * @sample highcharts/members/renderer-path-on-chart/
  12388. * Draw a path in a chart
  12389. * @sample highcharts/members/renderer-path/
  12390. * Draw a path independent from a chart
  12391. *
  12392. * @example
  12393. * let path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  12394. * .attr({ stroke: '#ff00ff' })
  12395. * .add();
  12396. *
  12397. * @function Highcharts.SVGRenderer#path
  12398. *
  12399. * @param {Highcharts.SVGPathArray} [path]
  12400. * An SVG path definition in array form.
  12401. *
  12402. * @return {Highcharts.SVGElement}
  12403. * The generated wrapper element.
  12404. *
  12405. */ /**
  12406. * Draw a path, wraps the SVG `path` element.
  12407. *
  12408. * @function Highcharts.SVGRenderer#path
  12409. *
  12410. * @param {Highcharts.SVGAttributes} [attribs]
  12411. * The initial attributes.
  12412. *
  12413. * @return {Highcharts.SVGElement}
  12414. * The generated wrapper element.
  12415. */
  12416. SVGRenderer.prototype.path = function (path) {
  12417. var attribs = (this.styledMode ? {} : {
  12418. fill: 'none'
  12419. });
  12420. if (isArray(path)) {
  12421. attribs.d = path;
  12422. }
  12423. else if (isObject(path)) { // attributes
  12424. extend(attribs, path);
  12425. }
  12426. return this.createElement('path').attr(attribs);
  12427. };
  12428. /**
  12429. * Draw a circle, wraps the SVG `circle` element.
  12430. *
  12431. * @sample highcharts/members/renderer-circle/
  12432. * Drawing a circle
  12433. *
  12434. * @function Highcharts.SVGRenderer#circle
  12435. *
  12436. * @param {number} [x]
  12437. * The center x position.
  12438. *
  12439. * @param {number} [y]
  12440. * The center y position.
  12441. *
  12442. * @param {number} [r]
  12443. * The radius.
  12444. *
  12445. * @return {Highcharts.SVGElement}
  12446. * The generated wrapper element.
  12447. */ /**
  12448. * Draw a circle, wraps the SVG `circle` element.
  12449. *
  12450. * @function Highcharts.SVGRenderer#circle
  12451. *
  12452. * @param {Highcharts.SVGAttributes} [attribs]
  12453. * The initial attributes.
  12454. *
  12455. * @return {Highcharts.SVGElement}
  12456. * The generated wrapper element.
  12457. */
  12458. SVGRenderer.prototype.circle = function (x, y, r) {
  12459. var attribs = (isObject(x) ?
  12460. x :
  12461. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  12462. // Setting x or y translates to cx and cy
  12463. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  12464. element.setAttribute('c' + key, value);
  12465. };
  12466. return wrapper.attr(attribs);
  12467. };
  12468. /**
  12469. * Draw and return an arc.
  12470. *
  12471. * @sample highcharts/members/renderer-arc/
  12472. * Drawing an arc
  12473. *
  12474. * @function Highcharts.SVGRenderer#arc
  12475. *
  12476. * @param {number} [x=0]
  12477. * Center X position.
  12478. *
  12479. * @param {number} [y=0]
  12480. * Center Y position.
  12481. *
  12482. * @param {number} [r=0]
  12483. * The outer radius' of the arc.
  12484. *
  12485. * @param {number} [innerR=0]
  12486. * Inner radius like used in donut charts.
  12487. *
  12488. * @param {number} [start=0]
  12489. * The starting angle of the arc in radians, where 0 is to the right and
  12490. * `-Math.PI/2` is up.
  12491. *
  12492. * @param {number} [end=0]
  12493. * The ending angle of the arc in radians, where 0 is to the right and
  12494. * `-Math.PI/2` is up.
  12495. *
  12496. * @return {Highcharts.SVGElement}
  12497. * The generated wrapper element.
  12498. */ /**
  12499. * Draw and return an arc. Overloaded function that takes arguments object.
  12500. *
  12501. * @function Highcharts.SVGRenderer#arc
  12502. *
  12503. * @param {Highcharts.SVGAttributes} attribs
  12504. * Initial SVG attributes.
  12505. *
  12506. * @return {Highcharts.SVGElement}
  12507. * The generated wrapper element.
  12508. */
  12509. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  12510. var arc,
  12511. options;
  12512. if (isObject(x)) {
  12513. options = x;
  12514. y = options.y;
  12515. r = options.r;
  12516. innerR = options.innerR;
  12517. start = options.start;
  12518. end = options.end;
  12519. x = options.x;
  12520. }
  12521. else {
  12522. options = {
  12523. innerR: innerR,
  12524. start: start,
  12525. end: end
  12526. };
  12527. }
  12528. // Arcs are defined as symbols for the ability to set
  12529. // attributes in attr and animate
  12530. arc = this.symbol('arc', x, y, r, r, options);
  12531. arc.r = r; // #959
  12532. return arc;
  12533. };
  12534. /**
  12535. * Draw and return a rectangle.
  12536. *
  12537. * @function Highcharts.SVGRenderer#rect
  12538. *
  12539. * @param {number} [x]
  12540. * Left position.
  12541. *
  12542. * @param {number} [y]
  12543. * Top position.
  12544. *
  12545. * @param {number} [width]
  12546. * Width of the rectangle.
  12547. *
  12548. * @param {number} [height]
  12549. * Height of the rectangle.
  12550. *
  12551. * @param {number} [r]
  12552. * Border corner radius.
  12553. *
  12554. * @param {number} [strokeWidth]
  12555. * A stroke width can be supplied to allow crisp drawing.
  12556. *
  12557. * @return {Highcharts.SVGElement}
  12558. * The generated wrapper element.
  12559. */ /**
  12560. * Draw and return a rectangle.
  12561. *
  12562. * @sample highcharts/members/renderer-rect-on-chart/
  12563. * Draw a rectangle in a chart
  12564. * @sample highcharts/members/renderer-rect/
  12565. * Draw a rectangle independent from a chart
  12566. *
  12567. * @function Highcharts.SVGRenderer#rect
  12568. *
  12569. * @param {Highcharts.SVGAttributes} [attributes]
  12570. * General SVG attributes for the rectangle.
  12571. *
  12572. * @return {Highcharts.SVGElement}
  12573. * The generated wrapper element.
  12574. */
  12575. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  12576. r = isObject(x) ? x.r : r;
  12577. var wrapper = this.createElement('rect'),
  12578. attribs = isObject(x) ?
  12579. x :
  12580. typeof x === 'undefined' ?
  12581. {} :
  12582. {
  12583. x: x,
  12584. y: y,
  12585. width: Math.max(width, 0),
  12586. height: Math.max(height, 0)
  12587. };
  12588. if (!this.styledMode) {
  12589. if (typeof strokeWidth !== 'undefined') {
  12590. attribs['stroke-width'] = strokeWidth;
  12591. attribs = wrapper.crisp(attribs);
  12592. }
  12593. attribs.fill = 'none';
  12594. }
  12595. if (r) {
  12596. attribs.r = r;
  12597. }
  12598. wrapper.rSetter = function (value, key, element) {
  12599. wrapper.r = value;
  12600. attr(element, {
  12601. rx: value,
  12602. ry: value
  12603. });
  12604. };
  12605. wrapper.rGetter = function () {
  12606. return wrapper.r || 0;
  12607. };
  12608. return wrapper.attr(attribs);
  12609. };
  12610. /**
  12611. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  12612. * elements.
  12613. *
  12614. * @sample highcharts/members/renderer-g/
  12615. * Show and hide grouped objects
  12616. *
  12617. * @function Highcharts.SVGRenderer#setSize
  12618. *
  12619. * @param {number} width
  12620. * The new pixel width.
  12621. *
  12622. * @param {number} height
  12623. * The new pixel height.
  12624. *
  12625. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  12626. * Whether and how to animate.
  12627. */
  12628. SVGRenderer.prototype.setSize = function (width, height, animate) {
  12629. var renderer = this;
  12630. renderer.width = width;
  12631. renderer.height = height;
  12632. renderer.boxWrapper.animate({
  12633. width: width,
  12634. height: height
  12635. }, {
  12636. step: function () {
  12637. this.attr({
  12638. viewBox: '0 0 ' + this.attr('width') + ' ' +
  12639. this.attr('height')
  12640. });
  12641. },
  12642. duration: pick(animate, true) ? void 0 : 0
  12643. });
  12644. renderer.alignElements();
  12645. };
  12646. /**
  12647. * Create and return an svg group element. Child
  12648. * {@link Highcharts.SVGElement} objects are added to the group by using the
  12649. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  12650. *
  12651. * @function Highcharts.SVGRenderer#g
  12652. *
  12653. * @param {string} [name]
  12654. * The group will be given a class name of `highcharts-{name}`. This
  12655. * can be used for styling and scripting.
  12656. *
  12657. * @return {Highcharts.SVGElement}
  12658. * The generated wrapper element.
  12659. */
  12660. SVGRenderer.prototype.g = function (name) {
  12661. var elem = this.createElement('g');
  12662. return name ?
  12663. elem.attr({ 'class': 'highcharts-' + name }) :
  12664. elem;
  12665. };
  12666. /**
  12667. * Display an image.
  12668. *
  12669. * @sample highcharts/members/renderer-image-on-chart/
  12670. * Add an image in a chart
  12671. * @sample highcharts/members/renderer-image/
  12672. * Add an image independent of a chart
  12673. *
  12674. * @function Highcharts.SVGRenderer#image
  12675. *
  12676. * @param {string} src
  12677. * The image source.
  12678. *
  12679. * @param {number} [x]
  12680. * The X position.
  12681. *
  12682. * @param {number} [y]
  12683. * The Y position.
  12684. *
  12685. * @param {number} [width]
  12686. * The image width. If omitted, it defaults to the image file width.
  12687. *
  12688. * @param {number} [height]
  12689. * The image height. If omitted it defaults to the image file
  12690. * height.
  12691. *
  12692. * @param {Function} [onload]
  12693. * Event handler for image load.
  12694. *
  12695. * @return {Highcharts.SVGElement}
  12696. * The generated wrapper element.
  12697. */
  12698. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  12699. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  12700. // Set the href in the xlink namespace
  12701. if (el.setAttributeNS) {
  12702. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  12703. }
  12704. else {
  12705. // could be exporting in IE
  12706. // using href throws "not supported" in ie7 and under,
  12707. // requries regex shim to fix later
  12708. el.setAttribute('hc-svg-href', src);
  12709. }
  12710. }, onDummyLoad = function (e) {
  12711. setSVGImageSource(elemWrapper.element, src);
  12712. onload.call(elemWrapper, e);
  12713. };
  12714. // optional properties
  12715. if (arguments.length > 1) {
  12716. extend(attribs, {
  12717. x: x,
  12718. y: y,
  12719. width: width,
  12720. height: height
  12721. });
  12722. }
  12723. elemWrapper = this.createElement('image').attr(attribs);
  12724. // Add load event if supplied
  12725. if (onload) {
  12726. // We have to use a dummy HTML image since IE support for SVG image
  12727. // load events is very buggy. First set a transparent src, wait for
  12728. // dummy to load, and then add the real src to the SVG image.
  12729. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  12730. dummy = new win.Image();
  12731. addEvent(dummy, 'load', onDummyLoad);
  12732. dummy.src = src;
  12733. if (dummy.complete) {
  12734. onDummyLoad({});
  12735. }
  12736. }
  12737. else {
  12738. setSVGImageSource(elemWrapper.element, src);
  12739. }
  12740. return elemWrapper;
  12741. };
  12742. /**
  12743. * Draw a symbol out of pre-defined shape paths from
  12744. * {@link SVGRenderer#symbols}.
  12745. * It is used in Highcharts for point makers, which cake a `symbol` option,
  12746. * and label and button backgrounds like in the tooltip and stock flags.
  12747. *
  12748. * @function Highcharts.SVGRenderer#symbol
  12749. *
  12750. * @param {string} symbol
  12751. * The symbol name.
  12752. *
  12753. * @param {number} [x]
  12754. * The X coordinate for the top left position.
  12755. *
  12756. * @param {number} [y]
  12757. * The Y coordinate for the top left position.
  12758. *
  12759. * @param {number} [width]
  12760. * The pixel width.
  12761. *
  12762. * @param {number} [height]
  12763. * The pixel height.
  12764. *
  12765. * @param {Highcharts.SymbolOptionsObject} [options]
  12766. * Additional options, depending on the actual symbol drawn.
  12767. *
  12768. * @return {Highcharts.SVGElement}
  12769. */
  12770. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  12771. var ren = this,
  12772. obj,
  12773. imageRegex = /^url\((.*?)\)$/,
  12774. isImage = imageRegex.test(symbol),
  12775. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  12776. // get the symbol definition function
  12777. symbolFn = (sym && this.symbols[sym]),
  12778. path,
  12779. imageSrc,
  12780. centerImage;
  12781. if (symbolFn) {
  12782. // Check if there's a path defined for this symbol
  12783. if (typeof x === 'number') {
  12784. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  12785. }
  12786. obj = this.path(path);
  12787. if (!ren.styledMode) {
  12788. obj.attr('fill', 'none');
  12789. }
  12790. // expando properties for use in animate and attr
  12791. extend(obj, {
  12792. symbolName: sym,
  12793. x: x,
  12794. y: y,
  12795. width: width,
  12796. height: height
  12797. });
  12798. if (options) {
  12799. extend(obj, options);
  12800. }
  12801. // Image symbols
  12802. }
  12803. else if (isImage) {
  12804. imageSrc = symbol.match(imageRegex)[1];
  12805. // Create the image synchronously, add attribs async
  12806. obj = this.image(imageSrc);
  12807. // The image width is not always the same as the symbol width. The
  12808. // image may be centered within the symbol, as is the case when
  12809. // image shapes are used as label backgrounds, for example in flags.
  12810. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  12811. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  12812. /**
  12813. * Set the size and position
  12814. */
  12815. centerImage = function () {
  12816. obj.attr({
  12817. width: obj.width,
  12818. height: obj.height
  12819. });
  12820. };
  12821. /**
  12822. * Width and height setters that take both the image's physical size
  12823. * and the label size into consideration, and translates the image
  12824. * to center within the label.
  12825. */
  12826. ['width', 'height'].forEach(function (key) {
  12827. obj[key + 'Setter'] = function (value, key) {
  12828. var imgSize = this['img' + key];
  12829. this[key] = value;
  12830. if (defined(imgSize)) {
  12831. // Scale and center the image within its container.
  12832. // The name `backgroundSize` is taken from the CSS spec,
  12833. // but the value `within` is made up. Other possible
  12834. // values in the spec, `cover` and `contain`, can be
  12835. // implemented if needed.
  12836. if (options &&
  12837. options.backgroundSize === 'within' &&
  12838. this.width &&
  12839. this.height) {
  12840. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  12841. }
  12842. if (this.element) {
  12843. this.element.setAttribute(key, imgSize);
  12844. }
  12845. if (!this.alignByTranslate) {
  12846. var translate = ((this[key] || 0) - imgSize) / 2;
  12847. var attribs = key === 'width' ?
  12848. { translateX: translate } :
  12849. { translateY: translate };
  12850. this.attr(attribs);
  12851. }
  12852. }
  12853. };
  12854. });
  12855. if (defined(x)) {
  12856. obj.attr({
  12857. x: x,
  12858. y: y
  12859. });
  12860. }
  12861. obj.isImg = true;
  12862. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  12863. centerImage();
  12864. }
  12865. else {
  12866. // Initialize image to be 0 size so export will still function
  12867. // if there's no cached sizes.
  12868. obj.attr({ width: 0, height: 0 });
  12869. // Create a dummy JavaScript image to get the width and height.
  12870. createElement('img', {
  12871. onload: function () {
  12872. var chart = charts[ren.chartIndex];
  12873. // Special case for SVGs on IE11, the width is not
  12874. // accessible until the image is part of the DOM
  12875. // (#2854).
  12876. if (this.width === 0) {
  12877. css(this, {
  12878. position: 'absolute',
  12879. top: '-999em'
  12880. });
  12881. doc.body.appendChild(this);
  12882. }
  12883. // Center the image
  12884. symbolSizes[imageSrc] = {
  12885. width: this.width,
  12886. height: this.height
  12887. };
  12888. obj.imgwidth = this.width;
  12889. obj.imgheight = this.height;
  12890. if (obj.element) {
  12891. centerImage();
  12892. }
  12893. // Clean up after #2854 workaround.
  12894. if (this.parentNode) {
  12895. this.parentNode.removeChild(this);
  12896. }
  12897. // Fire the load event when all external images are
  12898. // loaded
  12899. ren.imgCount--;
  12900. if (!ren.imgCount && chart && !chart.hasLoaded) {
  12901. chart.onload();
  12902. }
  12903. },
  12904. src: imageSrc
  12905. });
  12906. this.imgCount++;
  12907. }
  12908. }
  12909. return obj;
  12910. };
  12911. /**
  12912. * Define a clipping rectangle. The clipping rectangle is later applied
  12913. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  12914. * function.
  12915. *
  12916. * @example
  12917. * let circle = renderer.circle(100, 100, 100)
  12918. * .attr({ fill: 'red' })
  12919. * .add();
  12920. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  12921. *
  12922. * // Leave only the lower right quarter visible
  12923. * circle.clip(clipRect);
  12924. *
  12925. * @function Highcharts.SVGRenderer#clipRect
  12926. *
  12927. * @param {number} [x]
  12928. *
  12929. * @param {number} [y]
  12930. *
  12931. * @param {number} [width]
  12932. *
  12933. * @param {number} [height]
  12934. *
  12935. * @return {Highcharts.ClipRectElement}
  12936. * A clipping rectangle.
  12937. */
  12938. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  12939. var wrapper,
  12940. // Add a hyphen at the end to avoid confusion in testing indexes
  12941. // -1 and -10, -11 etc (#6550)
  12942. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  12943. id: id
  12944. }).add(this.defs);
  12945. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  12946. wrapper.id = id;
  12947. wrapper.clipPath = clipPath;
  12948. wrapper.count = 0;
  12949. return wrapper;
  12950. };
  12951. /**
  12952. * Draw text. The text can contain a subset of HTML, like spans and anchors
  12953. * and some basic text styling of these. For more advanced features like
  12954. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  12955. * To update the text after render, run `text.attr({ text: 'New text' })`.
  12956. *
  12957. * @sample highcharts/members/renderer-text-on-chart/
  12958. * Annotate the chart freely
  12959. * @sample highcharts/members/renderer-on-chart/
  12960. * Annotate with a border and in response to the data
  12961. * @sample highcharts/members/renderer-text/
  12962. * Formatted text
  12963. *
  12964. * @function Highcharts.SVGRenderer#text
  12965. *
  12966. * @param {string} [str]
  12967. * The text of (subset) HTML to draw.
  12968. *
  12969. * @param {number} [x]
  12970. * The x position of the text's lower left corner.
  12971. *
  12972. * @param {number} [y]
  12973. * The y position of the text's lower left corner.
  12974. *
  12975. * @param {boolean} [useHTML=false]
  12976. * Use HTML to render the text.
  12977. *
  12978. * @return {Highcharts.SVGElement}
  12979. * The text object.
  12980. */
  12981. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  12982. // declare variables
  12983. var renderer = this,
  12984. wrapper,
  12985. attribs = {};
  12986. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  12987. return renderer.html(str, x, y);
  12988. }
  12989. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  12990. if (y) {
  12991. attribs.y = Math.round(y);
  12992. }
  12993. if (defined(str)) {
  12994. attribs.text = str;
  12995. }
  12996. wrapper = renderer.createElement('text')
  12997. .attr(attribs);
  12998. if (!useHTML) {
  12999. wrapper.xSetter = function (value, key, element) {
  13000. var tspans = element.getElementsByTagName('tspan'),
  13001. tspan,
  13002. parentVal = element.getAttribute(key),
  13003. i;
  13004. for (i = 0; i < tspans.length; i++) {
  13005. tspan = tspans[i];
  13006. // If the x values are equal, the tspan represents a
  13007. // linebreak
  13008. if (tspan.getAttribute(key) === parentVal) {
  13009. tspan.setAttribute(key, value);
  13010. }
  13011. }
  13012. element.setAttribute(key, value);
  13013. };
  13014. }
  13015. return wrapper;
  13016. };
  13017. /**
  13018. * Utility to return the baseline offset and total line height from the font
  13019. * size.
  13020. *
  13021. * @function Highcharts.SVGRenderer#fontMetrics
  13022. *
  13023. * @param {number|string} [fontSize]
  13024. * The current font size to inspect. If not given, the font size
  13025. * will be found from the DOM element.
  13026. *
  13027. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  13028. * The element to inspect for a current font size.
  13029. *
  13030. * @return {Highcharts.FontMetricsObject}
  13031. * The font metrics.
  13032. */
  13033. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  13034. var lineHeight,
  13035. baseline;
  13036. if ((this.styledMode || !/px/.test(fontSize)) &&
  13037. win.getComputedStyle // old IE doesn't support it
  13038. ) {
  13039. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  13040. }
  13041. else {
  13042. fontSize = fontSize ||
  13043. // When the elem is a DOM element (#5932)
  13044. (elem && elem.style && elem.style.fontSize) ||
  13045. // Fall back on the renderer style default
  13046. (this.style && this.style.fontSize);
  13047. }
  13048. // Handle different units
  13049. if (/px/.test(fontSize)) {
  13050. fontSize = pInt(fontSize);
  13051. }
  13052. else {
  13053. fontSize = 12;
  13054. }
  13055. // Empirical values found by comparing font size and bounding box
  13056. // height. Applies to the default font family.
  13057. // https://jsfiddle.net/highcharts/7xvn7/
  13058. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  13059. baseline = Math.round(lineHeight * 0.8);
  13060. return {
  13061. h: lineHeight,
  13062. b: baseline,
  13063. f: fontSize
  13064. };
  13065. };
  13066. /**
  13067. * Correct X and Y positioning of a label for rotation (#1764).
  13068. *
  13069. * @private
  13070. * @function Highcharts.SVGRenderer#rotCorr
  13071. *
  13072. * @param {number} baseline
  13073. *
  13074. * @param {number} rotation
  13075. *
  13076. * @param {boolean} [alterY]
  13077. *
  13078. * @param {Highcharts.PositionObject}
  13079. */
  13080. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  13081. var y = baseline;
  13082. if (rotation && alterY) {
  13083. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  13084. }
  13085. return {
  13086. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  13087. y: y
  13088. };
  13089. };
  13090. /**
  13091. * Compatibility function to convert the legacy one-dimensional path array
  13092. * into an array of segments.
  13093. *
  13094. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  13095. * to support legacy paths from demos.
  13096. *
  13097. * @private
  13098. * @function Highcharts.SVGRenderer#pathToSegments
  13099. */
  13100. SVGRenderer.prototype.pathToSegments = function (path) {
  13101. var ret = [];
  13102. var segment = [];
  13103. var commandLength = {
  13104. A: 8,
  13105. C: 7,
  13106. H: 2,
  13107. L: 3,
  13108. M: 3,
  13109. Q: 5,
  13110. S: 5,
  13111. T: 3,
  13112. V: 2
  13113. };
  13114. // Short, non-typesafe parsing of the one-dimensional array. It splits
  13115. // the path on any string. This is not type checked against the tuple
  13116. // types, but is shorter, and doesn't require specific checks for any
  13117. // command type in SVG.
  13118. for (var i = 0; i < path.length; i++) {
  13119. // Command skipped, repeat previous or insert L/l for M/m
  13120. if (isString(segment[0]) &&
  13121. isNumber(path[i]) &&
  13122. segment.length === commandLength[(segment[0].toUpperCase())]) {
  13123. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  13124. }
  13125. // Split on string
  13126. if (typeof path[i] === 'string') {
  13127. if (segment.length) {
  13128. ret.push(segment.slice(0));
  13129. }
  13130. segment.length = 0;
  13131. }
  13132. segment.push(path[i]);
  13133. }
  13134. ret.push(segment.slice(0));
  13135. return ret;
  13136. /*
  13137. // Fully type-safe version where each tuple type is checked. The
  13138. // downside is filesize and a lack of flexibility for unsupported
  13139. // commands
  13140. const ret: SVGPath = [],
  13141. commands = {
  13142. A: 7,
  13143. C: 6,
  13144. H: 1,
  13145. L: 2,
  13146. M: 2,
  13147. Q: 4,
  13148. S: 4,
  13149. T: 2,
  13150. V: 1,
  13151. Z: 0
  13152. };
  13153. let i = 0,
  13154. lastI = 0,
  13155. lastCommand;
  13156. while (i < path.length) {
  13157. const item = path[i];
  13158. let command;
  13159. if (typeof item === 'string') {
  13160. command = item;
  13161. i += 1;
  13162. } else {
  13163. command = lastCommand || 'M';
  13164. }
  13165. // Upper case
  13166. const commandUC = command.toUpperCase();
  13167. if (commandUC in commands) {
  13168. // No numeric parameters
  13169. if (command === 'Z' || command === 'z') {
  13170. ret.push([command]);
  13171. // One numeric parameter
  13172. } else {
  13173. const val0 = path[i];
  13174. if (typeof val0 === 'number') {
  13175. // Horizontal line to
  13176. if (command === 'H' || command === 'h') {
  13177. ret.push([command, val0]);
  13178. i += 1;
  13179. // Vertical line to
  13180. } else if (command === 'V' || command === 'v') {
  13181. ret.push([command, val0]);
  13182. i += 1;
  13183. // Two numeric parameters
  13184. } else {
  13185. const val1 = path[i + 1];
  13186. if (typeof val1 === 'number') {
  13187. // lineTo
  13188. if (command === 'L' || command === 'l') {
  13189. ret.push([command, val0, val1]);
  13190. i += 2;
  13191. // moveTo
  13192. } else if (command === 'M' || command === 'm') {
  13193. ret.push([command, val0, val1]);
  13194. i += 2;
  13195. // Smooth quadratic bezier
  13196. } else if (command === 'T' || command === 't') {
  13197. ret.push([command, val0, val1]);
  13198. i += 2;
  13199. // Four numeric parameters
  13200. } else {
  13201. const val2 = path[i + 2],
  13202. val3 = path[i + 3];
  13203. if (
  13204. typeof val2 === 'number' &&
  13205. typeof val3 === 'number'
  13206. ) {
  13207. // Quadratic bezier to
  13208. if (
  13209. command === 'Q' ||
  13210. command === 'q'
  13211. ) {
  13212. ret.push([
  13213. command,
  13214. val0,
  13215. val1,
  13216. val2,
  13217. val3
  13218. ]);
  13219. i += 4;
  13220. // Smooth cubic bezier to
  13221. } else if (
  13222. command === 'S' ||
  13223. command === 's'
  13224. ) {
  13225. ret.push([
  13226. command,
  13227. val0,
  13228. val1,
  13229. val2,
  13230. val3
  13231. ]);
  13232. i += 4;
  13233. // Six numeric parameters
  13234. } else {
  13235. const val4 = path[i + 4],
  13236. val5 = path[i + 5];
  13237. if (
  13238. typeof val4 === 'number' &&
  13239. typeof val5 === 'number'
  13240. ) {
  13241. // Curve to
  13242. if (
  13243. command === 'C' ||
  13244. command === 'c'
  13245. ) {
  13246. ret.push([
  13247. command,
  13248. val0,
  13249. val1,
  13250. val2,
  13251. val3,
  13252. val4,
  13253. val5
  13254. ]);
  13255. i += 6;
  13256. // Seven numeric parameters
  13257. } else {
  13258. const val6 = path[i + 6];
  13259. // Arc to
  13260. if (
  13261. typeof val6 ===
  13262. 'number' &&
  13263. (
  13264. command === 'A' ||
  13265. command === 'a'
  13266. )
  13267. ) {
  13268. ret.push([
  13269. command,
  13270. val0,
  13271. val1,
  13272. val2,
  13273. val3,
  13274. val4,
  13275. val5,
  13276. val6
  13277. ]);
  13278. i += 7;
  13279. }
  13280. }
  13281. }
  13282. }
  13283. }
  13284. }
  13285. }
  13286. }
  13287. }
  13288. }
  13289. }
  13290. // An unmarked command following a moveTo is a lineTo
  13291. lastCommand = command === 'M' ? 'L' : command;
  13292. if (i === lastI) {
  13293. break;
  13294. }
  13295. lastI = i;
  13296. }
  13297. return ret;
  13298. */
  13299. };
  13300. /**
  13301. * Draw a label, which is an extended text element with support for border
  13302. * and background. Highcharts creates a `g` element with a text and a `path`
  13303. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  13304. * background are set through `stroke`, `stroke-width` and `fill` attributes
  13305. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  13306. * text after render, run `label.attr({ text: 'New text' })`.
  13307. *
  13308. * @sample highcharts/members/renderer-label-on-chart/
  13309. * A label on the chart
  13310. *
  13311. * @function Highcharts.SVGRenderer#label
  13312. *
  13313. * @param {string} str
  13314. * The initial text string or (subset) HTML to render.
  13315. *
  13316. * @param {number} x
  13317. * The x position of the label's left side.
  13318. *
  13319. * @param {number} [y]
  13320. * The y position of the label's top side or baseline, depending on
  13321. * the `baseline` parameter.
  13322. *
  13323. * @param {string} [shape='rect']
  13324. * The shape of the label's border/background, if any. Defaults to
  13325. * `rect`. Other possible values are `callout` or other shapes
  13326. * defined in {@link Highcharts.SVGRenderer#symbols}.
  13327. *
  13328. * @param {number} [anchorX]
  13329. * In case the `shape` has a pointer, like a flag, this is the
  13330. * coordinates it should be pinned to.
  13331. *
  13332. * @param {number} [anchorY]
  13333. * In case the `shape` has a pointer, like a flag, this is the
  13334. * coordinates it should be pinned to.
  13335. *
  13336. * @param {boolean} [useHTML=false]
  13337. * Wether to use HTML to render the label.
  13338. *
  13339. * @param {boolean} [baseline=false]
  13340. * Whether to position the label relative to the text baseline,
  13341. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  13342. * upper border of the rectangle.
  13343. *
  13344. * @param {string} [className]
  13345. * Class name for the group.
  13346. *
  13347. * @return {Highcharts.SVGElement}
  13348. * The generated label.
  13349. */
  13350. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  13351. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  13352. };
  13353. /**
  13354. * Re-align all aligned elements.
  13355. *
  13356. * @private
  13357. * @function Highcharts.SVGRenderer#alignElements
  13358. * @return {void}
  13359. */
  13360. SVGRenderer.prototype.alignElements = function () {
  13361. this.alignedObjects.forEach(function (el) { return el.align(); });
  13362. };
  13363. return SVGRenderer;
  13364. }());
  13365. /**
  13366. * A pointer to the renderer's associated Element class. The VMLRenderer
  13367. * will have a pointer to VMLElement here.
  13368. *
  13369. * @name Highcharts.SVGRenderer#Element
  13370. * @type {Highcharts.SVGElement}
  13371. */
  13372. SVGRenderer.prototype.Element = SVGElement;
  13373. /**
  13374. * @private
  13375. */
  13376. SVGRenderer.prototype.SVG_NS = SVG_NS;
  13377. /**
  13378. * Dummy function for plugins, called every time the renderer is updated.
  13379. * Prior to Highcharts 5, this was used for the canvg renderer.
  13380. *
  13381. * @deprecated
  13382. * @function Highcharts.SVGRenderer#draw
  13383. */
  13384. SVGRenderer.prototype.draw = noop;
  13385. /**
  13386. * A collection of characters mapped to HTML entities. When `useHTML` on an
  13387. * element is true, these entities will be rendered correctly by HTML. In
  13388. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  13389. * so for example `&lt;` will render as `<`.
  13390. *
  13391. * @example
  13392. * // Add support for unescaping quotes
  13393. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  13394. *
  13395. * @name Highcharts.SVGRenderer#escapes
  13396. * @type {Highcharts.Dictionary<string>}
  13397. */
  13398. SVGRenderer.prototype.escapes = {
  13399. '&': '&amp;',
  13400. '<': '&lt;',
  13401. '>': '&gt;',
  13402. "'": '&#39;',
  13403. '"': '&quot;'
  13404. };
  13405. var roundedRect = function (x,
  13406. y,
  13407. w,
  13408. h,
  13409. options) {
  13410. var r = (options && options.r) || 0;
  13411. return [
  13412. ['M', x + r, y],
  13413. ['L', x + w - r, y],
  13414. ['C', x + w, y, x + w, y, x + w, y + r],
  13415. ['L', x + w, y + h - r],
  13416. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  13417. ['L', x + r, y + h],
  13418. ['C', x, y + h, x, y + h, x, y + h - r],
  13419. ['L', x, y + r],
  13420. ['C', x, y, x, y, x + r, y] // top-left corner
  13421. ];
  13422. };
  13423. // #15291
  13424. var rect = function (x,
  13425. y,
  13426. w,
  13427. h,
  13428. options) {
  13429. if (options && options.r) {
  13430. return roundedRect(x,
  13431. y,
  13432. w,
  13433. h,
  13434. options);
  13435. }
  13436. return [
  13437. ['M', x, y],
  13438. ['L', x + w, y],
  13439. ['L', x + w, y + h],
  13440. ['L', x, y + h],
  13441. ['Z']
  13442. ];
  13443. };
  13444. /**
  13445. * An extendable collection of functions for defining symbol paths.
  13446. *
  13447. * @name Highcharts.SVGRenderer#symbols
  13448. * @type {Highcharts.SymbolDictionary}
  13449. */
  13450. SVGRenderer.prototype.symbols = {
  13451. circle: function (x, y, w, h) {
  13452. // Return a full arc
  13453. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  13454. start: Math.PI * 0.5,
  13455. end: Math.PI * 2.5,
  13456. open: false
  13457. });
  13458. },
  13459. rect: rect,
  13460. square: rect,
  13461. triangle: function (x, y, w, h) {
  13462. return [
  13463. ['M', x + w / 2, y],
  13464. ['L', x + w, y + h],
  13465. ['L', x, y + h],
  13466. ['Z']
  13467. ];
  13468. },
  13469. 'triangle-down': function (x, y, w, h) {
  13470. return [
  13471. ['M', x, y],
  13472. ['L', x + w, y],
  13473. ['L', x + w / 2, y + h],
  13474. ['Z']
  13475. ];
  13476. },
  13477. diamond: function (x, y, w, h) {
  13478. return [
  13479. ['M', x + w / 2, y],
  13480. ['L', x + w, y + h / 2],
  13481. ['L', x + w / 2, y + h],
  13482. ['L', x, y + h / 2],
  13483. ['Z']
  13484. ];
  13485. },
  13486. arc: function (x, y, w, h, options) {
  13487. var arc = [];
  13488. if (options) {
  13489. var start = options.start || 0,
  13490. rx = pick(options.r,
  13491. w),
  13492. ry = pick(options.r,
  13493. h || w),
  13494. proximity = 0.001,
  13495. fullCircle = (Math.abs((options.end || 0) - start - 2 * Math.PI) <
  13496. proximity),
  13497. // Substract a small number to prevent cos and sin of start and
  13498. // end from becoming equal on 360 arcs (related: #1561)
  13499. end = (options.end || 0) - proximity,
  13500. innerRadius = options.innerR,
  13501. open_1 = pick(options.open,
  13502. fullCircle),
  13503. cosStart = Math.cos(start),
  13504. sinStart = Math.sin(start),
  13505. cosEnd = Math.cos(end),
  13506. sinEnd = Math.sin(end),
  13507. // Proximity takes care of rounding errors around PI (#6971)
  13508. longArc = pick(options.longArc,
  13509. end - start - Math.PI < proximity ? 0 : 1);
  13510. arc.push([
  13511. 'M',
  13512. x + rx * cosStart,
  13513. y + ry * sinStart
  13514. ], [
  13515. 'A',
  13516. rx,
  13517. ry,
  13518. 0,
  13519. longArc,
  13520. pick(options.clockwise, 1),
  13521. x + rx * cosEnd,
  13522. y + ry * sinEnd
  13523. ]);
  13524. if (defined(innerRadius)) {
  13525. arc.push(open_1 ?
  13526. [
  13527. 'M',
  13528. x + innerRadius * cosEnd,
  13529. y + innerRadius * sinEnd
  13530. ] : [
  13531. 'L',
  13532. x + innerRadius * cosEnd,
  13533. y + innerRadius * sinEnd
  13534. ], [
  13535. 'A',
  13536. innerRadius,
  13537. innerRadius,
  13538. 0,
  13539. longArc,
  13540. // Clockwise - opposite to the outer arc clockwise
  13541. defined(options.clockwise) ? 1 - options.clockwise : 0,
  13542. x + innerRadius * cosStart,
  13543. y + innerRadius * sinStart
  13544. ]);
  13545. }
  13546. if (!open_1) {
  13547. arc.push(['Z']);
  13548. }
  13549. }
  13550. return arc;
  13551. },
  13552. /**
  13553. * Callout shape used for default tooltips, also used for rounded
  13554. * rectangles in VML
  13555. */
  13556. callout: function (x, y, w, h, options) {
  13557. var arrowLength = 6,
  13558. halfDistance = 6,
  13559. r = Math.min((options && options.r) || 0,
  13560. w,
  13561. h),
  13562. safeDistance = r + halfDistance,
  13563. anchorX = options && options.anchorX,
  13564. anchorY = options && options.anchorY || 0;
  13565. var path = roundedRect(x,
  13566. y,
  13567. w,
  13568. h, { r: r });
  13569. if (!isNumber(anchorX)) {
  13570. return path;
  13571. }
  13572. // Anchor on right side
  13573. if (x + anchorX >= w) {
  13574. // Chevron
  13575. if (anchorY > y + safeDistance &&
  13576. anchorY < y + h - safeDistance) {
  13577. path.splice(3, 1, ['L', x + w, anchorY - halfDistance], ['L', x + w + arrowLength, anchorY], ['L', x + w, anchorY + halfDistance], ['L', x + w, y + h - r]);
  13578. // Simple connector
  13579. }
  13580. else {
  13581. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  13582. }
  13583. // Anchor on left side
  13584. }
  13585. else if (x + anchorX <= 0) {
  13586. // Chevron
  13587. if (anchorY > y + safeDistance &&
  13588. anchorY < y + h - safeDistance) {
  13589. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  13590. // Simple connector
  13591. }
  13592. else {
  13593. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  13594. }
  13595. }
  13596. else if ( // replace bottom
  13597. anchorY &&
  13598. anchorY > h &&
  13599. anchorX > x + safeDistance &&
  13600. anchorX < x + w - safeDistance) {
  13601. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  13602. }
  13603. else if ( // replace top
  13604. anchorY &&
  13605. anchorY < 0 &&
  13606. anchorX > x + safeDistance &&
  13607. anchorX < x + w - safeDistance) {
  13608. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  13609. }
  13610. return path;
  13611. }
  13612. };
  13613. H.SVGRenderer = SVGRenderer;
  13614. H.Renderer = H.SVGRenderer;
  13615. return H.Renderer;
  13616. });
  13617. _registerModule(_modules, 'Core/Renderer/HTML/HTMLElement.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (H, SVGElement, U) {
  13618. /* *
  13619. *
  13620. * (c) 2010-2021 Torstein Honsi
  13621. *
  13622. * License: www.highcharts.com/license
  13623. *
  13624. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13625. *
  13626. * */
  13627. var isFirefox = H.isFirefox,
  13628. isMS = H.isMS,
  13629. isWebKit = H.isWebKit,
  13630. win = H.win;
  13631. var css = U.css,
  13632. defined = U.defined,
  13633. extend = U.extend,
  13634. pick = U.pick,
  13635. pInt = U.pInt;
  13636. /**
  13637. * Element placebo
  13638. * @private
  13639. */
  13640. var HTMLElement = SVGElement;
  13641. /* eslint-disable valid-jsdoc */
  13642. // Extend SvgElement for useHTML option.
  13643. extend(HTMLElement.prototype, /** @lends SVGElement.prototype */ {
  13644. /**
  13645. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  13646. * by the VML renderer
  13647. *
  13648. * @private
  13649. * @function Highcharts.SVGElement#htmlCss
  13650. *
  13651. * @param {Highcharts.CSSObject} styles
  13652. *
  13653. * @return {Highcharts.SVGElement}
  13654. */
  13655. htmlCss: function (styles) {
  13656. var wrapper = this,
  13657. element = wrapper.element,
  13658. // When setting or unsetting the width style, we need to update
  13659. // transform (#8809)
  13660. isSettingWidth = (element.tagName === 'SPAN' &&
  13661. styles &&
  13662. 'width' in styles),
  13663. textWidth = pick(isSettingWidth && styles.width,
  13664. void 0),
  13665. doTransform;
  13666. if (isSettingWidth) {
  13667. delete styles.width;
  13668. wrapper.textWidth = textWidth;
  13669. doTransform = true;
  13670. }
  13671. if (styles && styles.textOverflow === 'ellipsis') {
  13672. styles.whiteSpace = 'nowrap';
  13673. styles.overflow = 'hidden';
  13674. }
  13675. wrapper.styles = extend(wrapper.styles, styles);
  13676. css(wrapper.element, styles);
  13677. // Now that all styles are applied, to the transform
  13678. if (doTransform) {
  13679. wrapper.htmlUpdateTransform();
  13680. }
  13681. return wrapper;
  13682. },
  13683. /**
  13684. * VML and useHTML method for calculating the bounding box based on offsets.
  13685. *
  13686. * @private
  13687. * @function Highcharts.SVGElement#htmlGetBBox
  13688. *
  13689. * @param {boolean} refresh
  13690. * Whether to force a fresh value from the DOM or to use the cached
  13691. * value.
  13692. *
  13693. * @return {Highcharts.BBoxObject}
  13694. * A hash containing values for x, y, width and height.
  13695. */
  13696. htmlGetBBox: function () {
  13697. var wrapper = this,
  13698. element = wrapper.element;
  13699. return {
  13700. x: element.offsetLeft,
  13701. y: element.offsetTop,
  13702. width: element.offsetWidth,
  13703. height: element.offsetHeight
  13704. };
  13705. },
  13706. /**
  13707. * VML override private method to update elements based on internal
  13708. * properties based on SVG transform.
  13709. *
  13710. * @private
  13711. * @function Highcharts.SVGElement#htmlUpdateTransform
  13712. * @return {void}
  13713. */
  13714. htmlUpdateTransform: function () {
  13715. // aligning non added elements is expensive
  13716. if (!this.added) {
  13717. this.alignOnAdd = true;
  13718. return;
  13719. }
  13720. var wrapper = this,
  13721. renderer = wrapper.renderer,
  13722. elem = wrapper.element,
  13723. translateX = wrapper.translateX || 0,
  13724. translateY = wrapper.translateY || 0,
  13725. x = wrapper.x || 0,
  13726. y = wrapper.y || 0,
  13727. align = wrapper.textAlign || 'left',
  13728. alignCorrection = {
  13729. left: 0,
  13730. center: 0.5,
  13731. right: 1
  13732. }[align],
  13733. styles = wrapper.styles,
  13734. whiteSpace = styles && styles.whiteSpace;
  13735. /**
  13736. * @private
  13737. * @return {number}
  13738. */
  13739. function getTextPxLength() {
  13740. // Reset multiline/ellipsis in order to read width (#4928,
  13741. // #5417)
  13742. css(elem, {
  13743. width: '',
  13744. whiteSpace: whiteSpace || 'nowrap'
  13745. });
  13746. return elem.offsetWidth;
  13747. }
  13748. // apply translate
  13749. css(elem, {
  13750. marginLeft: translateX,
  13751. marginTop: translateY
  13752. });
  13753. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  13754. wrapper.shadows.forEach(function (shadow) {
  13755. css(shadow, {
  13756. marginLeft: translateX + 1,
  13757. marginTop: translateY + 1
  13758. });
  13759. });
  13760. }
  13761. // apply inversion
  13762. if (wrapper.inverted) { // wrapper is a group
  13763. [].forEach.call(elem.childNodes, function (child) {
  13764. renderer.invertChild(child, elem);
  13765. });
  13766. }
  13767. if (elem.tagName === 'SPAN') {
  13768. var rotation = wrapper.rotation, baseline = void 0, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  13769. rotation,
  13770. align,
  13771. elem.innerHTML,
  13772. wrapper.textWidth,
  13773. wrapper.textAlign
  13774. ].join(',');
  13775. // Update textWidth. Use the memoized textPxLength if possible, to
  13776. // avoid the getTextPxLength function using elem.offsetWidth.
  13777. // Calling offsetWidth affects rendering time as it forces layout
  13778. // (#7656).
  13779. if (textWidth !== wrapper.oldTextWidth &&
  13780. ((textWidth > wrapper.oldTextWidth) ||
  13781. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  13782. // Only set the width if the text is able to word-wrap, or
  13783. // text-overflow is ellipsis (#9537)
  13784. /[ \-]/.test(elem.textContent || elem.innerText) ||
  13785. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  13786. css(elem, {
  13787. width: textWidth + 'px',
  13788. display: 'block',
  13789. whiteSpace: whiteSpace || 'normal' // #3331
  13790. });
  13791. wrapper.oldTextWidth = textWidth;
  13792. wrapper.hasBoxWidthChanged = true; // #8159
  13793. }
  13794. else {
  13795. wrapper.hasBoxWidthChanged = false; // #8159
  13796. }
  13797. // Do the calculations and DOM access only if properties changed
  13798. if (currentTextTransform !== wrapper.cTT) {
  13799. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  13800. // Renderer specific handling of span rotation, but only if we
  13801. // have something to update.
  13802. if (defined(rotation) &&
  13803. ((rotation !== (wrapper.oldRotation || 0)) ||
  13804. (align !== wrapper.oldAlign))) {
  13805. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  13806. }
  13807. wrapper.getSpanCorrection(
  13808. // Avoid elem.offsetWidth if we can, it affects rendering
  13809. // time heavily (#7656)
  13810. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  13811. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  13812. }
  13813. // apply position with correction
  13814. css(elem, {
  13815. left: (x + (wrapper.xCorr || 0)) + 'px',
  13816. top: (y + (wrapper.yCorr || 0)) + 'px'
  13817. });
  13818. // record current text transform
  13819. wrapper.cTT = currentTextTransform;
  13820. wrapper.oldRotation = rotation;
  13821. wrapper.oldAlign = align;
  13822. }
  13823. },
  13824. /**
  13825. * Set the rotation of an individual HTML span.
  13826. *
  13827. * @private
  13828. * @function Highcharts.SVGElement#setSpanRotation
  13829. * @param {number} rotation
  13830. * @param {number} alignCorrection
  13831. * @param {number} baseline
  13832. * @return {void}
  13833. */
  13834. setSpanRotation: function (rotation, alignCorrection, baseline) {
  13835. var getTransformKey = function () { return (isMS &&
  13836. !/Edge/.test(win.navigator.userAgent) ?
  13837. '-ms-transform' :
  13838. isWebKit ?
  13839. '-webkit-transform' :
  13840. isFirefox ?
  13841. 'MozTransform' :
  13842. win.opera ?
  13843. '-o-transform' :
  13844. void 0); };
  13845. var rotationStyle = {},
  13846. cssTransformKey = getTransformKey();
  13847. if (cssTransformKey) {
  13848. rotationStyle[cssTransformKey] = rotationStyle.transform =
  13849. 'rotate(' + rotation + 'deg)';
  13850. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin =
  13851. (alignCorrection * 100) + '% ' + baseline + 'px';
  13852. css(this.element, rotationStyle);
  13853. }
  13854. },
  13855. /**
  13856. * Get the correction in X and Y positioning as the element is rotated.
  13857. *
  13858. * @private
  13859. * @function Highcharts.SVGElement#getSpanCorrection
  13860. * @param {number} width
  13861. * @param {number} baseline
  13862. * @param {number} alignCorrection
  13863. * @return {void}
  13864. */
  13865. getSpanCorrection: function (width, baseline, alignCorrection) {
  13866. this.xCorr = -width * alignCorrection;
  13867. this.yCorr = -baseline;
  13868. }
  13869. });
  13870. return HTMLElement;
  13871. });
  13872. _registerModule(_modules, 'Core/Renderer/HTML/HTMLRenderer.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (AST, SVGElement, SVGRenderer, U) {
  13873. /* *
  13874. *
  13875. * (c) 2010-2021 Torstein Honsi
  13876. *
  13877. * License: www.highcharts.com/license
  13878. *
  13879. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13880. *
  13881. * */
  13882. var attr = U.attr,
  13883. createElement = U.createElement,
  13884. extend = U.extend,
  13885. pick = U.pick;
  13886. /**
  13887. * Renderer placebo
  13888. * @private
  13889. */
  13890. var HTMLRenderer = SVGRenderer;
  13891. /* eslint-disable valid-jsdoc */
  13892. // Extend SvgRenderer for useHTML option.
  13893. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  13894. /**
  13895. * Create HTML text node. This is used by the VML renderer as well as the
  13896. * SVG renderer through the useHTML option.
  13897. *
  13898. * @private
  13899. * @function Highcharts.SVGRenderer#html
  13900. *
  13901. * @param {string} str
  13902. * The text of (subset) HTML to draw.
  13903. *
  13904. * @param {number} x
  13905. * The x position of the text's lower left corner.
  13906. *
  13907. * @param {number} y
  13908. * The y position of the text's lower left corner.
  13909. *
  13910. * @return {Highcharts.HTMLDOMElement}
  13911. */
  13912. html: function (str, x, y) {
  13913. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  13914. // These properties are set as attributes on the SVG group, and
  13915. // as identical CSS properties on the div. (#3542)
  13916. ['opacity', 'visibility'].forEach(function (prop) {
  13917. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  13918. var styleObject = gWrapper.div ?
  13919. gWrapper.div.style :
  13920. style;
  13921. SVGElement.prototype[prop + 'Setter']
  13922. .call(this, value, key, elem);
  13923. if (styleObject) {
  13924. styleObject[key] = value;
  13925. }
  13926. };
  13927. });
  13928. gWrapper.addedSetters = true;
  13929. };
  13930. // Text setter
  13931. wrapper.textSetter = function (value) {
  13932. if (value !== this.textStr) {
  13933. delete this.bBox;
  13934. delete this.oldTextWidth;
  13935. AST.setElementHTML(this.element, pick(value, ''));
  13936. this.textStr = value;
  13937. wrapper.doTransform = true;
  13938. }
  13939. };
  13940. // Add setters for the element itself (#4938)
  13941. if (isSVG) { // #4938, only for HTML within SVG
  13942. addSetters(wrapper, wrapper.element.style);
  13943. }
  13944. // Various setters which rely on update transform
  13945. wrapper.xSetter =
  13946. wrapper.ySetter =
  13947. wrapper.alignSetter =
  13948. wrapper.rotationSetter =
  13949. function (value, key) {
  13950. if (key === 'align') {
  13951. // Do not overwrite the SVGElement.align method. Same as VML.
  13952. wrapper.alignValue = wrapper.textAlign = value;
  13953. }
  13954. else {
  13955. wrapper[key] = value;
  13956. }
  13957. wrapper.doTransform = true;
  13958. };
  13959. // Runs at the end of .attr()
  13960. wrapper.afterSetters = function () {
  13961. // Update transform. Do this outside the loop to prevent redundant
  13962. // updating for batch setting of attributes.
  13963. if (this.doTransform) {
  13964. this.htmlUpdateTransform();
  13965. this.doTransform = false;
  13966. }
  13967. };
  13968. // Set the default attributes
  13969. wrapper
  13970. .attr({
  13971. text: str,
  13972. x: Math.round(x),
  13973. y: Math.round(y)
  13974. })
  13975. .css({
  13976. position: 'absolute'
  13977. });
  13978. if (!renderer.styledMode) {
  13979. wrapper.css({
  13980. fontFamily: this.style.fontFamily,
  13981. fontSize: this.style.fontSize
  13982. });
  13983. }
  13984. // Keep the whiteSpace style outside the wrapper.styles collection
  13985. element.style.whiteSpace = 'nowrap';
  13986. // Use the HTML specific .css method
  13987. wrapper.css = wrapper.htmlCss;
  13988. // This is specific for HTML within SVG
  13989. if (isSVG) {
  13990. wrapper.add = function (svgGroupWrapper) {
  13991. var htmlGroup,
  13992. container = renderer.box.parentNode,
  13993. parentGroup,
  13994. parents = [];
  13995. this.parentGroup = svgGroupWrapper;
  13996. // Create a mock group to hold the HTML elements
  13997. if (svgGroupWrapper) {
  13998. htmlGroup = svgGroupWrapper.div;
  13999. if (!htmlGroup) {
  14000. // Read the parent chain into an array and read from top
  14001. // down
  14002. parentGroup = svgGroupWrapper;
  14003. while (parentGroup) {
  14004. parents.push(parentGroup);
  14005. // Move up to the next parent group
  14006. parentGroup = parentGroup.parentGroup;
  14007. }
  14008. // Ensure dynamically updating position when any parent
  14009. // is translated
  14010. parents.reverse().forEach(function (parentGroup) {
  14011. var htmlGroupStyle,
  14012. cls = attr(parentGroup.element, 'class');
  14013. /**
  14014. * Common translate setter for X and Y on the HTML
  14015. * group. Reverted the fix for #6957 du to
  14016. * positioning problems and offline export (#7254,
  14017. * #7280, #7529)
  14018. * @private
  14019. * @param {*} value
  14020. * @param {string} key
  14021. * @return {void}
  14022. */
  14023. function translateSetter(value, key) {
  14024. parentGroup[key] = value;
  14025. if (key === 'translateX') {
  14026. htmlGroupStyle.left = value + 'px';
  14027. }
  14028. else {
  14029. htmlGroupStyle.top = value + 'px';
  14030. }
  14031. parentGroup.doTransform = true;
  14032. }
  14033. // Create a HTML div and append it to the parent div
  14034. // to emulate the SVG group structure
  14035. var parentGroupStyles = parentGroup.styles || {};
  14036. htmlGroup =
  14037. parentGroup.div =
  14038. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  14039. position: 'absolute',
  14040. left: (parentGroup.translateX || 0) + 'px',
  14041. top: (parentGroup.translateY || 0) + 'px',
  14042. display: parentGroup.display,
  14043. opacity: parentGroup.opacity,
  14044. cursor: parentGroupStyles.cursor,
  14045. pointerEvents: parentGroupStyles.pointerEvents // #5595
  14046. // the top group is appended to container
  14047. }, htmlGroup || container);
  14048. // Shortcut
  14049. htmlGroupStyle = htmlGroup.style;
  14050. // Set listeners to update the HTML div's position
  14051. // whenever the SVG group position is changed.
  14052. extend(parentGroup, {
  14053. // (#7287) Pass htmlGroup to use
  14054. // the related group
  14055. classSetter: (function (htmlGroup) {
  14056. return function (value) {
  14057. this.element.setAttribute('class', value);
  14058. htmlGroup.className = value;
  14059. };
  14060. }(htmlGroup)),
  14061. on: function () {
  14062. if (parents[0].div) { // #6418
  14063. wrapper.on.apply({
  14064. element: parents[0].div,
  14065. onEvents: wrapper.onEvents
  14066. }, arguments);
  14067. }
  14068. return parentGroup;
  14069. },
  14070. translateXSetter: translateSetter,
  14071. translateYSetter: translateSetter
  14072. });
  14073. if (!parentGroup.addedSetters) {
  14074. addSetters(parentGroup);
  14075. }
  14076. });
  14077. }
  14078. }
  14079. else {
  14080. htmlGroup = container;
  14081. }
  14082. htmlGroup.appendChild(element);
  14083. // Shared with VML:
  14084. wrapper.added = true;
  14085. if (wrapper.alignOnAdd) {
  14086. wrapper.htmlUpdateTransform();
  14087. }
  14088. return wrapper;
  14089. };
  14090. }
  14091. return wrapper;
  14092. }
  14093. });
  14094. return HTMLRenderer;
  14095. });
  14096. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (F, H, U) {
  14097. /* *
  14098. *
  14099. * (c) 2010-2021 Torstein Honsi
  14100. *
  14101. * License: www.highcharts.com/license
  14102. *
  14103. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14104. *
  14105. * */
  14106. var deg2rad = H.deg2rad;
  14107. var clamp = U.clamp,
  14108. correctFloat = U.correctFloat,
  14109. defined = U.defined,
  14110. destroyObjectProperties = U.destroyObjectProperties,
  14111. extend = U.extend,
  14112. fireEvent = U.fireEvent,
  14113. isNumber = U.isNumber,
  14114. merge = U.merge,
  14115. objectEach = U.objectEach,
  14116. pick = U.pick;
  14117. /**
  14118. * Optional parameters for the tick.
  14119. * @private
  14120. * @interface Highcharts.TickParametersObject
  14121. */ /**
  14122. * Set category for the tick.
  14123. * @name Highcharts.TickParametersObject#category
  14124. * @type {string|undefined}
  14125. */ /**
  14126. * @name Highcharts.TickParametersObject#options
  14127. * @type {Highcharts.Dictionary<any>|undefined}
  14128. */ /**
  14129. * Set tickmarkOffset for the tick.
  14130. * @name Highcharts.TickParametersObject#tickmarkOffset
  14131. * @type {number|undefined}
  14132. */
  14133. /**
  14134. * Additonal time tick information.
  14135. *
  14136. * @interface Highcharts.TimeTicksInfoObject
  14137. * @extends Highcharts.TimeNormalizedObject
  14138. */ /**
  14139. * @name Highcharts.TimeTicksInfoObject#higherRanks
  14140. * @type {Array<string>}
  14141. */ /**
  14142. * @name Highcharts.TimeTicksInfoObject#totalRange
  14143. * @type {number}
  14144. */
  14145. ''; // detach doclets above
  14146. /* eslint-disable no-invalid-this, valid-jsdoc */
  14147. /**
  14148. * The Tick class.
  14149. *
  14150. * @class
  14151. * @name Highcharts.Tick
  14152. *
  14153. * @param {Highcharts.Axis} axis
  14154. * The axis of the tick.
  14155. *
  14156. * @param {number} pos
  14157. * The position of the tick on the axis in terms of axis values.
  14158. *
  14159. * @param {string} [type]
  14160. * The type of tick, either 'minor' or an empty string
  14161. *
  14162. * @param {boolean} [noLabel=false]
  14163. * Whether to disable the label or not. Defaults to false.
  14164. *
  14165. * @param {object} [parameters]
  14166. * Optional parameters for the tick.
  14167. */
  14168. var Tick = /** @class */ (function () {
  14169. /* *
  14170. *
  14171. * Constructors
  14172. *
  14173. * */
  14174. function Tick(axis, pos, type, noLabel, parameters) {
  14175. this.isNew = true;
  14176. this.isNewLabel = true;
  14177. /**
  14178. * The related axis of the tick.
  14179. * @name Highcharts.Tick#axis
  14180. * @type {Highcharts.Axis}
  14181. */
  14182. this.axis = axis;
  14183. /**
  14184. * The logical position of the tick on the axis in terms of axis values.
  14185. * @name Highcharts.Tick#pos
  14186. * @type {number}
  14187. */
  14188. this.pos = pos;
  14189. /**
  14190. * The tick type, which can be `"minor"`, or an empty string.
  14191. * @name Highcharts.Tick#type
  14192. * @type {string}
  14193. */
  14194. this.type = type || '';
  14195. this.parameters = parameters || {};
  14196. /**
  14197. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  14198. * for grid axes.
  14199. * @name Highcharts.Tick#tickmarkOffset
  14200. * @type {number|undefined}
  14201. */
  14202. this.tickmarkOffset = this.parameters.tickmarkOffset;
  14203. this.options = this.parameters.options;
  14204. fireEvent(this, 'init');
  14205. if (!type && !noLabel) {
  14206. this.addLabel();
  14207. }
  14208. }
  14209. /* *
  14210. *
  14211. * Functions
  14212. *
  14213. * */
  14214. /**
  14215. * Write the tick label.
  14216. *
  14217. * @private
  14218. * @function Highcharts.Tick#addLabel
  14219. * @return {void}
  14220. */
  14221. Tick.prototype.addLabel = function () {
  14222. var tick = this,
  14223. axis = tick.axis,
  14224. options = axis.options,
  14225. chart = axis.chart,
  14226. categories = axis.categories,
  14227. log = axis.logarithmic,
  14228. names = axis.names,
  14229. pos = tick.pos,
  14230. labelOptions = pick(tick.options && tick.options.labels,
  14231. options.labels),
  14232. str,
  14233. tickPositions = axis.tickPositions,
  14234. isFirst = pos === tickPositions[0],
  14235. isLast = pos === tickPositions[tickPositions.length - 1],
  14236. label = tick.label,
  14237. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  14238. axis.tickInterval === 1,
  14239. tickPositionInfo = tickPositions.info,
  14240. dateTimeLabelFormat,
  14241. dateTimeLabelFormats,
  14242. i,
  14243. list;
  14244. // The context value
  14245. var value = this.parameters.category || (categories ?
  14246. pick(categories[pos],
  14247. names[pos],
  14248. pos) :
  14249. pos);
  14250. if (log && isNumber(value)) {
  14251. value = correctFloat(log.lin2log(value));
  14252. }
  14253. // Set the datetime label format. If a higher rank is set for this
  14254. // position, use that. If not, use the general format.
  14255. if (axis.dateTime && tickPositionInfo) {
  14256. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  14257. tickPositionInfo.higherRanks[pos]) ||
  14258. tickPositionInfo.unitName]);
  14259. dateTimeLabelFormat = dateTimeLabelFormats.main;
  14260. }
  14261. // set properties for access in render method
  14262. /**
  14263. * True if the tick is the first one on the axis.
  14264. * @name Highcharts.Tick#isFirst
  14265. * @readonly
  14266. * @type {boolean|undefined}
  14267. */
  14268. tick.isFirst = isFirst;
  14269. /**
  14270. * True if the tick is the last one on the axis.
  14271. * @name Highcharts.Tick#isLast
  14272. * @readonly
  14273. * @type {boolean|undefined}
  14274. */
  14275. tick.isLast = isLast;
  14276. // Get the string
  14277. var ctx = {
  14278. axis: axis,
  14279. chart: chart,
  14280. dateTimeLabelFormat: dateTimeLabelFormat,
  14281. isFirst: isFirst,
  14282. isLast: isLast,
  14283. pos: pos,
  14284. tick: tick,
  14285. tickPositionInfo: tickPositionInfo,
  14286. value: value
  14287. };
  14288. // Fire an event that allows modifying the context for use in
  14289. // `labels.format` and `labels.formatter`.
  14290. fireEvent(this, 'labelFormat', ctx);
  14291. // Label formatting. When `labels.format` is given, we first run the
  14292. // defaultFormatter and append the result to the context as `text`.
  14293. // Handy for adding prefix or suffix while keeping default number
  14294. // formatting.
  14295. var labelFormatter = function (ctx) {
  14296. if (labelOptions.formatter) {
  14297. return labelOptions.formatter.call(ctx,
  14298. ctx);
  14299. }
  14300. if (labelOptions.format) {
  14301. ctx.text = axis.defaultLabelFormatter.call(ctx);
  14302. return F.format(labelOptions.format, ctx, chart);
  14303. }
  14304. return axis.defaultLabelFormatter.call(ctx, ctx);
  14305. };
  14306. str = labelFormatter.call(ctx, ctx);
  14307. // Set up conditional formatting based on the format list if existing.
  14308. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  14309. if (list) {
  14310. tick.shortenLabel = function () {
  14311. for (i = 0; i < list.length; i++) {
  14312. extend(ctx, { dateTimeLabelFormat: list[i] });
  14313. label.attr({
  14314. text: labelFormatter.call(ctx, ctx)
  14315. });
  14316. if (label.getBBox().width <
  14317. axis.getSlotWidth(tick) - 2 *
  14318. labelOptions.padding) {
  14319. return;
  14320. }
  14321. }
  14322. label.attr({
  14323. text: ''
  14324. });
  14325. };
  14326. }
  14327. // Call only after first render
  14328. if (animateLabels && axis._addedPlotLB) {
  14329. tick.moveLabel(str, labelOptions);
  14330. }
  14331. // First call
  14332. if (!defined(label) && !tick.movedLabel) {
  14333. /**
  14334. * The rendered text label of the tick.
  14335. * @name Highcharts.Tick#label
  14336. * @type {Highcharts.SVGElement|undefined}
  14337. */
  14338. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  14339. // Base value to detect change for new calls to getBBox
  14340. tick.rotation = 0;
  14341. // update
  14342. }
  14343. else if (label && label.textStr !== str && !animateLabels) {
  14344. // When resetting text, also reset the width if dynamically set
  14345. // (#8809)
  14346. if (label.textWidth &&
  14347. !labelOptions.style.width &&
  14348. !label.styles.width) {
  14349. label.css({ width: null });
  14350. }
  14351. label.attr({ text: str });
  14352. label.textPxLength = label.getBBox().width;
  14353. }
  14354. };
  14355. /**
  14356. * Render and return the label of the tick.
  14357. *
  14358. * @private
  14359. * @function Highcharts.Tick#createLabel
  14360. * @param {Highcharts.PositionObject} xy
  14361. * @param {string} str
  14362. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14363. * @return {Highcharts.SVGElement|undefined}
  14364. */
  14365. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  14366. var axis = this.axis,
  14367. chart = axis.chart,
  14368. label = defined(str) && labelOptions.enabled ?
  14369. chart.renderer
  14370. .text(str,
  14371. xy.x,
  14372. xy.y,
  14373. labelOptions.useHTML)
  14374. .add(axis.labelGroup) :
  14375. null;
  14376. // Un-rotated length
  14377. if (label) {
  14378. // Without position absolute, IE export sometimes is wrong
  14379. if (!chart.styledMode) {
  14380. label.css(merge(labelOptions.style));
  14381. }
  14382. label.textPxLength = label.getBBox().width;
  14383. }
  14384. return label;
  14385. };
  14386. /**
  14387. * Destructor for the tick prototype
  14388. *
  14389. * @private
  14390. * @function Highcharts.Tick#destroy
  14391. * @return {void}
  14392. */
  14393. Tick.prototype.destroy = function () {
  14394. destroyObjectProperties(this, this.axis);
  14395. };
  14396. /**
  14397. * Gets the x and y positions for ticks in terms of pixels.
  14398. *
  14399. * @private
  14400. * @function Highcharts.Tick#getPosition
  14401. *
  14402. * @param {boolean} horiz
  14403. * Whether the tick is on an horizontal axis or not.
  14404. *
  14405. * @param {number} tickPos
  14406. * Position of the tick.
  14407. *
  14408. * @param {number} tickmarkOffset
  14409. * Tickmark offset for all ticks.
  14410. *
  14411. * @param {boolean} [old]
  14412. * Whether the axis has changed or not.
  14413. *
  14414. * @return {Highcharts.PositionObject}
  14415. * The tick position.
  14416. *
  14417. * @fires Highcharts.Tick#event:afterGetPosition
  14418. */
  14419. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  14420. var axis = this.axis,
  14421. chart = axis.chart,
  14422. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  14423. pos;
  14424. pos = {
  14425. x: horiz ?
  14426. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  14427. axis.transB) :
  14428. (axis.left +
  14429. axis.offset +
  14430. (axis.opposite ?
  14431. (((old && chart.oldChartWidth) ||
  14432. chart.chartWidth) -
  14433. axis.right -
  14434. axis.left) :
  14435. 0)),
  14436. y: horiz ?
  14437. (cHeight -
  14438. axis.bottom +
  14439. axis.offset -
  14440. (axis.opposite ? axis.height : 0)) :
  14441. correctFloat(cHeight -
  14442. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  14443. axis.transB)
  14444. };
  14445. // Chrome workaround for #10516
  14446. pos.y = clamp(pos.y, -1e5, 1e5);
  14447. fireEvent(this, 'afterGetPosition', { pos: pos });
  14448. return pos;
  14449. };
  14450. /**
  14451. * Get the x, y position of the tick label
  14452. *
  14453. * @private
  14454. * @return {Highcharts.PositionObject}
  14455. */
  14456. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  14457. var axis = this.axis,
  14458. transA = axis.transA,
  14459. reversed = ( // #7911
  14460. axis.isLinked && axis.linkedParent ?
  14461. axis.linkedParent.reversed :
  14462. axis.reversed),
  14463. staggerLines = axis.staggerLines,
  14464. rotCorr = axis.tickRotCorr || { x: 0,
  14465. y: 0 },
  14466. yOffset = labelOptions.y,
  14467. // Adjust for label alignment if we use reserveSpace: true (#5286)
  14468. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  14469. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  14470. 0),
  14471. line,
  14472. pos = {};
  14473. if (!defined(yOffset)) {
  14474. if (axis.side === 0) {
  14475. yOffset = label.rotation ? -8 : -label.getBBox().height;
  14476. }
  14477. else if (axis.side === 2) {
  14478. yOffset = rotCorr.y + 8;
  14479. }
  14480. else {
  14481. // #3140, #3140
  14482. yOffset = Math.cos(label.rotation * deg2rad) *
  14483. (rotCorr.y - label.getBBox(false, 0).height / 2);
  14484. }
  14485. }
  14486. x = x +
  14487. labelOptions.x +
  14488. labelOffsetCorrection +
  14489. rotCorr.x -
  14490. (tickmarkOffset && horiz ?
  14491. tickmarkOffset * transA * (reversed ? -1 : 1) :
  14492. 0);
  14493. y = y + yOffset - (tickmarkOffset && !horiz ?
  14494. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  14495. // Correct for staggered labels
  14496. if (staggerLines) {
  14497. line = (index / (step || 1) % staggerLines);
  14498. if (axis.opposite) {
  14499. line = staggerLines - line - 1;
  14500. }
  14501. y += line * (axis.labelOffset / staggerLines);
  14502. }
  14503. pos.x = x;
  14504. pos.y = Math.round(y);
  14505. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  14506. return pos;
  14507. };
  14508. /**
  14509. * Get the offset height or width of the label
  14510. *
  14511. * @private
  14512. * @function Highcharts.Tick#getLabelSize
  14513. * @return {number}
  14514. */
  14515. Tick.prototype.getLabelSize = function () {
  14516. return this.label ?
  14517. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  14518. 0;
  14519. };
  14520. /**
  14521. * Extendible method to return the path of the marker
  14522. *
  14523. * @private
  14524. *
  14525. */
  14526. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  14527. return renderer.crispLine([[
  14528. 'M',
  14529. x,
  14530. y
  14531. ], [
  14532. 'L',
  14533. x + (horiz ? 0 : -tickLength),
  14534. y + (horiz ? tickLength : 0)
  14535. ]], tickWidth);
  14536. };
  14537. /**
  14538. * Handle the label overflow by adjusting the labels to the left and right
  14539. * edge, or hide them if they collide into the neighbour label.
  14540. *
  14541. * @private
  14542. * @function Highcharts.Tick#handleOverflow
  14543. * @param {Highcharts.PositionObject} xy
  14544. * @return {void}
  14545. */
  14546. Tick.prototype.handleOverflow = function (xy) {
  14547. var tick = this,
  14548. axis = this.axis,
  14549. labelOptions = axis.options.labels,
  14550. pxPos = xy.x,
  14551. chartWidth = axis.chart.chartWidth,
  14552. spacing = axis.chart.spacing,
  14553. leftBound = pick(axis.labelLeft,
  14554. Math.min(axis.pos,
  14555. spacing[3])),
  14556. rightBound = pick(axis.labelRight,
  14557. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  14558. chartWidth - spacing[1])),
  14559. label = this.label,
  14560. rotation = this.rotation,
  14561. factor = {
  14562. left: 0,
  14563. center: 0.5,
  14564. right: 1
  14565. }[axis.labelAlign || label.attr('align')],
  14566. labelWidth = label.getBBox().width,
  14567. slotWidth = axis.getSlotWidth(tick),
  14568. modifiedSlotWidth = slotWidth,
  14569. xCorrection = factor,
  14570. goRight = 1,
  14571. leftPos,
  14572. rightPos,
  14573. textWidth,
  14574. css = {};
  14575. // Check if the label overshoots the chart spacing box. If it does, move
  14576. // it. If it now overshoots the slotWidth, add ellipsis.
  14577. if (!rotation && labelOptions.overflow === 'justify') {
  14578. leftPos = pxPos - factor * labelWidth;
  14579. rightPos = pxPos + (1 - factor) * labelWidth;
  14580. if (leftPos < leftBound) {
  14581. modifiedSlotWidth =
  14582. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  14583. }
  14584. else if (rightPos > rightBound) {
  14585. modifiedSlotWidth =
  14586. rightBound - xy.x + modifiedSlotWidth * factor;
  14587. goRight = -1;
  14588. }
  14589. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  14590. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  14591. xy.x += (goRight *
  14592. (slotWidth -
  14593. modifiedSlotWidth -
  14594. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  14595. }
  14596. // If the label width exceeds the available space, set a text width
  14597. // to be picked up below. Also, if a width has been set before, we
  14598. // need to set a new one because the reported labelWidth will be
  14599. // limited by the box (#3938).
  14600. if (labelWidth > modifiedSlotWidth ||
  14601. (axis.autoRotation && (label.styles || {}).width)) {
  14602. textWidth = modifiedSlotWidth;
  14603. }
  14604. // Add ellipsis to prevent rotated labels to be clipped against the edge
  14605. // of the chart
  14606. }
  14607. else if (rotation < 0 &&
  14608. pxPos - factor * labelWidth < leftBound) {
  14609. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  14610. }
  14611. else if (rotation > 0 &&
  14612. pxPos + factor * labelWidth > rightBound) {
  14613. textWidth = Math.round((chartWidth - pxPos) /
  14614. Math.cos(rotation * deg2rad));
  14615. }
  14616. if (textWidth) {
  14617. if (tick.shortenLabel) {
  14618. tick.shortenLabel();
  14619. }
  14620. else {
  14621. css.width = Math.floor(textWidth) + 'px';
  14622. if (!(labelOptions.style || {}).textOverflow) {
  14623. css.textOverflow = 'ellipsis';
  14624. }
  14625. label.css(css);
  14626. }
  14627. }
  14628. };
  14629. /**
  14630. * Try to replace the label if the same one already exists.
  14631. *
  14632. * @private
  14633. * @function Highcharts.Tick#moveLabel
  14634. * @param {string} str
  14635. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14636. *
  14637. * @return {void}
  14638. */
  14639. Tick.prototype.moveLabel = function (str, labelOptions) {
  14640. var tick = this,
  14641. label = tick.label,
  14642. moved = false,
  14643. axis = tick.axis,
  14644. labelPos,
  14645. reversed = axis.reversed,
  14646. xPos,
  14647. yPos;
  14648. if (label && label.textStr === str) {
  14649. tick.movedLabel = label;
  14650. moved = true;
  14651. delete tick.label;
  14652. }
  14653. else { // Find a label with the same string
  14654. objectEach(axis.ticks, function (currentTick) {
  14655. if (!moved &&
  14656. !currentTick.isNew &&
  14657. currentTick !== tick &&
  14658. currentTick.label &&
  14659. currentTick.label.textStr === str) {
  14660. tick.movedLabel = currentTick.label;
  14661. moved = true;
  14662. currentTick.labelPos = tick.movedLabel.xy;
  14663. delete currentTick.label;
  14664. }
  14665. });
  14666. }
  14667. // Create new label if the actual one is moved
  14668. if (!moved && (tick.labelPos || label)) {
  14669. labelPos = tick.labelPos || label.xy;
  14670. xPos = axis.horiz ?
  14671. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  14672. yPos = axis.horiz ?
  14673. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  14674. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  14675. if (tick.movedLabel) {
  14676. tick.movedLabel.attr({ opacity: 0 });
  14677. }
  14678. }
  14679. };
  14680. /**
  14681. * Put everything in place
  14682. *
  14683. * @private
  14684. * @param {number} index
  14685. * @param {boolean} [old]
  14686. * Use old coordinates to prepare an animation into new position
  14687. * @param {number} [opacity]
  14688. * @return {voids}
  14689. */
  14690. Tick.prototype.render = function (index, old, opacity) {
  14691. var tick = this,
  14692. axis = tick.axis,
  14693. horiz = axis.horiz,
  14694. pos = tick.pos,
  14695. tickmarkOffset = pick(tick.tickmarkOffset,
  14696. axis.tickmarkOffset),
  14697. xy = tick.getPosition(horiz,
  14698. pos,
  14699. tickmarkOffset,
  14700. old),
  14701. x = xy.x,
  14702. y = xy.y,
  14703. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  14704. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  14705. var labelOpacity = pick(opacity,
  14706. tick.label && tick.label.newOpacity, // #15528
  14707. 1);
  14708. opacity = pick(opacity, 1);
  14709. this.isActive = true;
  14710. // Create the grid line
  14711. this.renderGridLine(old, opacity, reverseCrisp);
  14712. // create the tick mark
  14713. this.renderMark(xy, opacity, reverseCrisp);
  14714. // the label is created on init - now move it into place
  14715. this.renderLabel(xy, old, labelOpacity, index);
  14716. tick.isNew = false;
  14717. fireEvent(this, 'afterRender');
  14718. };
  14719. /**
  14720. * Renders the gridLine.
  14721. *
  14722. * @private
  14723. * @param {boolean} old Whether or not the tick is old
  14724. * @param {number} opacity The opacity of the grid line
  14725. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14726. * @return {void}
  14727. */
  14728. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  14729. var tick = this,
  14730. axis = tick.axis,
  14731. options = axis.options,
  14732. gridLine = tick.gridLine,
  14733. gridLinePath,
  14734. attribs = {},
  14735. pos = tick.pos,
  14736. type = tick.type,
  14737. tickmarkOffset = pick(tick.tickmarkOffset,
  14738. axis.tickmarkOffset),
  14739. renderer = axis.chart.renderer,
  14740. gridLineWidth = options.gridLineWidth,
  14741. gridLineColor = options.gridLineColor,
  14742. dashStyle = options.gridLineDashStyle;
  14743. if (tick.type === 'minor') {
  14744. gridLineWidth = options.minorGridLineWidth;
  14745. gridLineColor = options.minorGridLineColor;
  14746. dashStyle = options.minorGridLineDashStyle;
  14747. }
  14748. if (!gridLine) {
  14749. if (!axis.chart.styledMode) {
  14750. attribs.stroke = gridLineColor;
  14751. attribs['stroke-width'] = gridLineWidth || 0;
  14752. attribs.dashstyle = dashStyle;
  14753. }
  14754. if (!type) {
  14755. attribs.zIndex = 1;
  14756. }
  14757. if (old) {
  14758. opacity = 0;
  14759. }
  14760. /**
  14761. * The rendered grid line of the tick.
  14762. * @name Highcharts.Tick#gridLine
  14763. * @type {Highcharts.SVGElement|undefined}
  14764. */
  14765. tick.gridLine = gridLine = renderer.path()
  14766. .attr(attribs)
  14767. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  14768. .add(axis.gridGroup);
  14769. }
  14770. if (gridLine) {
  14771. gridLinePath = axis.getPlotLinePath({
  14772. value: pos + tickmarkOffset,
  14773. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  14774. force: 'pass',
  14775. old: old
  14776. });
  14777. // If the parameter 'old' is set, the current call will be followed
  14778. // by another call, therefore do not do any animations this time
  14779. if (gridLinePath) {
  14780. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  14781. d: gridLinePath,
  14782. opacity: opacity
  14783. });
  14784. }
  14785. }
  14786. };
  14787. /**
  14788. * Renders the tick mark.
  14789. *
  14790. * @private
  14791. * @param {Highcharts.PositionObject} xy The position vector of the mark
  14792. * @param {number} opacity The opacity of the mark
  14793. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14794. * @return {void}
  14795. */
  14796. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  14797. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickSize = axis.tickSize(type ? type + 'Tick' : 'tick'), mark = tick.mark, isNewMark = !mark, x = xy.x, y = xy.y, tickWidth = pick(options[type !== 'minor' ? 'tickWidth' : 'minorTickWidth'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  14798. tickColor = options[type !== 'minor' ? 'tickColor' : 'minorTickColor'];
  14799. if (tickSize) {
  14800. // negate the length
  14801. if (axis.opposite) {
  14802. tickSize[0] = -tickSize[0];
  14803. }
  14804. // First time, create it
  14805. if (isNewMark) {
  14806. /**
  14807. * The rendered mark of the tick.
  14808. * @name Highcharts.Tick#mark
  14809. * @type {Highcharts.SVGElement|undefined}
  14810. */
  14811. tick.mark = mark = renderer.path()
  14812. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  14813. .add(axis.axisGroup);
  14814. if (!axis.chart.styledMode) {
  14815. mark.attr({
  14816. stroke: tickColor,
  14817. 'stroke-width': tickWidth
  14818. });
  14819. }
  14820. }
  14821. mark[isNewMark ? 'attr' : 'animate']({
  14822. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  14823. opacity: opacity
  14824. });
  14825. }
  14826. };
  14827. /**
  14828. * Renders the tick label.
  14829. * Note: The label should already be created in init(), so it should only
  14830. * have to be moved into place.
  14831. *
  14832. * @private
  14833. * @param {Highcharts.PositionObject} xy The position vector of the label
  14834. * @param {boolean} old Whether or not the tick is old
  14835. * @param {number} opacity The opacity of the label
  14836. * @param {number} index The index of the tick
  14837. * @return {void}
  14838. */
  14839. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  14840. var tick = this,
  14841. axis = tick.axis,
  14842. horiz = axis.horiz,
  14843. options = axis.options,
  14844. label = tick.label,
  14845. labelOptions = options.labels,
  14846. step = labelOptions.step,
  14847. tickmarkOffset = pick(tick.tickmarkOffset,
  14848. axis.tickmarkOffset),
  14849. show = true,
  14850. x = xy.x,
  14851. y = xy.y;
  14852. if (label && isNumber(x)) {
  14853. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  14854. // Apply show first and show last. If the tick is both first and
  14855. // last, it is a single centered tick, in which case we show the
  14856. // label anyway (#2100).
  14857. if ((tick.isFirst &&
  14858. !tick.isLast &&
  14859. !options.showFirstLabel) ||
  14860. (tick.isLast &&
  14861. !tick.isFirst &&
  14862. !options.showLastLabel)) {
  14863. show = false;
  14864. // Handle label overflow and show or hide accordingly
  14865. }
  14866. else if (horiz &&
  14867. !labelOptions.step &&
  14868. !labelOptions.rotation &&
  14869. !old &&
  14870. opacity !== 0) {
  14871. tick.handleOverflow(xy);
  14872. }
  14873. // apply step
  14874. if (step && index % step) {
  14875. // show those indices dividable by step
  14876. show = false;
  14877. }
  14878. // Set the new position, and show or hide
  14879. if (show && isNumber(xy.y)) {
  14880. xy.opacity = opacity;
  14881. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  14882. tick.isNewLabel = false;
  14883. }
  14884. else {
  14885. label.attr('y', -9999); // #1338
  14886. tick.isNewLabel = true;
  14887. }
  14888. }
  14889. };
  14890. /**
  14891. * Replace labels with the moved ones to perform animation. Additionally
  14892. * destroy unused labels.
  14893. *
  14894. * @private
  14895. * @function Highcharts.Tick#replaceMovedLabel
  14896. * @return {void}
  14897. */
  14898. Tick.prototype.replaceMovedLabel = function () {
  14899. var tick = this,
  14900. label = tick.label,
  14901. axis = tick.axis,
  14902. reversed = axis.reversed,
  14903. x,
  14904. y;
  14905. // Animate and destroy
  14906. if (label && !tick.isNew) {
  14907. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  14908. y = axis.horiz ?
  14909. label.xy.y :
  14910. (reversed ? axis.width + axis.top : axis.top);
  14911. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  14912. delete tick.label;
  14913. }
  14914. axis.isDirty = true;
  14915. tick.label = tick.movedLabel;
  14916. delete tick.movedLabel;
  14917. };
  14918. return Tick;
  14919. }());
  14920. H.Tick = Tick;
  14921. return H.Tick;
  14922. });
  14923. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Options.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, Color, H, palette, O, Tick, U) {
  14924. /* *
  14925. *
  14926. * (c) 2010-2021 Torstein Honsi
  14927. *
  14928. * License: www.highcharts.com/license
  14929. *
  14930. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14931. *
  14932. * */
  14933. var animObject = A.animObject;
  14934. var defaultOptions = O.defaultOptions;
  14935. var addEvent = U.addEvent,
  14936. arrayMax = U.arrayMax,
  14937. arrayMin = U.arrayMin,
  14938. clamp = U.clamp,
  14939. correctFloat = U.correctFloat,
  14940. defined = U.defined,
  14941. destroyObjectProperties = U.destroyObjectProperties,
  14942. erase = U.erase,
  14943. error = U.error,
  14944. extend = U.extend,
  14945. fireEvent = U.fireEvent,
  14946. getMagnitude = U.getMagnitude,
  14947. isArray = U.isArray,
  14948. isFunction = U.isFunction,
  14949. isNumber = U.isNumber,
  14950. isString = U.isString,
  14951. merge = U.merge,
  14952. normalizeTickInterval = U.normalizeTickInterval,
  14953. objectEach = U.objectEach,
  14954. pick = U.pick,
  14955. relativeLength = U.relativeLength,
  14956. removeEvent = U.removeEvent,
  14957. splat = U.splat,
  14958. syncTimeout = U.syncTimeout;
  14959. /**
  14960. * Options for the path on the Axis to be calculated.
  14961. * @interface Highcharts.AxisPlotLinePathOptionsObject
  14962. */ /**
  14963. * Axis value.
  14964. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  14965. * @type {number|undefined}
  14966. */ /**
  14967. * Line width used for calculation crisp line coordinates. Defaults to 1.
  14968. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  14969. * @type {number|undefined}
  14970. */ /**
  14971. * If `false`, the function will return null when it falls outside the axis
  14972. * bounds. If `true`, the function will return a path aligned to the plot area
  14973. * sides if it falls outside. If `pass`, it will return a path outside.
  14974. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  14975. * @type {string|boolean|undefined}
  14976. */ /**
  14977. * Used in Highcharts Stock. When `true`, plot paths
  14978. * (crosshair, plotLines, gridLines)
  14979. * will be rendered on all axes when defined on the first axis.
  14980. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  14981. * @type {boolean|undefined}
  14982. */ /**
  14983. * Use old coordinates (for resizing and rescaling).
  14984. * If not set, defaults to `false`.
  14985. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  14986. * @type {boolean|undefined}
  14987. */ /**
  14988. * If given, return the plot line path of a pixel position on the axis.
  14989. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  14990. * @type {number|undefined}
  14991. */ /**
  14992. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  14993. * plot bands
  14994. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  14995. * @type {boolean|undefined}
  14996. */
  14997. /**
  14998. * Options for crosshairs on axes.
  14999. *
  15000. * @product highstock
  15001. *
  15002. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  15003. */
  15004. /**
  15005. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  15006. */
  15007. /**
  15008. * @callback Highcharts.AxisEventCallbackFunction
  15009. *
  15010. * @param {Highcharts.Axis} this
  15011. */
  15012. /**
  15013. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  15014. *
  15015. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15016. *
  15017. * @param {Highcharts.AxisLabelsFormatterContextObject} ctx
  15018. *
  15019. * @return {string}
  15020. */
  15021. /**
  15022. * @interface Highcharts.AxisLabelsFormatterContextObject
  15023. */ /**
  15024. * The axis item of the label
  15025. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  15026. * @type {Highcharts.Axis}
  15027. */ /**
  15028. * The chart instance.
  15029. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  15030. * @type {Highcharts.Chart}
  15031. */ /**
  15032. * Whether the label belongs to the first tick on the axis.
  15033. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  15034. * @type {boolean}
  15035. */ /**
  15036. * Whether the label belongs to the last tick on the axis.
  15037. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  15038. * @type {boolean}
  15039. */ /**
  15040. * The position on the axis in terms of axis values. For category axes, a
  15041. * zero-based index. For datetime axes, the JavaScript time in milliseconds
  15042. * since 1970.
  15043. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  15044. * @type {number}
  15045. */ /**
  15046. * The preformatted text as the result of the default formatting. For example
  15047. * dates will be formatted as strings, and numbers with language-specific comma
  15048. * separators, thousands separators and numeric symbols like `k` or `M`.
  15049. * @name Highcharts.AxisLabelsFormatterContextObject#text
  15050. * @type {string}
  15051. */ /**
  15052. * The Tick instance.
  15053. * @name Highcharts.AxisLabelsFormatterContextObject#tick
  15054. * @type {Highcharts.Tick}
  15055. */ /**
  15056. * This can be either a numeric value or a category string.
  15057. * @name Highcharts.AxisLabelsFormatterContextObject#value
  15058. * @type {number|string}
  15059. */
  15060. /**
  15061. * Options for axes.
  15062. *
  15063. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  15064. */
  15065. /**
  15066. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  15067. *
  15068. * @param {Highcharts.Axis} this
  15069. *
  15070. * @param {Highcharts.AxisPointBreakEventObject} evt
  15071. */
  15072. /**
  15073. * @interface Highcharts.AxisPointBreakEventObject
  15074. */ /**
  15075. * @name Highcharts.AxisPointBreakEventObject#brk
  15076. * @type {Highcharts.Dictionary<number>}
  15077. */ /**
  15078. * @name Highcharts.AxisPointBreakEventObject#point
  15079. * @type {Highcharts.Point}
  15080. */ /**
  15081. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  15082. * @type {Function}
  15083. */ /**
  15084. * @name Highcharts.AxisPointBreakEventObject#target
  15085. * @type {Highcharts.SVGElement}
  15086. */ /**
  15087. * @name Highcharts.AxisPointBreakEventObject#type
  15088. * @type {"pointBreak"|"pointInBreak"}
  15089. */
  15090. /**
  15091. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  15092. *
  15093. * @param {Highcharts.Axis} this
  15094. *
  15095. * @param {Highcharts.AxisSetExtremesEventObject} evt
  15096. */
  15097. /**
  15098. * @interface Highcharts.AxisSetExtremesEventObject
  15099. * @extends Highcharts.ExtremesObject
  15100. */ /**
  15101. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  15102. * @type {Function}
  15103. */ /**
  15104. * @name Highcharts.AxisSetExtremesEventObject#target
  15105. * @type {Highcharts.SVGElement}
  15106. */ /**
  15107. * @name Highcharts.AxisSetExtremesEventObject#trigger
  15108. * @type {Highcharts.AxisExtremesTriggerValue|string}
  15109. */ /**
  15110. * @name Highcharts.AxisSetExtremesEventObject#type
  15111. * @type {"setExtremes"}
  15112. */
  15113. /**
  15114. * @callback Highcharts.AxisTickPositionerCallbackFunction
  15115. *
  15116. * @param {Highcharts.Axis} this
  15117. *
  15118. * @return {Highcharts.AxisTickPositionsArray}
  15119. */
  15120. /**
  15121. * @interface Highcharts.AxisTickPositionsArray
  15122. * @augments Array<number>
  15123. */
  15124. /**
  15125. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  15126. */
  15127. /**
  15128. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  15129. */
  15130. /**
  15131. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  15132. */
  15133. /**
  15134. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  15135. * function.
  15136. *
  15137. * @interface Highcharts.ExtremesObject
  15138. */ /**
  15139. * The maximum value of the axis' associated series.
  15140. * @name Highcharts.ExtremesObject#dataMax
  15141. * @type {number}
  15142. */ /**
  15143. * The minimum value of the axis' associated series.
  15144. * @name Highcharts.ExtremesObject#dataMin
  15145. * @type {number}
  15146. */ /**
  15147. * The maximum axis value, either automatic or set manually. If the `max` option
  15148. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  15149. * the same as `dataMax`.
  15150. * @name Highcharts.ExtremesObject#max
  15151. * @type {number}
  15152. */ /**
  15153. * The minimum axis value, either automatic or set manually. If the `min` option
  15154. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  15155. * the same as `dataMin`.
  15156. * @name Highcharts.ExtremesObject#min
  15157. * @type {number}
  15158. */ /**
  15159. * The user defined maximum, either from the `max` option or from a zoom or
  15160. * `setExtremes` action.
  15161. * @name Highcharts.ExtremesObject#userMax
  15162. * @type {number}
  15163. */ /**
  15164. * The user defined minimum, either from the `min` option or from a zoom or
  15165. * `setExtremes` action.
  15166. * @name Highcharts.ExtremesObject#userMin
  15167. * @type {number}
  15168. */
  15169. /**
  15170. * Formatter function for the text of a crosshair label.
  15171. *
  15172. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  15173. *
  15174. * @param {Highcharts.Axis} this
  15175. * Axis context
  15176. *
  15177. * @param {number} value
  15178. * Y value of the data point
  15179. *
  15180. * @return {string}
  15181. */
  15182. ''; // detach doclets above
  15183. var deg2rad = H.deg2rad;
  15184. /**
  15185. * Create a new axis object. Called internally when instanciating a new chart or
  15186. * adding axes by {@link Highcharts.Chart#addAxis}.
  15187. *
  15188. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  15189. * series cartesian chart, there is one X axis and one Y axis.
  15190. *
  15191. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  15192. * an array of Axis objects. If there is only one axis, it can be referenced
  15193. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  15194. * pattern goes for Y axes.
  15195. *
  15196. * If you need to get the axes from a series object, use the `series.xAxis` and
  15197. * `series.yAxis` properties. These are not arrays, as one series can only be
  15198. * associated to one X and one Y axis.
  15199. *
  15200. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  15201. * the axis configuration options, and get the axis by
  15202. * {@link Highcharts.Chart#get}.
  15203. *
  15204. * Configuration options for the axes are given in options.xAxis and
  15205. * options.yAxis.
  15206. *
  15207. * @class
  15208. * @name Highcharts.Axis
  15209. *
  15210. * @param {Highcharts.Chart} chart
  15211. * The Chart instance to apply the axis on.
  15212. *
  15213. * @param {Highcharts.AxisOptions} userOptions
  15214. * Axis options.
  15215. */
  15216. var Axis = /** @class */ (function () {
  15217. /* *
  15218. *
  15219. * Constructors
  15220. *
  15221. * */
  15222. function Axis(chart, userOptions) {
  15223. this.alternateBands = void 0;
  15224. this.bottom = void 0;
  15225. this.categories = void 0;
  15226. this.chart = void 0;
  15227. this.closestPointRange = void 0;
  15228. this.coll = void 0;
  15229. this.hasNames = void 0;
  15230. this.hasVisibleSeries = void 0;
  15231. this.height = void 0;
  15232. this.isLinked = void 0;
  15233. this.labelEdge = void 0; // @todo
  15234. this.labelFormatter = void 0;
  15235. this.left = void 0;
  15236. this.len = void 0;
  15237. this.max = void 0;
  15238. this.maxLabelLength = void 0;
  15239. this.min = void 0;
  15240. this.minorTickInterval = void 0;
  15241. this.minorTicks = void 0;
  15242. this.minPixelPadding = void 0;
  15243. this.names = void 0;
  15244. this.offset = void 0;
  15245. this.options = void 0;
  15246. this.overlap = void 0;
  15247. this.paddedTicks = void 0;
  15248. this.plotLinesAndBands = void 0;
  15249. this.plotLinesAndBandsGroups = void 0;
  15250. this.pointRange = void 0;
  15251. this.pointRangePadding = void 0;
  15252. this.pos = void 0;
  15253. this.positiveValuesOnly = void 0;
  15254. this.right = void 0;
  15255. this.series = void 0;
  15256. this.side = void 0;
  15257. this.tickAmount = void 0;
  15258. this.tickInterval = void 0;
  15259. this.tickmarkOffset = void 0;
  15260. this.tickPositions = void 0;
  15261. this.tickRotCorr = void 0;
  15262. this.ticks = void 0;
  15263. this.top = void 0;
  15264. this.transA = void 0;
  15265. this.transB = void 0;
  15266. this.translationSlope = void 0;
  15267. this.userOptions = void 0;
  15268. this.visible = void 0;
  15269. this.width = void 0;
  15270. this.zoomEnabled = void 0;
  15271. this.init(chart, userOptions);
  15272. }
  15273. /* *
  15274. *
  15275. * Functions
  15276. *
  15277. * */
  15278. /**
  15279. * Overrideable function to initialize the axis.
  15280. *
  15281. * @see {@link Axis}
  15282. *
  15283. * @function Highcharts.Axis#init
  15284. *
  15285. * @param {Highcharts.Chart} chart
  15286. * The Chart instance to apply the axis on.
  15287. *
  15288. * @param {Highcharts.AxisOptions} userOptions
  15289. * Axis options.
  15290. *
  15291. * @fires Highcharts.Axis#event:afterInit
  15292. * @fires Highcharts.Axis#event:init
  15293. */
  15294. Axis.prototype.init = function (chart, userOptions) {
  15295. var isXAxis = userOptions.isX,
  15296. axis = this;
  15297. /**
  15298. * The Chart that the axis belongs to.
  15299. *
  15300. * @name Highcharts.Axis#chart
  15301. * @type {Highcharts.Chart}
  15302. */
  15303. axis.chart = chart;
  15304. /**
  15305. * Whether the axis is horizontal.
  15306. *
  15307. * @name Highcharts.Axis#horiz
  15308. * @type {boolean|undefined}
  15309. */
  15310. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  15311. /**
  15312. * Whether the axis is the x-axis.
  15313. *
  15314. * @name Highcharts.Axis#isXAxis
  15315. * @type {boolean|undefined}
  15316. */
  15317. axis.isXAxis = isXAxis;
  15318. /**
  15319. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  15320. * or `colorAxis`. Corresponds to properties on Chart, for example
  15321. * {@link Chart.xAxis}.
  15322. *
  15323. * @name Highcharts.Axis#coll
  15324. * @type {string}
  15325. */
  15326. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  15327. fireEvent(this, 'init', { userOptions: userOptions });
  15328. axis.opposite = pick(userOptions.opposite, axis.opposite); // needed in setOptions
  15329. /**
  15330. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  15331. * is bottom and 3 is left.
  15332. *
  15333. * @name Highcharts.Axis#side
  15334. * @type {number}
  15335. */
  15336. axis.side = pick(userOptions.side, axis.side, (axis.horiz ?
  15337. (axis.opposite ? 0 : 2) : // top : bottom
  15338. (axis.opposite ? 1 : 3)) // right : left
  15339. );
  15340. /**
  15341. * Current options for the axis after merge of defaults and user's
  15342. * options.
  15343. *
  15344. * @name Highcharts.Axis#options
  15345. * @type {Highcharts.AxisOptions}
  15346. */
  15347. axis.setOptions(userOptions);
  15348. var options = this.options,
  15349. labelsOptions = options.labels,
  15350. type = options.type;
  15351. /**
  15352. * User's options for this axis without defaults.
  15353. *
  15354. * @name Highcharts.Axis#userOptions
  15355. * @type {Highcharts.AxisOptions}
  15356. */
  15357. axis.userOptions = userOptions;
  15358. axis.minPixelPadding = 0;
  15359. /**
  15360. * Whether the axis is reversed. Based on the `axis.reversed`,
  15361. * option, but inverted charts have reversed xAxis by default.
  15362. *
  15363. * @name Highcharts.Axis#reversed
  15364. * @type {boolean}
  15365. */
  15366. axis.reversed = pick(options.reversed, axis.reversed);
  15367. axis.visible = options.visible;
  15368. axis.zoomEnabled = options.zoomEnabled;
  15369. // Initial categories
  15370. axis.hasNames =
  15371. type === 'category' || options.categories === true;
  15372. /**
  15373. * If categories are present for the axis, names are used instead of
  15374. * numbers for that axis.
  15375. *
  15376. * Since Highcharts 3.0, categories can also be extracted by giving each
  15377. * point a name and setting axis type to `category`. However, if you
  15378. * have multiple series, best practice remains defining the `categories`
  15379. * array.
  15380. *
  15381. * @see [xAxis.categories](/highcharts/xAxis.categories)
  15382. *
  15383. * @name Highcharts.Axis#categories
  15384. * @type {Array<string>}
  15385. * @readonly
  15386. */
  15387. axis.categories = options.categories || axis.hasNames;
  15388. if (!axis.names) { // Preserve on update (#3830)
  15389. axis.names = [];
  15390. axis.names.keys = {};
  15391. }
  15392. // Placeholder for plotlines and plotbands groups
  15393. axis.plotLinesAndBandsGroups = {};
  15394. // Shorthand types
  15395. axis.positiveValuesOnly = !!axis.logarithmic;
  15396. // Flag, if axis is linked to another axis
  15397. axis.isLinked = defined(options.linkedTo);
  15398. /**
  15399. * List of major ticks mapped by postition on axis.
  15400. *
  15401. * @see {@link Highcharts.Tick}
  15402. *
  15403. * @name Highcharts.Axis#ticks
  15404. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15405. */
  15406. axis.ticks = {};
  15407. axis.labelEdge = [];
  15408. /**
  15409. * List of minor ticks mapped by position on the axis.
  15410. *
  15411. * @see {@link Highcharts.Tick}
  15412. *
  15413. * @name Highcharts.Axis#minorTicks
  15414. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15415. */
  15416. axis.minorTicks = {};
  15417. // List of plotLines/Bands
  15418. axis.plotLinesAndBands = [];
  15419. // Alternate bands
  15420. axis.alternateBands = {};
  15421. // Axis metrics
  15422. axis.len = 0;
  15423. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  15424. axis.range = options.range;
  15425. axis.offset = options.offset || 0;
  15426. /**
  15427. * The maximum value of the axis. In a logarithmic axis, this is the
  15428. * logarithm of the real value, and the real value can be obtained from
  15429. * {@link Axis#getExtremes}.
  15430. *
  15431. * @name Highcharts.Axis#max
  15432. * @type {number|null}
  15433. */
  15434. axis.max = null;
  15435. /**
  15436. * The minimum value of the axis. In a logarithmic axis, this is the
  15437. * logarithm of the real value, and the real value can be obtained from
  15438. * {@link Axis#getExtremes}.
  15439. *
  15440. * @name Highcharts.Axis#min
  15441. * @type {number|null}
  15442. */
  15443. axis.min = null;
  15444. /**
  15445. * The processed crosshair options.
  15446. *
  15447. * @name Highcharts.Axis#crosshair
  15448. * @type {boolean|Highcharts.AxisCrosshairOptions}
  15449. */
  15450. var crosshair = pick(options.crosshair,
  15451. splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1]);
  15452. axis.crosshair = crosshair === true ? {} : crosshair;
  15453. var events = axis.options.events;
  15454. // Register. Don't add it again on Axis.update().
  15455. if (chart.axes.indexOf(axis) === -1) { //
  15456. if (isXAxis) { // #2713
  15457. chart.axes.splice(chart.xAxis.length, 0, axis);
  15458. }
  15459. else {
  15460. chart.axes.push(axis);
  15461. }
  15462. chart[axis.coll].push(axis);
  15463. }
  15464. /**
  15465. * All series associated to the axis.
  15466. *
  15467. * @name Highcharts.Axis#series
  15468. * @type {Array<Highcharts.Series>}
  15469. */
  15470. axis.series = axis.series || []; // populated by Series
  15471. // Reversed axis
  15472. if (chart.inverted &&
  15473. !axis.isZAxis &&
  15474. isXAxis &&
  15475. typeof axis.reversed === 'undefined') {
  15476. axis.reversed = true;
  15477. }
  15478. axis.labelRotation = isNumber(labelsOptions.rotation) ?
  15479. labelsOptions.rotation :
  15480. void 0;
  15481. // register event listeners
  15482. objectEach(events, function (event, eventType) {
  15483. if (isFunction(event)) {
  15484. addEvent(axis, eventType, event);
  15485. }
  15486. });
  15487. fireEvent(this, 'afterInit');
  15488. };
  15489. /**
  15490. * Merge and set options.
  15491. *
  15492. * @private
  15493. * @function Highcharts.Axis#setOptions
  15494. *
  15495. * @param {Highcharts.AxisOptions} userOptions
  15496. * Axis options.
  15497. *
  15498. * @fires Highcharts.Axis#event:afterSetOptions
  15499. */
  15500. Axis.prototype.setOptions = function (userOptions) {
  15501. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  15502. Axis.defaultTopAxisOptions,
  15503. Axis.defaultRightAxisOptions,
  15504. Axis.defaultBottomAxisOptions,
  15505. Axis.defaultLeftAxisOptions
  15506. ][this.side], merge(
  15507. // if set in setOptions (#1053):
  15508. defaultOptions[this.coll], userOptions));
  15509. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  15510. };
  15511. /**
  15512. * The default label formatter. The context is a special config object for
  15513. * the label. In apps, use the
  15514. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  15515. * instead, except when a modification is needed.
  15516. *
  15517. * @function Highcharts.Axis#defaultLabelFormatter
  15518. *
  15519. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15520. * Formatter context of axis label.
  15521. *
  15522. * @return {string}
  15523. * The formatted label content.
  15524. */
  15525. Axis.prototype.defaultLabelFormatter = function () {
  15526. var axis = this.axis,
  15527. value = isNumber(this.value) ? this.value : NaN,
  15528. time = axis.chart.time,
  15529. categories = axis.categories,
  15530. dateTimeLabelFormat = this.dateTimeLabelFormat,
  15531. lang = defaultOptions.lang,
  15532. numericSymbols = lang.numericSymbols,
  15533. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  15534. i = numericSymbols && numericSymbols.length,
  15535. multi,
  15536. ret,
  15537. // make sure the same symbol is added for all labels on a linear
  15538. // axis
  15539. numericSymbolDetector = axis.logarithmic ?
  15540. Math.abs(value) :
  15541. axis.tickInterval;
  15542. var chart = this.chart;
  15543. var numberFormatter = chart.numberFormatter;
  15544. if (categories) {
  15545. ret = "" + this.value;
  15546. }
  15547. else if (dateTimeLabelFormat) { // datetime axis
  15548. ret = time.dateFormat(dateTimeLabelFormat, value);
  15549. }
  15550. else if (i && numericSymbolDetector >= 1000) {
  15551. // Decide whether we should add a numeric symbol like k (thousands)
  15552. // or M (millions). If we are to enable this in tooltip or other
  15553. // places as well, we can move this logic to the numberFormatter and
  15554. // enable it by a parameter.
  15555. while (i-- && typeof ret === 'undefined') {
  15556. multi = Math.pow(numSymMagnitude, i + 1);
  15557. if (
  15558. // Only accept a numeric symbol when the distance is more
  15559. // than a full unit. So for example if the symbol is k, we
  15560. // don't accept numbers like 0.5k.
  15561. numericSymbolDetector >= multi &&
  15562. // Accept one decimal before the symbol. Accepts 0.5k but
  15563. // not 0.25k. How does this work with the previous?
  15564. (value * 10) % multi === 0 &&
  15565. numericSymbols[i] !== null &&
  15566. value !== 0) { // #5480
  15567. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  15568. }
  15569. }
  15570. }
  15571. if (typeof ret === 'undefined') {
  15572. if (Math.abs(value) >= 10000) { // add thousands separators
  15573. ret = numberFormatter(value, -1);
  15574. }
  15575. else { // small numbers
  15576. ret = numberFormatter(value, -1, void 0, ''); // #2466
  15577. }
  15578. }
  15579. return ret;
  15580. };
  15581. /**
  15582. * Get the minimum and maximum for the series of each axis. The function
  15583. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  15584. *
  15585. * @private
  15586. * @function Highcharts.Axis#getSeriesExtremes
  15587. *
  15588. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  15589. * @fires Highcharts.Axis#event:getSeriesExtremes
  15590. */
  15591. Axis.prototype.getSeriesExtremes = function () {
  15592. var axis = this,
  15593. chart = axis.chart,
  15594. xExtremes;
  15595. fireEvent(this, 'getSeriesExtremes', null, function () {
  15596. axis.hasVisibleSeries = false;
  15597. // Reset properties in case we're redrawing (#3353)
  15598. axis.dataMin = axis.dataMax = axis.threshold = null;
  15599. axis.softThreshold = !axis.isXAxis;
  15600. if (axis.stacking) {
  15601. axis.stacking.buildStacks();
  15602. }
  15603. // loop through this axis' series
  15604. axis.series.forEach(function (series) {
  15605. if (series.visible ||
  15606. !chart.options.chart.ignoreHiddenSeries) {
  15607. var seriesOptions = series.options,
  15608. xData = void 0,
  15609. threshold = seriesOptions.threshold,
  15610. seriesDataMin = void 0,
  15611. seriesDataMax = void 0;
  15612. axis.hasVisibleSeries = true;
  15613. // Validate threshold in logarithmic axes
  15614. if (axis.positiveValuesOnly && threshold <= 0) {
  15615. threshold = null;
  15616. }
  15617. // Get dataMin and dataMax for X axes
  15618. if (axis.isXAxis) {
  15619. xData = series.xData;
  15620. if (xData.length) {
  15621. var isPositive = function (number) { return number > 0; };
  15622. xData = axis.logarithmic ?
  15623. xData.filter(axis.validatePositiveValue) :
  15624. xData;
  15625. xExtremes = series.getXExtremes(xData);
  15626. // If xData contains values which is not numbers,
  15627. // then filter them out. To prevent performance hit,
  15628. // we only do this after we have already found
  15629. // seriesDataMin because in most cases all data is
  15630. // valid. #5234.
  15631. seriesDataMin = xExtremes.min;
  15632. seriesDataMax = xExtremes.max;
  15633. if (!isNumber(seriesDataMin) &&
  15634. // #5010:
  15635. !(seriesDataMin instanceof Date)) {
  15636. xData = xData.filter(isNumber);
  15637. xExtremes = series.getXExtremes(xData);
  15638. // Do it again with valid data
  15639. seriesDataMin = xExtremes.min;
  15640. seriesDataMax = xExtremes.max;
  15641. }
  15642. if (xData.length) {
  15643. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15644. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15645. }
  15646. }
  15647. // Get dataMin and dataMax for Y axes, as well as handle
  15648. // stacking and processed data
  15649. }
  15650. else {
  15651. // Get this particular series extremes
  15652. var dataExtremes = series.applyExtremes();
  15653. // Get the dataMin and dataMax so far. If percentage is
  15654. // used, the min and max are always 0 and 100. If
  15655. // seriesDataMin and seriesDataMax is null, then series
  15656. // doesn't have active y data, we continue with nulls
  15657. if (isNumber(dataExtremes.dataMin)) {
  15658. seriesDataMin = dataExtremes.dataMin;
  15659. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15660. }
  15661. if (isNumber(dataExtremes.dataMax)) {
  15662. seriesDataMax = dataExtremes.dataMax;
  15663. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15664. }
  15665. // Adjust to threshold
  15666. if (defined(threshold)) {
  15667. axis.threshold = threshold;
  15668. }
  15669. // If any series has a hard threshold, it takes
  15670. // precedence
  15671. if (!seriesOptions.softThreshold ||
  15672. axis.positiveValuesOnly) {
  15673. axis.softThreshold = false;
  15674. }
  15675. }
  15676. }
  15677. });
  15678. });
  15679. fireEvent(this, 'afterGetSeriesExtremes');
  15680. };
  15681. /**
  15682. * Translate from axis value to pixel position on the chart, or back. Use
  15683. * the `toPixels` and `toValue` functions in applications.
  15684. *
  15685. * @private
  15686. * @function Highcharts.Axis#translate
  15687. *
  15688. * @param {number} val
  15689. * TO-DO: parameter description
  15690. *
  15691. * @param {boolean|null} [backwards]
  15692. * TO-DO: parameter description
  15693. *
  15694. * @param {boolean|null} [cvsCoord]
  15695. * TO-DO: parameter description
  15696. *
  15697. * @param {boolean|null} [old]
  15698. * TO-DO: parameter description
  15699. *
  15700. * @param {boolean} [handleLog]
  15701. * TO-DO: parameter description
  15702. *
  15703. * @param {number} [pointPlacement]
  15704. * TO-DO: parameter description
  15705. *
  15706. * @return {number|undefined}
  15707. */
  15708. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  15709. var axis = this.linkedParent || this, // #1417
  15710. sign = 1,
  15711. cvsOffset = 0,
  15712. localA = old && axis.old ? axis.old.transA : axis.transA,
  15713. localMin = old && axis.old ? axis.old.min : axis.min,
  15714. returnValue = 0,
  15715. minPixelPadding = axis.minPixelPadding,
  15716. doPostTranslate = (axis.isOrdinal ||
  15717. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  15718. (axis.logarithmic && handleLog)) && axis.lin2val;
  15719. if (!localA) {
  15720. localA = axis.transA;
  15721. }
  15722. // In vertical axes, the canvas coordinates start from 0 at the top like
  15723. // in SVG.
  15724. if (cvsCoord) {
  15725. sign *= -1; // canvas coordinates inverts the value
  15726. cvsOffset = axis.len;
  15727. }
  15728. // Handle reversed axis
  15729. if (axis.reversed) {
  15730. sign *= -1;
  15731. cvsOffset -= sign * (axis.sector || axis.len);
  15732. }
  15733. // From pixels to value
  15734. if (backwards) { // reverse translation
  15735. val = val * sign + cvsOffset;
  15736. val -= minPixelPadding;
  15737. // from chart pixel to value:
  15738. returnValue = val / localA + localMin;
  15739. if (doPostTranslate) { // log and ordinal axes
  15740. returnValue = axis.lin2val(returnValue);
  15741. }
  15742. // From value to pixels
  15743. }
  15744. else {
  15745. if (doPostTranslate) { // log and ordinal axes
  15746. val = axis.val2lin(val);
  15747. }
  15748. returnValue = isNumber(localMin) ?
  15749. (sign * (val - localMin) * localA +
  15750. cvsOffset +
  15751. (sign * minPixelPadding) +
  15752. (isNumber(pointPlacement) ?
  15753. localA * pointPlacement :
  15754. 0)) :
  15755. void 0;
  15756. }
  15757. return returnValue;
  15758. };
  15759. /**
  15760. * Translate a value in terms of axis units into pixels within the chart.
  15761. *
  15762. * @function Highcharts.Axis#toPixels
  15763. *
  15764. * @param {number} value
  15765. * A value in terms of axis units.
  15766. *
  15767. * @param {boolean} paneCoordinates
  15768. * Whether to return the pixel coordinate relative to the chart or just the
  15769. * axis/pane itself.
  15770. *
  15771. * @return {number}
  15772. * Pixel position of the value on the chart or axis.
  15773. */
  15774. Axis.prototype.toPixels = function (value, paneCoordinates) {
  15775. return this.translate(value, false, !this.horiz, null, true) +
  15776. (paneCoordinates ? 0 : this.pos);
  15777. };
  15778. /**
  15779. * Translate a pixel position along the axis to a value in terms of axis
  15780. * units.
  15781. *
  15782. * @function Highcharts.Axis#toValue
  15783. *
  15784. * @param {number} pixel
  15785. * The pixel value coordinate.
  15786. *
  15787. * @param {boolean} [paneCoordinates=false]
  15788. * Whether the input pixel is relative to the chart or just the axis/pane
  15789. * itself.
  15790. *
  15791. * @return {number}
  15792. * The axis value.
  15793. */
  15794. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  15795. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  15796. };
  15797. /**
  15798. * Create the path for a plot line that goes from the given value on
  15799. * this axis, across the plot to the opposite side. Also used internally for
  15800. * grid lines and crosshairs.
  15801. *
  15802. * @function Highcharts.Axis#getPlotLinePath
  15803. *
  15804. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  15805. * Options for the path.
  15806. *
  15807. * @return {Highcharts.SVGPathArray|null}
  15808. * The SVG path definition for the plot line.
  15809. */
  15810. Axis.prototype.getPlotLinePath = function (options) {
  15811. var axis = this,
  15812. chart = axis.chart,
  15813. axisLeft = axis.left,
  15814. axisTop = axis.top,
  15815. old = options.old,
  15816. value = options.value,
  15817. translatedValue = options.translatedValue,
  15818. lineWidth = options.lineWidth,
  15819. force = options.force,
  15820. x1,
  15821. y1,
  15822. x2,
  15823. y2,
  15824. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  15825. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  15826. skip,
  15827. transB = axis.transB,
  15828. evt;
  15829. // eslint-disable-next-line valid-jsdoc
  15830. /**
  15831. * Check if x is between a and b. If not, either move to a/b
  15832. * or skip, depending on the force parameter.
  15833. * @private
  15834. */
  15835. function between(x, a, b) {
  15836. if (force !== 'pass' && x < a || x > b) {
  15837. if (force) {
  15838. x = clamp(x, a, b);
  15839. }
  15840. else {
  15841. skip = true;
  15842. }
  15843. }
  15844. return x;
  15845. }
  15846. evt = {
  15847. value: value,
  15848. lineWidth: lineWidth,
  15849. old: old,
  15850. force: force,
  15851. acrossPanes: options.acrossPanes,
  15852. translatedValue: translatedValue
  15853. };
  15854. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  15855. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  15856. // Keep the translated value within sane bounds, and avoid Infinity
  15857. // to fail the isNumber test (#7709).
  15858. translatedValue = clamp(translatedValue, -1e5, 1e5);
  15859. x1 = x2 = Math.round(translatedValue + transB);
  15860. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  15861. if (!isNumber(translatedValue)) { // no min or max
  15862. skip = true;
  15863. force = false; // #7175, don't force it when path is invalid
  15864. }
  15865. else if (axis.horiz) {
  15866. y1 = axisTop;
  15867. y2 = cHeight - axis.bottom;
  15868. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  15869. }
  15870. else {
  15871. x1 = axisLeft;
  15872. x2 = cWidth - axis.right;
  15873. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  15874. }
  15875. e.path = skip && !force ?
  15876. null :
  15877. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  15878. });
  15879. return evt.path;
  15880. };
  15881. /**
  15882. * Internal function to get the tick positions of a linear axis to round
  15883. * values like whole tens or every five.
  15884. *
  15885. * @function Highcharts.Axis#getLinearTickPositions
  15886. *
  15887. * @param {number} tickInterval
  15888. * The normalized tick interval.
  15889. *
  15890. * @param {number} min
  15891. * Axis minimum.
  15892. *
  15893. * @param {number} max
  15894. * Axis maximum.
  15895. *
  15896. * @return {Array<number>}
  15897. * An array of axis values where ticks should be placed.
  15898. */
  15899. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  15900. var pos,
  15901. lastPos,
  15902. roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  15903. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  15904. tickPositions = [],
  15905. precision;
  15906. // When the precision is higher than what we filter out in
  15907. // correctFloat, skip it (#6183).
  15908. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  15909. precision = 20;
  15910. }
  15911. // For single points, add a tick regardless of the relative position
  15912. // (#2662, #6274)
  15913. if (this.single) {
  15914. return [min];
  15915. }
  15916. // Populate the intermediate values
  15917. pos = roundedMin;
  15918. while (pos <= roundedMax) {
  15919. // Place the tick on the rounded value
  15920. tickPositions.push(pos);
  15921. // Always add the raw tickInterval, not the corrected one.
  15922. pos = correctFloat(pos + tickInterval, precision);
  15923. // If the interval is not big enough in the current min - max range
  15924. // to actually increase the loop variable, we need to break out to
  15925. // prevent endless loop. Issue #619
  15926. if (pos === lastPos) {
  15927. break;
  15928. }
  15929. // Record the last value
  15930. lastPos = pos;
  15931. }
  15932. return tickPositions;
  15933. };
  15934. /**
  15935. * Resolve the new minorTicks/minorTickInterval options into the legacy
  15936. * loosely typed minorTickInterval option.
  15937. *
  15938. * @function Highcharts.Axis#getMinorTickInterval
  15939. *
  15940. * @return {number|"auto"|null}
  15941. */
  15942. Axis.prototype.getMinorTickInterval = function () {
  15943. var options = this.options;
  15944. if (options.minorTicks === true) {
  15945. return pick(options.minorTickInterval, 'auto');
  15946. }
  15947. if (options.minorTicks === false) {
  15948. return null;
  15949. }
  15950. return options.minorTickInterval;
  15951. };
  15952. /**
  15953. * Internal function to return the minor tick positions. For logarithmic
  15954. * axes, the same logic as for major ticks is reused.
  15955. *
  15956. * @function Highcharts.Axis#getMinorTickPositions
  15957. *
  15958. * @return {Array<number>}
  15959. * An array of axis values where ticks should be placed.
  15960. */
  15961. Axis.prototype.getMinorTickPositions = function () {
  15962. var axis = this,
  15963. options = axis.options,
  15964. tickPositions = axis.tickPositions,
  15965. minorTickInterval = axis.minorTickInterval,
  15966. minorTickPositions = [],
  15967. pos,
  15968. pointRangePadding = axis.pointRangePadding || 0,
  15969. min = axis.min - pointRangePadding, // #1498
  15970. max = axis.max + pointRangePadding, // #1498
  15971. range = max - min;
  15972. // If minor ticks get too dense, they are hard to read, and may cause
  15973. // long running script. So we don't draw them.
  15974. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  15975. var logarithmic_1 = axis.logarithmic;
  15976. if (logarithmic_1) {
  15977. // For each interval in the major ticks, compute the minor ticks
  15978. // separately.
  15979. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  15980. if (i) {
  15981. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  15982. }
  15983. });
  15984. }
  15985. else if (axis.dateTime &&
  15986. this.getMinorTickInterval() === 'auto') { // #1314
  15987. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  15988. }
  15989. else {
  15990. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  15991. // Very, very, tight grid lines (#5771)
  15992. if (pos === minorTickPositions[0]) {
  15993. break;
  15994. }
  15995. minorTickPositions.push(pos);
  15996. }
  15997. }
  15998. }
  15999. if (minorTickPositions.length !== 0) {
  16000. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  16001. }
  16002. return minorTickPositions;
  16003. };
  16004. /**
  16005. * Adjust the min and max for the minimum range. Keep in mind that the
  16006. * series data is not yet processed, so we don't have information on data
  16007. * cropping and grouping, or updated `axis.pointRange` or
  16008. * `series.pointRange`. The data can't be processed until we have finally
  16009. * established min and max.
  16010. *
  16011. * @private
  16012. * @function Highcharts.Axis#adjustForMinRange
  16013. */
  16014. Axis.prototype.adjustForMinRange = function () {
  16015. var axis = this,
  16016. options = axis.options,
  16017. min = axis.min,
  16018. max = axis.max,
  16019. log = axis.logarithmic,
  16020. zoomOffset,
  16021. spaceAvailable,
  16022. closestDataRange = 0,
  16023. i,
  16024. distance,
  16025. xData,
  16026. loopLength,
  16027. minArgs,
  16028. maxArgs,
  16029. minRange;
  16030. // Set the automatic minimum range based on the closest point distance
  16031. if (axis.isXAxis &&
  16032. typeof axis.minRange === 'undefined' &&
  16033. !log) {
  16034. if (defined(options.min) || defined(options.max)) {
  16035. axis.minRange = null; // don't do this again
  16036. }
  16037. else {
  16038. // Find the closest distance between raw data points, as opposed
  16039. // to closestPointRange that applies to processed points
  16040. // (cropped and grouped)
  16041. axis.series.forEach(function (series) {
  16042. xData = series.xData;
  16043. loopLength = series.xIncrement ? 1 : xData.length - 1;
  16044. if (xData.length > 1) {
  16045. for (i = loopLength; i > 0; i--) {
  16046. distance = xData[i] - xData[i - 1];
  16047. if (!closestDataRange || distance < closestDataRange) {
  16048. closestDataRange = distance;
  16049. }
  16050. }
  16051. }
  16052. });
  16053. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  16054. }
  16055. }
  16056. // if minRange is exceeded, adjust
  16057. if (max - min < axis.minRange) {
  16058. spaceAvailable =
  16059. axis.dataMax - axis.dataMin >=
  16060. axis.minRange;
  16061. minRange = axis.minRange;
  16062. zoomOffset = (minRange - max + min) / 2;
  16063. // if min and max options have been set, don't go beyond it
  16064. minArgs = [
  16065. min - zoomOffset,
  16066. pick(options.min, min - zoomOffset)
  16067. ];
  16068. // If space is available, stay within the data range
  16069. if (spaceAvailable) {
  16070. minArgs[2] = axis.logarithmic ?
  16071. axis.logarithmic.log2lin(axis.dataMin) :
  16072. axis.dataMin;
  16073. }
  16074. min = arrayMax(minArgs);
  16075. maxArgs = [
  16076. min + minRange,
  16077. pick(options.max, min + minRange)
  16078. ];
  16079. // If space is availabe, stay within the data range
  16080. if (spaceAvailable) {
  16081. maxArgs[2] = log ?
  16082. log.log2lin(axis.dataMax) :
  16083. axis.dataMax;
  16084. }
  16085. max = arrayMin(maxArgs);
  16086. // now if the max is adjusted, adjust the min back
  16087. if (max - min < minRange) {
  16088. minArgs[0] = max - minRange;
  16089. minArgs[1] = pick(options.min, max - minRange);
  16090. min = arrayMax(minArgs);
  16091. }
  16092. }
  16093. // Record modified extremes
  16094. axis.min = min;
  16095. axis.max = max;
  16096. };
  16097. // eslint-disable-next-line valid-jsdoc
  16098. /**
  16099. * Find the closestPointRange across all series.
  16100. *
  16101. * @private
  16102. * @function Highcharts.Axis#getClosest
  16103. */
  16104. Axis.prototype.getClosest = function () {
  16105. var ret;
  16106. if (this.categories) {
  16107. ret = 1;
  16108. }
  16109. else {
  16110. this.series.forEach(function (series) {
  16111. var seriesClosest = series.closestPointRange,
  16112. visible = series.visible ||
  16113. !series.chart.options.chart.ignoreHiddenSeries;
  16114. if (!series.noSharedTooltip &&
  16115. defined(seriesClosest) &&
  16116. visible) {
  16117. ret = defined(ret) ?
  16118. Math.min(ret, seriesClosest) :
  16119. seriesClosest;
  16120. }
  16121. });
  16122. }
  16123. return ret;
  16124. };
  16125. /**
  16126. * When a point name is given and no x, search for the name in the existing
  16127. * categories, or if categories aren't provided, search names or create a
  16128. * new category (#2522).
  16129. * @private
  16130. * @function Highcharts.Axis#nameToX
  16131. *
  16132. * @param {Highcharts.Point} point
  16133. * The point to inspect.
  16134. *
  16135. * @return {number}
  16136. * The X value that the point is given.
  16137. */
  16138. Axis.prototype.nameToX = function (point) {
  16139. var explicitCategories = isArray(this.categories),
  16140. names = explicitCategories ? this.categories : this.names,
  16141. nameX = point.options.x,
  16142. x;
  16143. point.series.requireSorting = false;
  16144. if (!defined(nameX)) {
  16145. nameX = this.options.uniqueNames ?
  16146. (explicitCategories ?
  16147. names.indexOf(point.name) :
  16148. pick(names.keys[point.name], -1)) :
  16149. point.series.autoIncrement();
  16150. }
  16151. if (nameX === -1) { // Not found in currenct categories
  16152. if (!explicitCategories) {
  16153. x = names.length;
  16154. }
  16155. }
  16156. else {
  16157. x = nameX;
  16158. }
  16159. // Write the last point's name to the names array
  16160. if (typeof x !== 'undefined') {
  16161. this.names[x] = point.name;
  16162. // Backwards mapping is much faster than array searching (#7725)
  16163. this.names.keys[point.name] = x;
  16164. }
  16165. return x;
  16166. };
  16167. /**
  16168. * When changes have been done to series data, update the axis.names.
  16169. *
  16170. * @private
  16171. * @function Highcharts.Axis#updateNames
  16172. */
  16173. Axis.prototype.updateNames = function () {
  16174. var axis = this,
  16175. names = this.names,
  16176. i = names.length;
  16177. if (i > 0) {
  16178. Object.keys(names.keys).forEach(function (key) {
  16179. delete (names.keys)[key];
  16180. });
  16181. names.length = 0;
  16182. this.minRange = this.userMinRange; // Reset
  16183. (this.series || []).forEach(function (series) {
  16184. // Reset incrementer (#5928)
  16185. series.xIncrement = null;
  16186. // When adding a series, points are not yet generated
  16187. if (!series.points || series.isDirtyData) {
  16188. // When we're updating the series with data that is longer
  16189. // than it was, and cropThreshold is passed, we need to make
  16190. // sure that the axis.max is increased _before_ running the
  16191. // premature processData. Otherwise this early iteration of
  16192. // processData will crop the points to axis.max, and the
  16193. // names array will be too short (#5857).
  16194. axis.max = Math.max(axis.max, series.xData.length - 1);
  16195. series.processData();
  16196. series.generatePoints();
  16197. }
  16198. series.data.forEach(function (point, i) {
  16199. var x;
  16200. if (point &&
  16201. point.options &&
  16202. typeof point.name !== 'undefined' // #9562
  16203. ) {
  16204. x = axis.nameToX(point);
  16205. if (typeof x !== 'undefined' && x !== point.x) {
  16206. point.x = x;
  16207. series.xData[i] = x;
  16208. }
  16209. }
  16210. });
  16211. });
  16212. }
  16213. };
  16214. /**
  16215. * Update translation information.
  16216. *
  16217. * @private
  16218. * @function Highcharts.Axis#setAxisTranslation
  16219. *
  16220. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  16221. */
  16222. Axis.prototype.setAxisTranslation = function () {
  16223. var axis = this,
  16224. range = axis.max - axis.min,
  16225. pointRange = axis.axisPointRange || 0,
  16226. closestPointRange,
  16227. minPointOffset = 0,
  16228. pointRangePadding = 0,
  16229. linkedParent = axis.linkedParent,
  16230. ordinalCorrection,
  16231. hasCategories = !!axis.categories,
  16232. transA = axis.transA,
  16233. isXAxis = axis.isXAxis;
  16234. // Adjust translation for padding. Y axis with categories need to go
  16235. // through the same (#1784).
  16236. if (isXAxis || hasCategories || pointRange) {
  16237. // Get the closest points
  16238. closestPointRange = axis.getClosest();
  16239. if (linkedParent) {
  16240. minPointOffset = linkedParent.minPointOffset;
  16241. pointRangePadding = linkedParent.pointRangePadding;
  16242. }
  16243. else {
  16244. axis.series.forEach(function (series) {
  16245. var seriesPointRange = hasCategories ?
  16246. 1 :
  16247. (isXAxis ?
  16248. pick(series.options.pointRange,
  16249. closestPointRange, 0) :
  16250. (axis.axisPointRange || 0)), // #2806
  16251. pointPlacement = series.options.pointPlacement;
  16252. pointRange = Math.max(pointRange, seriesPointRange);
  16253. if (!axis.single || hasCategories) {
  16254. // TODO: series should internally set x- and y-
  16255. // pointPlacement to simplify this logic.
  16256. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  16257. // minPointOffset is the value padding to the left of
  16258. // the axis in order to make room for points with a
  16259. // pointRange, typically columns. When the
  16260. // pointPlacement option is 'between' or 'on', this
  16261. // padding does not apply.
  16262. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  16263. 0 :
  16264. seriesPointRange / 2);
  16265. // Determine the total padding needed to the length of
  16266. // the axis to make room for the pointRange. If the
  16267. // series' pointPlacement is 'on', no padding is added.
  16268. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  16269. 0 :
  16270. seriesPointRange);
  16271. }
  16272. });
  16273. }
  16274. // Record minPointOffset and pointRangePadding
  16275. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  16276. axis.ordinal.slope / closestPointRange :
  16277. 1; // #988, #1853
  16278. axis.minPointOffset = minPointOffset =
  16279. minPointOffset * ordinalCorrection;
  16280. axis.pointRangePadding =
  16281. pointRangePadding = pointRangePadding * ordinalCorrection;
  16282. // pointRange means the width reserved for each point, like in a
  16283. // column chart
  16284. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  16285. // closestPointRange means the closest distance between points. In
  16286. // columns it is mostly equal to pointRange, but in lines pointRange
  16287. // is 0 while closestPointRange is some other value
  16288. if (isXAxis) {
  16289. axis.closestPointRange = closestPointRange;
  16290. }
  16291. }
  16292. // Secondary values
  16293. axis.translationSlope = axis.transA = transA =
  16294. axis.staticScale ||
  16295. axis.len / ((range + pointRangePadding) || 1);
  16296. // Translation addend
  16297. axis.transB = axis.horiz ? axis.left : axis.bottom;
  16298. axis.minPixelPadding = transA * minPointOffset;
  16299. fireEvent(this, 'afterSetAxisTranslation');
  16300. };
  16301. /**
  16302. * @private
  16303. * @function Highcharts.Axis#minFromRange
  16304. *
  16305. * @return {number}
  16306. */
  16307. Axis.prototype.minFromRange = function () {
  16308. var axis = this;
  16309. return axis.max - axis.range;
  16310. };
  16311. /**
  16312. * Set the tick positions to round values and optionally extend the extremes
  16313. * to the nearest tick.
  16314. *
  16315. * @private
  16316. * @function Highcharts.Axis#setTickInterval
  16317. *
  16318. * @param {boolean} secondPass
  16319. * TO-DO: parameter description
  16320. *
  16321. * @fires Highcharts.Axis#event:foundExtremes
  16322. */
  16323. Axis.prototype.setTickInterval = function (secondPass) {
  16324. var axis = this,
  16325. chart = axis.chart,
  16326. log = axis.logarithmic,
  16327. options = axis.options,
  16328. isXAxis = axis.isXAxis,
  16329. isLinked = axis.isLinked,
  16330. maxPadding = options.maxPadding,
  16331. minPadding = options.minPadding,
  16332. length,
  16333. linkedParentExtremes,
  16334. tickIntervalOption = options.tickInterval,
  16335. minTickInterval,
  16336. tickPixelIntervalOption = options.tickPixelInterval,
  16337. categories = axis.categories,
  16338. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  16339. softThreshold = axis.softThreshold,
  16340. thresholdMin,
  16341. thresholdMax,
  16342. hardMin,
  16343. hardMax;
  16344. if (!axis.dateTime && !categories && !isLinked) {
  16345. this.getTickAmount();
  16346. }
  16347. // Min or max set either by zooming/setExtremes or initial options
  16348. hardMin = pick(axis.userMin, options.min);
  16349. hardMax = pick(axis.userMax, options.max);
  16350. // Linked axis gets the extremes from the parent axis
  16351. if (isLinked) {
  16352. axis.linkedParent = chart[axis.coll][options.linkedTo];
  16353. linkedParentExtremes = axis.linkedParent.getExtremes();
  16354. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  16355. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  16356. if (options.type !== axis.linkedParent.options.type) {
  16357. // Can't link axes of different type
  16358. error(11, 1, chart);
  16359. }
  16360. // Initial min and max from the extreme data values
  16361. }
  16362. else {
  16363. // Adjust to hard threshold
  16364. if (softThreshold && defined(threshold)) {
  16365. if (axis.dataMin >= threshold) {
  16366. thresholdMin = threshold;
  16367. minPadding = 0;
  16368. }
  16369. else if (axis.dataMax <= threshold) {
  16370. thresholdMax = threshold;
  16371. maxPadding = 0;
  16372. }
  16373. }
  16374. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  16375. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  16376. }
  16377. if (log) {
  16378. if (axis.positiveValuesOnly &&
  16379. !secondPass &&
  16380. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  16381. // Can't plot negative values on log axis
  16382. error(10, 1, chart);
  16383. }
  16384. // The correctFloat cures #934, float errors on full tens. But it
  16385. // was too aggressive for #4360 because of conversion back to lin,
  16386. // therefore use precision 15.
  16387. axis.min = correctFloat(log.log2lin(axis.min), 16);
  16388. axis.max = correctFloat(log.log2lin(axis.max), 16);
  16389. }
  16390. // handle zoomed range
  16391. if (axis.range && defined(axis.max)) {
  16392. // #618, #6773:
  16393. axis.userMin = axis.min = hardMin =
  16394. Math.max(axis.dataMin, axis.minFromRange());
  16395. axis.userMax = hardMax = axis.max;
  16396. axis.range = null; // don't use it when running setExtremes
  16397. }
  16398. // Hook for Highcharts Stock Scroller.
  16399. // Consider combining with beforePadding.
  16400. fireEvent(axis, 'foundExtremes');
  16401. // Hook for adjusting this.min and this.max. Used by bubble series.
  16402. if (axis.beforePadding) {
  16403. axis.beforePadding();
  16404. }
  16405. // adjust min and max for the minimum range
  16406. axis.adjustForMinRange();
  16407. // Pad the values to get clear of the chart's edges. To avoid
  16408. // tickInterval taking the padding into account, we do this after
  16409. // computing tick interval (#1337).
  16410. if (!categories &&
  16411. !axis.axisPointRange &&
  16412. !(axis.stacking && axis.stacking.usePercentage) &&
  16413. !isLinked &&
  16414. defined(axis.min) &&
  16415. defined(axis.max)) {
  16416. length = axis.max - axis.min;
  16417. if (length) {
  16418. if (!defined(hardMin) && minPadding) {
  16419. axis.min -= length * minPadding;
  16420. }
  16421. if (!defined(hardMax) && maxPadding) {
  16422. axis.max += length * maxPadding;
  16423. }
  16424. }
  16425. }
  16426. // Handle options for floor, ceiling, softMin and softMax (#6359)
  16427. if (!isNumber(axis.userMin)) {
  16428. if (isNumber(options.softMin) && options.softMin < axis.min) {
  16429. axis.min = hardMin = options.softMin; // #6894
  16430. }
  16431. if (isNumber(options.floor)) {
  16432. axis.min = Math.max(axis.min, options.floor);
  16433. }
  16434. }
  16435. if (!isNumber(axis.userMax)) {
  16436. if (isNumber(options.softMax) && options.softMax > axis.max) {
  16437. axis.max = hardMax = options.softMax; // #6894
  16438. }
  16439. if (isNumber(options.ceiling)) {
  16440. axis.max = Math.min(axis.max, options.ceiling);
  16441. }
  16442. }
  16443. // When the threshold is soft, adjust the extreme value only if the data
  16444. // extreme and the padded extreme land on either side of the threshold.
  16445. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  16446. // for -1 because of the default minPadding and startOnTick options.
  16447. // This is prevented by the softThreshold option.
  16448. if (softThreshold && defined(axis.dataMin)) {
  16449. threshold = threshold || 0;
  16450. if (!defined(hardMin) &&
  16451. axis.min < threshold &&
  16452. axis.dataMin >= threshold) {
  16453. axis.min = axis.options.minRange ?
  16454. Math.min(threshold, axis.max -
  16455. axis.minRange) :
  16456. threshold;
  16457. }
  16458. else if (!defined(hardMax) &&
  16459. axis.max > threshold &&
  16460. axis.dataMax <= threshold) {
  16461. axis.max = axis.options.minRange ?
  16462. Math.max(threshold, axis.min +
  16463. axis.minRange) :
  16464. threshold;
  16465. }
  16466. }
  16467. // If min is bigger than highest, or if max less than lowest value, the
  16468. // chart should not render points. (#14417)
  16469. if (isNumber(axis.min) &&
  16470. isNumber(axis.max) &&
  16471. !this.chart.polar &&
  16472. (axis.min > axis.max)) {
  16473. if (defined(axis.options.min)) {
  16474. axis.max = axis.min;
  16475. }
  16476. else if (defined(axis.options.max)) {
  16477. axis.min = axis.max;
  16478. }
  16479. }
  16480. // get tickInterval
  16481. if (axis.min === axis.max ||
  16482. typeof axis.min === 'undefined' ||
  16483. typeof axis.max === 'undefined') {
  16484. axis.tickInterval = 1;
  16485. }
  16486. else if (isLinked &&
  16487. axis.linkedParent &&
  16488. !tickIntervalOption &&
  16489. tickPixelIntervalOption ===
  16490. axis.linkedParent.options.tickPixelInterval) {
  16491. axis.tickInterval = tickIntervalOption =
  16492. axis.linkedParent.tickInterval;
  16493. }
  16494. else {
  16495. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  16496. ((axis.max - axis.min) /
  16497. Math.max(this.tickAmount - 1, 1)) :
  16498. void 0,
  16499. // For categoried axis, 1 is default, for linear axis use
  16500. // tickPix
  16501. categories ?
  16502. 1 :
  16503. // don't let it be more than the data range
  16504. (axis.max - axis.min) *
  16505. tickPixelIntervalOption /
  16506. Math.max(axis.len, tickPixelIntervalOption));
  16507. }
  16508. // Now we're finished detecting min and max, crop and group series data.
  16509. // This is in turn needed in order to find tick positions in ordinal
  16510. // axes.
  16511. if (isXAxis && !secondPass) {
  16512. axis.series.forEach(function (series) {
  16513. series.processData(axis.min !== (axis.old && axis.old.min) ||
  16514. axis.max !== (axis.old && axis.old.max));
  16515. });
  16516. }
  16517. // set the translation factor used in translate function
  16518. axis.setAxisTranslation();
  16519. // hook for ordinal axes and radial axes
  16520. fireEvent(this, 'initialAxisTranslation');
  16521. // In column-like charts, don't cramp in more ticks than there are
  16522. // points (#1943, #4184)
  16523. if (axis.pointRange && !tickIntervalOption) {
  16524. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  16525. }
  16526. // Before normalizing the tick interval, handle minimum tick interval.
  16527. // This applies only if tickInterval is not defined.
  16528. minTickInterval = pick(options.minTickInterval,
  16529. // In datetime axes, don't go below the data interval, except when
  16530. // there are scatter-like series involved (#13369).
  16531. axis.dateTime &&
  16532. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  16533. axis.closestPointRange : 0);
  16534. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  16535. axis.tickInterval = minTickInterval;
  16536. }
  16537. // for linear axes, get magnitude and normalize the interval
  16538. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  16539. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  16540. // If the tick interval is greather than 0.5, avoid
  16541. // decimals, as linear axes are often used to render
  16542. // discrete values. #3363. If a tick amount is set, allow
  16543. // decimals by default, as it increases the chances for a
  16544. // good fit.
  16545. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  16546. }
  16547. // Prevent ticks from getting so close that we can't draw the labels
  16548. if (!this.tickAmount) {
  16549. axis.tickInterval = axis.unsquish();
  16550. }
  16551. this.setTickPositions();
  16552. };
  16553. /**
  16554. * Now we have computed the normalized tickInterval, get the tick positions.
  16555. *
  16556. * @private
  16557. * @function Highcharts.Axis#setTickPositions
  16558. *
  16559. * @fires Highcharts.Axis#event:afterSetTickPositions
  16560. */
  16561. Axis.prototype.setTickPositions = function () {
  16562. var axis = this,
  16563. options = this.options,
  16564. tickPositions,
  16565. tickPositionsOption = options.tickPositions,
  16566. minorTickIntervalOption = this.getMinorTickInterval(),
  16567. tickPositioner = options.tickPositioner,
  16568. hasVerticalPanning = this.hasVerticalPanning(),
  16569. isColorAxis = this.coll === 'colorAxis',
  16570. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  16571. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  16572. // Set the tickmarkOffset
  16573. this.tickmarkOffset = (this.categories &&
  16574. options.tickmarkPlacement === 'between' &&
  16575. this.tickInterval === 1) ? 0.5 : 0; // #3202
  16576. // get minorTickInterval
  16577. this.minorTickInterval =
  16578. minorTickIntervalOption === 'auto' &&
  16579. this.tickInterval ?
  16580. this.tickInterval / 5 :
  16581. minorTickIntervalOption;
  16582. // When there is only one point, or all points have the same value on
  16583. // this axis, then min and max are equal and tickPositions.length is 0
  16584. // or 1. In this case, add some padding in order to center the point,
  16585. // but leave it with one tick. #1337.
  16586. this.single =
  16587. this.min === this.max &&
  16588. defined(this.min) &&
  16589. !this.tickAmount &&
  16590. (
  16591. // Data is on integer (#6563)
  16592. parseInt(this.min, 10) === this.min ||
  16593. // Between integers and decimals are not allowed (#6274)
  16594. options.allowDecimals !== false);
  16595. /**
  16596. * Contains the current positions that are laid out on the axis. The
  16597. * positions are numbers in terms of axis values. In a category axis
  16598. * they are integers, in a datetime axis they are also integers, but
  16599. * designating milliseconds.
  16600. *
  16601. * This property is read only - for modifying the tick positions, use
  16602. * the `tickPositioner` callback or [axis.tickPositions(
  16603. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  16604. * instead.
  16605. *
  16606. * @name Highcharts.Axis#tickPositions
  16607. * @type {Highcharts.AxisTickPositionsArray|undefined}
  16608. */
  16609. this.tickPositions =
  16610. // Find the tick positions. Work on a copy (#1565)
  16611. tickPositions =
  16612. (tickPositionsOption && tickPositionsOption.slice());
  16613. if (!tickPositions) {
  16614. // Too many ticks (#6405). Create a friendly warning and provide two
  16615. // ticks so at least we can show the data series.
  16616. if ((!axis.ordinal || !axis.ordinal.positions) &&
  16617. ((this.max - this.min) /
  16618. this.tickInterval >
  16619. Math.max(2 * this.len, 200))) {
  16620. tickPositions = [this.min, this.max];
  16621. error(19, false, this.chart);
  16622. }
  16623. else if (axis.dateTime) {
  16624. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  16625. }
  16626. else if (axis.logarithmic) {
  16627. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  16628. }
  16629. else {
  16630. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  16631. }
  16632. // Too dense ticks, keep only the first and last (#4477)
  16633. if (tickPositions.length > this.len) {
  16634. tickPositions = [tickPositions[0], tickPositions.pop()];
  16635. // Reduce doubled value (#7339)
  16636. if (tickPositions[0] === tickPositions[1]) {
  16637. tickPositions.length = 1;
  16638. }
  16639. }
  16640. this.tickPositions = tickPositions;
  16641. // Run the tick positioner callback, that allows modifying auto tick
  16642. // positions.
  16643. if (tickPositioner) {
  16644. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  16645. if (tickPositioner) {
  16646. this.tickPositions = tickPositions = tickPositioner;
  16647. }
  16648. }
  16649. }
  16650. // Reset min/max or remove extremes based on start/end on tick
  16651. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  16652. this.trimTicks(tickPositions, startOnTick, endOnTick);
  16653. if (!this.isLinked) {
  16654. // Substract half a unit (#2619, #2846, #2515, #3390),
  16655. // but not in case of multiple ticks (#6897)
  16656. if (this.single &&
  16657. tickPositions.length < 2 &&
  16658. !this.categories &&
  16659. !this.series.some(function (s) {
  16660. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  16661. })) {
  16662. this.min -= 0.5;
  16663. this.max += 0.5;
  16664. }
  16665. if (!tickPositionsOption && !tickPositioner) {
  16666. this.adjustTickAmount();
  16667. }
  16668. }
  16669. fireEvent(this, 'afterSetTickPositions');
  16670. };
  16671. /**
  16672. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  16673. * rounded min/max. Also handle single data points.
  16674. *
  16675. * @private
  16676. * @function Highcharts.Axis#trimTicks
  16677. *
  16678. * @param {Array<number>} tickPositions
  16679. * TO-DO: parameter description
  16680. *
  16681. * @param {boolean} [startOnTick]
  16682. * TO-DO: parameter description
  16683. *
  16684. * @param {boolean} [endOnTick]
  16685. * TO-DO: parameter description
  16686. */
  16687. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  16688. var roundedMin = tickPositions[0],
  16689. roundedMax = tickPositions[tickPositions.length - 1],
  16690. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  16691. fireEvent(this, 'trimTicks');
  16692. if (!this.isLinked) {
  16693. if (startOnTick && roundedMin !== -Infinity) { // #6502
  16694. this.min = roundedMin;
  16695. }
  16696. else {
  16697. while (this.min - minPointOffset > tickPositions[0]) {
  16698. tickPositions.shift();
  16699. }
  16700. }
  16701. if (endOnTick) {
  16702. this.max = roundedMax;
  16703. }
  16704. else {
  16705. while (this.max + minPointOffset <
  16706. tickPositions[tickPositions.length - 1]) {
  16707. tickPositions.pop();
  16708. }
  16709. }
  16710. // If no tick are left, set one tick in the middle (#3195)
  16711. if (tickPositions.length === 0 &&
  16712. defined(roundedMin) &&
  16713. !this.options.tickPositions) {
  16714. tickPositions.push((roundedMax + roundedMin) / 2);
  16715. }
  16716. }
  16717. };
  16718. /**
  16719. * Check if there are multiple axes in the same pane.
  16720. *
  16721. * @private
  16722. * @function Highcharts.Axis#alignToOthers
  16723. *
  16724. * @return {boolean|undefined}
  16725. * True if there are other axes.
  16726. */
  16727. Axis.prototype.alignToOthers = function () {
  16728. var axis = this,
  16729. others = // Whether there is another axis to pair with this one
  16730. {},
  16731. hasOther,
  16732. options = axis.options;
  16733. if (
  16734. // Only if alignTicks is true
  16735. this.chart.options.chart.alignTicks !== false &&
  16736. options.alignTicks &&
  16737. // Disabled when startOnTick or endOnTick are false (#7604)
  16738. options.startOnTick !== false &&
  16739. options.endOnTick !== false &&
  16740. // Don't try to align ticks on a log axis, they are not evenly
  16741. // spaced (#6021)
  16742. !axis.logarithmic) {
  16743. this.chart[this.coll].forEach(function (axis) {
  16744. var otherOptions = axis.options, horiz = axis.horiz, key = [
  16745. horiz ? otherOptions.left : otherOptions.top,
  16746. otherOptions.width,
  16747. otherOptions.height,
  16748. otherOptions.pane
  16749. ].join(',');
  16750. if (axis.series.length) { // #4442
  16751. if (others[key]) {
  16752. hasOther = true; // #4201
  16753. }
  16754. else {
  16755. others[key] = 1;
  16756. }
  16757. }
  16758. });
  16759. }
  16760. return hasOther;
  16761. };
  16762. /**
  16763. * Find the max ticks of either the x and y axis collection, and record it
  16764. * in `this.tickAmount`.
  16765. *
  16766. * @private
  16767. * @function Highcharts.Axis#getTickAmount
  16768. */
  16769. Axis.prototype.getTickAmount = function () {
  16770. var axis = this,
  16771. options = this.options,
  16772. tickAmount = options.tickAmount,
  16773. tickPixelInterval = options.tickPixelInterval;
  16774. if (!defined(options.tickInterval) &&
  16775. !tickAmount &&
  16776. this.len < tickPixelInterval &&
  16777. !this.isRadial &&
  16778. !axis.logarithmic &&
  16779. options.startOnTick &&
  16780. options.endOnTick) {
  16781. tickAmount = 2;
  16782. }
  16783. if (!tickAmount && this.alignToOthers()) {
  16784. // Add 1 because 4 tick intervals require 5 ticks (including first
  16785. // and last)
  16786. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  16787. }
  16788. // For tick amounts of 2 and 3, compute five ticks and remove the
  16789. // intermediate ones. This prevents the axis from adding ticks that are
  16790. // too far away from the data extremes.
  16791. if (tickAmount < 4) {
  16792. this.finalTickAmt = tickAmount;
  16793. tickAmount = 5;
  16794. }
  16795. this.tickAmount = tickAmount;
  16796. };
  16797. /**
  16798. * When using multiple axes, adjust the number of ticks to match the highest
  16799. * number of ticks in that group.
  16800. *
  16801. * @private
  16802. * @function Highcharts.Axis#adjustTickAmount
  16803. */
  16804. Axis.prototype.adjustTickAmount = function () {
  16805. var axis = this,
  16806. axisOptions = axis.options,
  16807. tickInterval = axis.tickInterval,
  16808. tickPositions = axis.tickPositions,
  16809. tickAmount = axis.tickAmount,
  16810. finalTickAmt = axis.finalTickAmt,
  16811. currentTickAmount = tickPositions && tickPositions.length,
  16812. threshold = pick(axis.threshold,
  16813. axis.softThreshold ? 0 : null),
  16814. len,
  16815. i;
  16816. if (axis.hasData() && isNumber(axis.min) && isNumber(axis.max)) { // #14769
  16817. if (currentTickAmount < tickAmount) {
  16818. while (tickPositions.length < tickAmount) {
  16819. // Extend evenly for both sides unless we're on the
  16820. // threshold (#3965)
  16821. if (tickPositions.length % 2 ||
  16822. axis.min === threshold) {
  16823. // to the end
  16824. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  16825. tickInterval));
  16826. }
  16827. else {
  16828. // to the start
  16829. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  16830. }
  16831. }
  16832. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  16833. // Do not crop when ticks are not extremes (#9841)
  16834. axis.min = axisOptions.startOnTick ?
  16835. tickPositions[0] :
  16836. Math.min(axis.min, tickPositions[0]);
  16837. axis.max = axisOptions.endOnTick ?
  16838. tickPositions[tickPositions.length - 1] :
  16839. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  16840. // We have too many ticks, run second pass to try to reduce ticks
  16841. }
  16842. else if (currentTickAmount > tickAmount) {
  16843. axis.tickInterval *= 2;
  16844. axis.setTickPositions();
  16845. }
  16846. // The finalTickAmt property is set in getTickAmount
  16847. if (defined(finalTickAmt)) {
  16848. i = len = tickPositions.length;
  16849. while (i--) {
  16850. if (
  16851. // Remove every other tick
  16852. (finalTickAmt === 3 && i % 2 === 1) ||
  16853. // Remove all but first and last
  16854. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  16855. tickPositions.splice(i, 1);
  16856. }
  16857. }
  16858. axis.finalTickAmt = void 0;
  16859. }
  16860. }
  16861. };
  16862. /**
  16863. * Set the scale based on data min and max, user set min and max or options.
  16864. *
  16865. * @private
  16866. * @function Highcharts.Axis#setScale
  16867. *
  16868. * @fires Highcharts.Axis#event:afterSetScale
  16869. */
  16870. Axis.prototype.setScale = function () {
  16871. var axis = this,
  16872. isDirtyAxisLength,
  16873. isDirtyData = false,
  16874. isXAxisDirty = false;
  16875. axis.series.forEach(function (series) {
  16876. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  16877. // When x axis is dirty, we need new data extremes for y as
  16878. // well:
  16879. isXAxisDirty = (isXAxisDirty ||
  16880. (series.xAxis && series.xAxis.isDirty) ||
  16881. false);
  16882. });
  16883. // set the new axisLength
  16884. axis.setAxisSize();
  16885. isDirtyAxisLength = axis.len !== (axis.old && axis.old.len);
  16886. // do we really need to go through all this?
  16887. if (isDirtyAxisLength ||
  16888. isDirtyData ||
  16889. isXAxisDirty ||
  16890. axis.isLinked ||
  16891. axis.forceRedraw ||
  16892. axis.userMin !== (axis.old && axis.old.userMin) ||
  16893. axis.userMax !== (axis.old && axis.old.userMax) ||
  16894. axis.alignToOthers()) {
  16895. if (axis.stacking) {
  16896. axis.stacking.resetStacks();
  16897. }
  16898. axis.forceRedraw = false;
  16899. // get data extremes if needed
  16900. axis.getSeriesExtremes();
  16901. // get fixed positions based on tickInterval
  16902. axis.setTickInterval();
  16903. // Mark as dirty if it is not already set to dirty and extremes have
  16904. // changed. #595.
  16905. if (!axis.isDirty) {
  16906. axis.isDirty =
  16907. isDirtyAxisLength ||
  16908. axis.min !== (axis.old && axis.old.min) ||
  16909. axis.max !== (axis.old && axis.old.max);
  16910. }
  16911. }
  16912. else if (axis.stacking) {
  16913. axis.stacking.cleanStacks();
  16914. }
  16915. // Recalculate panning state object, when the data
  16916. // has changed. It is required when vertical panning is enabled.
  16917. if (isDirtyData && axis.panningState) {
  16918. axis.panningState.isDirty = true;
  16919. }
  16920. fireEvent(this, 'afterSetScale');
  16921. };
  16922. /**
  16923. * Set the minimum and maximum of the axes after render time. If the
  16924. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  16925. * values are rounded off to the nearest tick. To prevent this, these
  16926. * options can be set to false before calling setExtremes. Also, setExtremes
  16927. * will not allow a range lower than the `minRange` option, which by default
  16928. * is the range of five points.
  16929. *
  16930. * @sample highcharts/members/axis-setextremes/
  16931. * Set extremes from a button
  16932. * @sample highcharts/members/axis-setextremes-datetime/
  16933. * Set extremes on a datetime axis
  16934. * @sample highcharts/members/axis-setextremes-off-ticks/
  16935. * Set extremes off ticks
  16936. * @sample stock/members/axis-setextremes/
  16937. * Set extremes in Highcharts Stock
  16938. * @sample maps/members/axis-setextremes/
  16939. * Set extremes in Highmaps
  16940. *
  16941. * @function Highcharts.Axis#setExtremes
  16942. *
  16943. * @param {number} [newMin]
  16944. * The new minimum value.
  16945. *
  16946. * @param {number} [newMax]
  16947. * The new maximum value.
  16948. *
  16949. * @param {boolean} [redraw=true]
  16950. * Whether to redraw the chart or wait for an explicit call to
  16951. * {@link Highcharts.Chart#redraw}
  16952. *
  16953. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  16954. * Enable or modify animations.
  16955. *
  16956. * @param {*} [eventArguments]
  16957. * Arguments to be accessed in event handler.
  16958. *
  16959. * @fires Highcharts.Axis#event:setExtremes
  16960. */
  16961. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  16962. var axis = this,
  16963. chart = axis.chart;
  16964. redraw = pick(redraw, true); // defaults to true
  16965. axis.series.forEach(function (serie) {
  16966. delete serie.kdTree;
  16967. });
  16968. // Extend the arguments with min and max
  16969. eventArguments = extend(eventArguments, {
  16970. min: newMin,
  16971. max: newMax
  16972. });
  16973. // Fire the event
  16974. fireEvent(axis, 'setExtremes', eventArguments, function () {
  16975. axis.userMin = newMin;
  16976. axis.userMax = newMax;
  16977. axis.eventArgs = eventArguments;
  16978. if (redraw) {
  16979. chart.redraw(animation);
  16980. }
  16981. });
  16982. };
  16983. /**
  16984. * Overridable method for zooming chart. Pulled out in a separate method to
  16985. * allow overriding in stock charts.
  16986. * @private
  16987. * @function Highcharts.Axis#zoom
  16988. *
  16989. * @param {number} newMin
  16990. * TO-DO: parameter description
  16991. *
  16992. * @param {number} newMax
  16993. * TO-DO: parameter description
  16994. *
  16995. * @return {boolean}
  16996. */
  16997. Axis.prototype.zoom = function (newMin, newMax) {
  16998. var axis = this,
  16999. dataMin = this.dataMin,
  17000. dataMax = this.dataMax,
  17001. options = this.options,
  17002. min = Math.min(dataMin,
  17003. pick(options.min,
  17004. dataMin)),
  17005. max = Math.max(dataMax,
  17006. pick(options.max,
  17007. dataMax)),
  17008. evt = {
  17009. newMin: newMin,
  17010. newMax: newMax
  17011. };
  17012. fireEvent(this, 'zoom', evt, function (e) {
  17013. // Use e.newMin and e.newMax - event handlers may have altered them
  17014. var newMin = e.newMin,
  17015. newMax = e.newMax;
  17016. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  17017. // Prevent pinch zooming out of range. Check for defined is for
  17018. // #1946. #1734.
  17019. if (!axis.allowZoomOutside) {
  17020. // #6014, sometimes newMax will be smaller than min (or
  17021. // newMin will be larger than max).
  17022. if (defined(dataMin)) {
  17023. if (newMin < min) {
  17024. newMin = min;
  17025. }
  17026. if (newMin > max) {
  17027. newMin = max;
  17028. }
  17029. }
  17030. if (defined(dataMax)) {
  17031. if (newMax < min) {
  17032. newMax = min;
  17033. }
  17034. if (newMax > max) {
  17035. newMax = max;
  17036. }
  17037. }
  17038. }
  17039. // In full view, displaying the reset zoom button is not
  17040. // required
  17041. axis.displayBtn = (typeof newMin !== 'undefined' ||
  17042. typeof newMax !== 'undefined');
  17043. // Do it
  17044. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  17045. }
  17046. e.zoomed = true;
  17047. });
  17048. return evt.zoomed;
  17049. };
  17050. /**
  17051. * Update the axis metrics.
  17052. *
  17053. * @private
  17054. * @function Highcharts.Axis#setAxisSize
  17055. */
  17056. Axis.prototype.setAxisSize = function () {
  17057. var chart = this.chart,
  17058. options = this.options,
  17059. // [top, right, bottom, left]
  17060. offsets = options.offsets || [0, 0, 0, 0],
  17061. horiz = this.horiz,
  17062. // Check for percentage based input values. Rounding fixes problems
  17063. // with column overflow and plot line filtering (#4898, #4899)
  17064. width = this.width = Math.round(relativeLength(pick(options.width,
  17065. chart.plotWidth - offsets[3] + offsets[1]),
  17066. chart.plotWidth)),
  17067. height = this.height = Math.round(relativeLength(pick(options.height,
  17068. chart.plotHeight - offsets[0] + offsets[2]),
  17069. chart.plotHeight)),
  17070. top = this.top = Math.round(relativeLength(pick(options.top,
  17071. chart.plotTop + offsets[0]),
  17072. chart.plotHeight,
  17073. chart.plotTop)),
  17074. left = this.left = Math.round(relativeLength(pick(options.left,
  17075. chart.plotLeft + offsets[3]),
  17076. chart.plotWidth,
  17077. chart.plotLeft));
  17078. // Expose basic values to use in Series object and navigator
  17079. this.bottom = chart.chartHeight - height - top;
  17080. this.right = chart.chartWidth - width - left;
  17081. // Direction agnostic properties
  17082. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  17083. this.pos = horiz ? left : top; // distance from SVG origin
  17084. };
  17085. /**
  17086. * Get the current extremes for the axis.
  17087. *
  17088. * @sample highcharts/members/axis-getextremes/
  17089. * Report extremes by click on a button
  17090. * @sample maps/members/axis-getextremes/
  17091. * Get extremes in Highmaps
  17092. *
  17093. * @function Highcharts.Axis#getExtremes
  17094. *
  17095. * @return {Highcharts.ExtremesObject}
  17096. * An object containing extremes information.
  17097. */
  17098. Axis.prototype.getExtremes = function () {
  17099. var axis = this;
  17100. var log = axis.logarithmic;
  17101. return {
  17102. min: log ?
  17103. correctFloat(log.lin2log(axis.min)) :
  17104. axis.min,
  17105. max: log ?
  17106. correctFloat(log.lin2log(axis.max)) :
  17107. axis.max,
  17108. dataMin: axis.dataMin,
  17109. dataMax: axis.dataMax,
  17110. userMin: axis.userMin,
  17111. userMax: axis.userMax
  17112. };
  17113. };
  17114. /**
  17115. * Get the zero plane either based on zero or on the min or max value.
  17116. * Used in bar and area plots.
  17117. *
  17118. * @function Highcharts.Axis#getThreshold
  17119. *
  17120. * @param {number} threshold
  17121. * The threshold in axis values.
  17122. *
  17123. * @return {number|undefined}
  17124. * The translated threshold position in terms of pixels, and corrected to
  17125. * stay within the axis bounds.
  17126. */
  17127. Axis.prototype.getThreshold = function (threshold) {
  17128. var axis = this,
  17129. log = axis.logarithmic,
  17130. realMin = log ? log.lin2log(axis.min) : axis.min,
  17131. realMax = log ? log.lin2log(axis.max) : axis.max;
  17132. if (threshold === null || threshold === -Infinity) {
  17133. threshold = realMin;
  17134. }
  17135. else if (threshold === Infinity) {
  17136. threshold = realMax;
  17137. }
  17138. else if (realMin > threshold) {
  17139. threshold = realMin;
  17140. }
  17141. else if (realMax < threshold) {
  17142. threshold = realMax;
  17143. }
  17144. return axis.translate(threshold, 0, 1, 0, 1);
  17145. };
  17146. /**
  17147. * Compute auto alignment for the axis label based on which side the axis is
  17148. * on and the given rotation for the label.
  17149. *
  17150. * @private
  17151. * @function Highcharts.Axis#autoLabelAlign
  17152. *
  17153. * @param {number} rotation
  17154. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  17155. * options.
  17156. *
  17157. * @return {Highcharts.AlignValue}
  17158. * Can be `"center"`, `"left"` or `"right"`.
  17159. */
  17160. Axis.prototype.autoLabelAlign = function (rotation) {
  17161. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  17162. evt = { align: 'center' };
  17163. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  17164. if (angle > 15 && angle < 165) {
  17165. e.align = 'right';
  17166. }
  17167. else if (angle > 195 && angle < 345) {
  17168. e.align = 'left';
  17169. }
  17170. });
  17171. return evt.align;
  17172. };
  17173. /**
  17174. * Get the tick length and width for the axis based on axis options.
  17175. * @private
  17176. * @function Highcharts.Axis#tickSize
  17177. *
  17178. * @param {string} [prefix]
  17179. * 'tick' or 'minorTick'
  17180. *
  17181. * @return {Array<number,number>|undefined}
  17182. * An array of tickLength and tickWidth
  17183. */
  17184. Axis.prototype.tickSize = function (prefix) {
  17185. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  17186. // Default to 1 on linear and datetime X axes
  17187. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  17188. if (tickWidth && tickLength) {
  17189. // Negate the length
  17190. if (options[prefix + 'Position'] === 'inside') {
  17191. tickLength = -tickLength;
  17192. }
  17193. tickSize = [tickLength, tickWidth];
  17194. }
  17195. e = { tickSize: tickSize };
  17196. fireEvent(this, 'afterTickSize', e);
  17197. return e.tickSize;
  17198. };
  17199. /**
  17200. * Return the size of the labels.
  17201. *
  17202. * @private
  17203. * @function Highcharts.Axis#labelMetrics
  17204. *
  17205. * @return {Highcharts.FontMetricsObject}
  17206. */
  17207. Axis.prototype.labelMetrics = function () {
  17208. var index = this.tickPositions && this.tickPositions[0] || 0;
  17209. return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  17210. };
  17211. /**
  17212. * Prevent the ticks from getting so close we can't draw the labels. On a
  17213. * horizontal axis, this is handled by rotating the labels, removing ticks
  17214. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  17215. *
  17216. * @private
  17217. * @function Highcharts.Axis#unsquish
  17218. *
  17219. * @return {number}
  17220. */
  17221. Axis.prototype.unsquish = function () {
  17222. var labelOptions = this.options.labels,
  17223. horiz = this.horiz,
  17224. tickInterval = this.tickInterval,
  17225. newTickInterval = tickInterval,
  17226. slotSize = this.len / (((this.categories ? 1 : 0) +
  17227. this.max -
  17228. this.min) /
  17229. tickInterval),
  17230. rotation,
  17231. rotationOption = labelOptions.rotation,
  17232. labelMetrics = this.labelMetrics(),
  17233. step,
  17234. bestScore = Number.MAX_VALUE,
  17235. autoRotation,
  17236. range = Math.max(this.max - this.min, 0),
  17237. // Return the multiple of tickInterval that is needed to avoid
  17238. // collision
  17239. getStep = function (spaceNeeded) {
  17240. var step = spaceNeeded / (slotSize || 1);
  17241. step = step > 1 ? Math.ceil(step) : 1;
  17242. // Guard for very small or negative angles (#9835)
  17243. if (step * tickInterval > range &&
  17244. spaceNeeded !== Infinity &&
  17245. slotSize !== Infinity &&
  17246. range) {
  17247. step = Math.ceil(range / tickInterval);
  17248. }
  17249. return correctFloat(step * tickInterval);
  17250. };
  17251. if (horiz) {
  17252. if (!labelOptions.staggerLines && !labelOptions.step) {
  17253. if (isNumber(rotationOption)) {
  17254. autoRotation = [rotationOption];
  17255. }
  17256. else if (slotSize < labelOptions.autoRotationLimit) {
  17257. autoRotation = labelOptions.autoRotation;
  17258. }
  17259. }
  17260. if (autoRotation) {
  17261. // Loop over the given autoRotation options, and determine
  17262. // which gives the best score. The best score is that with
  17263. // the lowest number of steps and a rotation closest
  17264. // to horizontal.
  17265. autoRotation.forEach(function (rot) {
  17266. var score;
  17267. if (rot === rotationOption ||
  17268. (rot && rot >= -90 && rot <= 90)) { // #3891
  17269. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  17270. score = step + Math.abs(rot / 360);
  17271. if (score < bestScore) {
  17272. bestScore = score;
  17273. rotation = rot;
  17274. newTickInterval = step;
  17275. }
  17276. }
  17277. });
  17278. }
  17279. }
  17280. else if (!labelOptions.step) { // #4411
  17281. newTickInterval = getStep(labelMetrics.h);
  17282. }
  17283. this.autoRotation = autoRotation;
  17284. this.labelRotation = pick(rotation, isNumber(rotationOption) ? rotationOption : 0);
  17285. return newTickInterval;
  17286. };
  17287. /**
  17288. * Get the general slot width for labels/categories on this axis. This may
  17289. * change between the pre-render (from Axis.getOffset) and the final tick
  17290. * rendering and placement.
  17291. *
  17292. * @private
  17293. * @function Highcharts.Axis#getSlotWidth
  17294. *
  17295. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  17296. * basing on tick label. It is used in highcharts-3d module, where the slots
  17297. * has different widths depending on perspective angles.
  17298. *
  17299. * @return {number}
  17300. * The pixel width allocated to each axis label.
  17301. */
  17302. Axis.prototype.getSlotWidth = function (tick) {
  17303. // #5086, #1580, #1931
  17304. var chart = this.chart,
  17305. horiz = this.horiz,
  17306. labelOptions = this.options.labels,
  17307. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  17308. marginLeft = chart.margin[3];
  17309. // Used by grid axis
  17310. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  17311. return tick.slotWidth;
  17312. }
  17313. if (horiz && labelOptions.step < 2) {
  17314. if (labelOptions.rotation) { // #4415
  17315. return 0;
  17316. }
  17317. return ((this.staggerLines || 1) * this.len) / slotCount;
  17318. }
  17319. if (!horiz) {
  17320. // #7028
  17321. var cssWidth = labelOptions.style.width;
  17322. if (cssWidth !== void 0) {
  17323. return parseInt(String(cssWidth), 10);
  17324. }
  17325. if (marginLeft) {
  17326. return marginLeft - chart.spacing[3];
  17327. }
  17328. }
  17329. // Last resort, a fraction of the available size
  17330. return chart.chartWidth * 0.33;
  17331. };
  17332. /**
  17333. * Render the axis labels and determine whether ellipsis or rotation need to
  17334. * be applied.
  17335. *
  17336. * @private
  17337. * @function Highcharts.Axis#renderUnsquish
  17338. */
  17339. Axis.prototype.renderUnsquish = function () {
  17340. var chart = this.chart,
  17341. renderer = chart.renderer,
  17342. tickPositions = this.tickPositions,
  17343. ticks = this.ticks,
  17344. labelOptions = this.options.labels,
  17345. labelStyleOptions = labelOptions.style,
  17346. horiz = this.horiz,
  17347. slotWidth = this.getSlotWidth(),
  17348. innerWidth = Math.max(1,
  17349. Math.round(slotWidth - 2 * labelOptions.padding)),
  17350. attr = {},
  17351. labelMetrics = this.labelMetrics(),
  17352. textOverflowOption = labelStyleOptions.textOverflow,
  17353. commonWidth,
  17354. commonTextOverflow,
  17355. maxLabelLength = 0,
  17356. label,
  17357. i,
  17358. pos;
  17359. // Set rotation option unless it is "auto", like in gauges
  17360. if (!isString(labelOptions.rotation)) {
  17361. // #4443
  17362. attr.rotation = labelOptions.rotation || 0;
  17363. }
  17364. // Get the longest label length
  17365. tickPositions.forEach(function (tickPosition) {
  17366. var tick = ticks[tickPosition];
  17367. // Replace label - sorting animation
  17368. if (tick.movedLabel) {
  17369. tick.replaceMovedLabel();
  17370. }
  17371. if (tick &&
  17372. tick.label &&
  17373. tick.label.textPxLength > maxLabelLength) {
  17374. maxLabelLength = tick.label.textPxLength;
  17375. }
  17376. });
  17377. this.maxLabelLength = maxLabelLength;
  17378. // Handle auto rotation on horizontal axis
  17379. if (this.autoRotation) {
  17380. // Apply rotation only if the label is too wide for the slot, and
  17381. // the label is wider than its height.
  17382. if (maxLabelLength > innerWidth &&
  17383. maxLabelLength > labelMetrics.h) {
  17384. attr.rotation = this.labelRotation;
  17385. }
  17386. else {
  17387. this.labelRotation = 0;
  17388. }
  17389. // Handle word-wrap or ellipsis on vertical axis
  17390. }
  17391. else if (slotWidth) {
  17392. // For word-wrap or ellipsis
  17393. commonWidth = innerWidth;
  17394. if (!textOverflowOption) {
  17395. commonTextOverflow = 'clip';
  17396. // On vertical axis, only allow word wrap if there is room
  17397. // for more lines.
  17398. i = tickPositions.length;
  17399. while (!horiz && i--) {
  17400. pos = tickPositions[i];
  17401. label = ticks[pos].label;
  17402. if (label) {
  17403. // Reset ellipsis in order to get the correct
  17404. // bounding box (#4070)
  17405. if (label.styles &&
  17406. label.styles.textOverflow === 'ellipsis') {
  17407. label.css({ textOverflow: 'clip' });
  17408. // Set the correct width in order to read
  17409. // the bounding box height (#4678, #5034)
  17410. }
  17411. else if (label.textPxLength > slotWidth) {
  17412. label.css({ width: slotWidth + 'px' });
  17413. }
  17414. if (label.getBBox().height > (this.len / tickPositions.length -
  17415. (labelMetrics.h - labelMetrics.f))) {
  17416. label.specificTextOverflow = 'ellipsis';
  17417. }
  17418. }
  17419. }
  17420. }
  17421. }
  17422. // Add ellipsis if the label length is significantly longer than ideal
  17423. if (attr.rotation) {
  17424. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  17425. chart.chartHeight * 0.33 :
  17426. maxLabelLength);
  17427. if (!textOverflowOption) {
  17428. commonTextOverflow = 'ellipsis';
  17429. }
  17430. }
  17431. // Set the explicit or automatic label alignment
  17432. this.labelAlign = labelOptions.align ||
  17433. this.autoLabelAlign(this.labelRotation);
  17434. if (this.labelAlign) {
  17435. attr.align = this.labelAlign;
  17436. }
  17437. // Apply general and specific CSS
  17438. tickPositions.forEach(function (pos) {
  17439. var tick = ticks[pos],
  17440. label = tick && tick.label,
  17441. widthOption = labelStyleOptions.width,
  17442. css = {};
  17443. if (label) {
  17444. // This needs to go before the CSS in old IE (#4502)
  17445. label.attr(attr);
  17446. if (tick.shortenLabel) {
  17447. tick.shortenLabel();
  17448. }
  17449. else if (commonWidth &&
  17450. !widthOption &&
  17451. // Setting width in this case messes with the bounding box
  17452. // (#7975)
  17453. labelStyleOptions.whiteSpace !== 'nowrap' &&
  17454. (
  17455. // Speed optimizing, #7656
  17456. commonWidth < label.textPxLength ||
  17457. // Resetting CSS, #4928
  17458. label.element.tagName === 'SPAN')) {
  17459. css.width = commonWidth + 'px';
  17460. if (!textOverflowOption) {
  17461. css.textOverflow = (label.specificTextOverflow ||
  17462. commonTextOverflow);
  17463. }
  17464. label.css(css);
  17465. // Reset previously shortened label (#8210)
  17466. }
  17467. else if (label.styles &&
  17468. label.styles.width &&
  17469. !css.width &&
  17470. !widthOption) {
  17471. label.css({ width: null });
  17472. }
  17473. delete label.specificTextOverflow;
  17474. tick.rotation = attr.rotation;
  17475. }
  17476. }, this);
  17477. // Note: Why is this not part of getLabelPosition?
  17478. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  17479. };
  17480. /**
  17481. * Return true if the axis has associated data.
  17482. *
  17483. * @function Highcharts.Axis#hasData
  17484. *
  17485. * @return {boolean}
  17486. * True if the axis has associated visible series and those series have
  17487. * either valid data points or explicit `min` and `max` settings.
  17488. */
  17489. Axis.prototype.hasData = function () {
  17490. return this.series.some(function (s) {
  17491. return s.hasData();
  17492. }) ||
  17493. (this.options.showEmpty &&
  17494. defined(this.min) &&
  17495. defined(this.max));
  17496. };
  17497. /**
  17498. * Adds the title defined in axis.options.title.
  17499. *
  17500. * @function Highcharts.Axis#addTitle
  17501. *
  17502. * @param {boolean} [display]
  17503. * Whether or not to display the title.
  17504. */
  17505. Axis.prototype.addTitle = function (display) {
  17506. var axis = this,
  17507. renderer = axis.chart.renderer,
  17508. horiz = axis.horiz,
  17509. opposite = axis.opposite,
  17510. options = axis.options,
  17511. axisTitleOptions = options.title,
  17512. textAlign,
  17513. styledMode = axis.chart.styledMode;
  17514. if (!axis.axisTitle) {
  17515. textAlign = axisTitleOptions.textAlign;
  17516. if (!textAlign) {
  17517. textAlign = (horiz ? {
  17518. low: 'left',
  17519. middle: 'center',
  17520. high: 'right'
  17521. } : {
  17522. low: opposite ? 'right' : 'left',
  17523. middle: 'center',
  17524. high: opposite ? 'left' : 'right'
  17525. })[axisTitleOptions.align];
  17526. }
  17527. axis.axisTitle = renderer
  17528. .text(axisTitleOptions.text || '', 0, 0, axisTitleOptions.useHTML)
  17529. .attr({
  17530. zIndex: 7,
  17531. rotation: axisTitleOptions.rotation,
  17532. align: textAlign
  17533. })
  17534. .addClass('highcharts-axis-title');
  17535. // #7814, don't mutate style option
  17536. if (!styledMode) {
  17537. axis.axisTitle.css(merge(axisTitleOptions.style));
  17538. }
  17539. axis.axisTitle.add(axis.axisGroup);
  17540. axis.axisTitle.isNew = true;
  17541. }
  17542. // Max width defaults to the length of the axis
  17543. if (!styledMode &&
  17544. !axisTitleOptions.style.width &&
  17545. !axis.isRadial) {
  17546. axis.axisTitle.css({
  17547. width: axis.len + 'px'
  17548. });
  17549. }
  17550. // hide or show the title depending on whether showEmpty is set
  17551. axis.axisTitle[display ? 'show' : 'hide'](display);
  17552. };
  17553. /**
  17554. * Generates a tick for initial positioning.
  17555. *
  17556. * @private
  17557. * @function Highcharts.Axis#generateTick
  17558. *
  17559. * @param {number} pos
  17560. * The tick position in axis values.
  17561. *
  17562. * @param {number} [i]
  17563. * The index of the tick in {@link Axis.tickPositions}.
  17564. */
  17565. Axis.prototype.generateTick = function (pos) {
  17566. var axis = this;
  17567. var ticks = axis.ticks;
  17568. if (!ticks[pos]) {
  17569. ticks[pos] = new Tick(axis, pos);
  17570. }
  17571. else {
  17572. ticks[pos].addLabel(); // update labels depending on tick interval
  17573. }
  17574. };
  17575. /**
  17576. * Render the tick labels to a preliminary position to get their sizes
  17577. *
  17578. * @private
  17579. * @function Highcharts.Axis#getOffset
  17580. *
  17581. * @fires Highcharts.Axis#event:afterGetOffset
  17582. */
  17583. Axis.prototype.getOffset = function () {
  17584. var _this = this;
  17585. var axis = this,
  17586. chart = axis.chart,
  17587. renderer = chart.renderer,
  17588. options = axis.options,
  17589. tickPositions = axis.tickPositions,
  17590. ticks = axis.ticks,
  17591. horiz = axis.horiz,
  17592. side = axis.side,
  17593. invertedSide = chart.inverted &&
  17594. !axis.isZAxis ? [1, 0, 3, 2][side] : side,
  17595. hasData,
  17596. showAxis,
  17597. titleOffset = 0,
  17598. titleOffsetOption,
  17599. titleMargin = 0,
  17600. axisTitleOptions = options.title,
  17601. labelOptions = options.labels,
  17602. labelOffset = 0, // reset
  17603. labelOffsetPadded,
  17604. axisOffset = chart.axisOffset,
  17605. clipOffset = chart.clipOffset,
  17606. clip,
  17607. directionFactor = [-1, 1, 1, -1][side],
  17608. className = options.className,
  17609. axisParent = axis.axisParent, // Used in color axis
  17610. lineHeightCorrection;
  17611. // For reuse in Axis.render
  17612. hasData = axis.hasData();
  17613. axis.showAxis = showAxis = hasData || options.showEmpty;
  17614. // Set/reset staggerLines
  17615. axis.staggerLines = (axis.horiz && labelOptions.staggerLines) || void 0;
  17616. // Create the axisGroup and gridGroup elements on first iteration
  17617. if (!axis.axisGroup) {
  17618. var createGroup = function (name,
  17619. suffix,
  17620. zIndex) { return renderer.g(name)
  17621. .attr({ zIndex: zIndex })
  17622. .addClass("highcharts-" + _this.coll.toLowerCase() + suffix + " " +
  17623. (_this.isRadial ? "highcharts-radial-axis" + suffix + " " : '') +
  17624. (className || ''))
  17625. .add(axisParent); };
  17626. axis.gridGroup = createGroup('grid', '-grid', options.gridZIndex);
  17627. axis.axisGroup = createGroup('axis', '', options.zIndex);
  17628. axis.labelGroup = createGroup('axis-labels', '-labels', labelOptions.zIndex);
  17629. }
  17630. if (hasData || axis.isLinked) {
  17631. // Generate ticks
  17632. tickPositions.forEach(function (pos, i) {
  17633. // i is not used here, but may be used in overrides
  17634. axis.generateTick(pos, i);
  17635. });
  17636. axis.renderUnsquish();
  17637. // Left side must be align: right and right side must
  17638. // have align: left for labels
  17639. axis.reserveSpaceDefault = (side === 0 ||
  17640. side === 2 ||
  17641. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  17642. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  17643. tickPositions.forEach(function (pos) {
  17644. // get the highest offset
  17645. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  17646. });
  17647. }
  17648. if (axis.staggerLines) {
  17649. labelOffset *= axis.staggerLines;
  17650. }
  17651. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  17652. }
  17653. else { // doesn't have data
  17654. objectEach(ticks, function (tick, n) {
  17655. tick.destroy();
  17656. delete ticks[n];
  17657. });
  17658. }
  17659. if (axisTitleOptions &&
  17660. axisTitleOptions.text &&
  17661. axisTitleOptions.enabled !== false) {
  17662. axis.addTitle(showAxis);
  17663. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  17664. axis.titleOffset = titleOffset =
  17665. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  17666. titleOffsetOption = axisTitleOptions.offset;
  17667. titleMargin = defined(titleOffsetOption) ?
  17668. 0 :
  17669. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  17670. }
  17671. }
  17672. // Render the axis line
  17673. axis.renderLine();
  17674. // handle automatic or user set offset
  17675. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  17676. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  17677. if (side === 0) {
  17678. lineHeightCorrection = -axis.labelMetrics().h;
  17679. }
  17680. else if (side === 2) {
  17681. lineHeightCorrection = axis.tickRotCorr.y;
  17682. }
  17683. else {
  17684. lineHeightCorrection = 0;
  17685. }
  17686. // Find the padded label offset
  17687. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  17688. if (labelOffset) {
  17689. labelOffsetPadded -= lineHeightCorrection;
  17690. labelOffsetPadded += directionFactor * (horiz ?
  17691. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  17692. labelOptions.x);
  17693. }
  17694. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  17695. if (axis.getMaxLabelDimensions) {
  17696. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  17697. }
  17698. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  17699. // has rendered.
  17700. var tickSize = this.tickSize('tick');
  17701. axisOffset[side] = Math.max(axisOffset[side], (axis.axisTitleMargin || 0) + titleOffset +
  17702. directionFactor * axis.offset, labelOffsetPadded, // #3027
  17703. tickPositions && tickPositions.length && tickSize ?
  17704. tickSize[0] + directionFactor * axis.offset :
  17705. 0 // #4866
  17706. );
  17707. // Decide the clipping needed to keep the graph inside
  17708. // the plot area and axis lines
  17709. clip = options.offset ?
  17710. 0 :
  17711. // #4308, #4371:
  17712. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  17713. clipOffset[invertedSide] =
  17714. Math.max(clipOffset[invertedSide], clip);
  17715. fireEvent(this, 'afterGetOffset');
  17716. };
  17717. /**
  17718. * Internal function to get the path for the axis line. Extended for polar
  17719. * charts.
  17720. *
  17721. * @function Highcharts.Axis#getLinePath
  17722. *
  17723. * @param {number} lineWidth
  17724. * The line width in pixels.
  17725. *
  17726. * @return {Highcharts.SVGPathArray}
  17727. * The SVG path definition in array form.
  17728. */
  17729. Axis.prototype.getLinePath = function (lineWidth) {
  17730. var chart = this.chart,
  17731. opposite = this.opposite,
  17732. offset = this.offset,
  17733. horiz = this.horiz,
  17734. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  17735. lineTop = chart.chartHeight - this.bottom -
  17736. (opposite ? this.height : 0) + offset;
  17737. if (opposite) {
  17738. lineWidth *= -1; // crispify the other way - #1480, #1687
  17739. }
  17740. return chart.renderer
  17741. .crispLine([
  17742. [
  17743. 'M',
  17744. horiz ?
  17745. this.left :
  17746. lineLeft,
  17747. horiz ?
  17748. lineTop :
  17749. this.top
  17750. ],
  17751. [
  17752. 'L',
  17753. horiz ?
  17754. chart.chartWidth - this.right :
  17755. lineLeft,
  17756. horiz ?
  17757. lineTop :
  17758. chart.chartHeight - this.bottom
  17759. ]
  17760. ], lineWidth);
  17761. };
  17762. /**
  17763. * Render the axis line. Called internally when rendering and redrawing the
  17764. * axis.
  17765. *
  17766. * @function Highcharts.Axis#renderLine
  17767. */
  17768. Axis.prototype.renderLine = function () {
  17769. if (!this.axisLine) {
  17770. this.axisLine = this.chart.renderer.path()
  17771. .addClass('highcharts-axis-line')
  17772. .add(this.axisGroup);
  17773. if (!this.chart.styledMode) {
  17774. this.axisLine.attr({
  17775. stroke: this.options.lineColor,
  17776. 'stroke-width': this.options.lineWidth,
  17777. zIndex: 7
  17778. });
  17779. }
  17780. }
  17781. };
  17782. /**
  17783. * Position the axis title.
  17784. *
  17785. * @private
  17786. * @function Highcharts.Axis#getTitlePosition
  17787. *
  17788. * @return {Highcharts.PositionObject}
  17789. * X and Y positions for the title.
  17790. */
  17791. Axis.prototype.getTitlePosition = function () {
  17792. // compute anchor points for each of the title align options
  17793. var horiz = this.horiz,
  17794. axisLeft = this.left,
  17795. axisTop = this.top,
  17796. axisLength = this.len,
  17797. axisTitleOptions = this.options.title,
  17798. margin = horiz ? axisLeft : axisTop,
  17799. opposite = this.opposite,
  17800. offset = this.offset,
  17801. xOption = axisTitleOptions.x,
  17802. yOption = axisTitleOptions.y,
  17803. axisTitle = this.axisTitle,
  17804. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style.fontSize,
  17805. axisTitle),
  17806. // The part of a multiline text that is below the baseline of the
  17807. // first line. Subtract 1 to preserve pixel-perfectness from the
  17808. // old behaviour (v5.0.12), where only one line was allowed.
  17809. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  17810. // the position in the length direction of the axis
  17811. alongAxis = {
  17812. low: margin + (horiz ? 0 : axisLength),
  17813. middle: margin + axisLength / 2,
  17814. high: margin + (horiz ? axisLength : 0)
  17815. }[axisTitleOptions.align],
  17816. // the position in the perpendicular direction of the axis
  17817. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  17818. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  17819. (opposite ? -1 : 1) * // so does opposite axes
  17820. this.axisTitleMargin +
  17821. [
  17822. -textHeightOvershoot,
  17823. textHeightOvershoot,
  17824. fontMetrics.f,
  17825. -textHeightOvershoot // left
  17826. ][this.side],
  17827. titlePosition = {
  17828. x: horiz ?
  17829. alongAxis + xOption :
  17830. offAxis + (opposite ? this.width : 0) + offset + xOption,
  17831. y: horiz ?
  17832. offAxis + yOption - (opposite ? this.height : 0) + offset :
  17833. alongAxis + yOption
  17834. };
  17835. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  17836. return titlePosition;
  17837. };
  17838. /**
  17839. * Render a minor tick into the given position. If a minor tick already
  17840. * exists in this position, move it.
  17841. *
  17842. * @function Highcharts.Axis#renderMinorTick
  17843. *
  17844. * @param {number} pos
  17845. * The position in axis values.
  17846. */
  17847. Axis.prototype.renderMinorTick = function (pos) {
  17848. var axis = this;
  17849. var slideInTicks = axis.chart.hasRendered && axis.old;
  17850. var minorTicks = axis.minorTicks;
  17851. if (!minorTicks[pos]) {
  17852. minorTicks[pos] = new Tick(axis, pos, 'minor');
  17853. }
  17854. // Render new ticks in old position
  17855. if (slideInTicks && minorTicks[pos].isNew) {
  17856. minorTicks[pos].render(null, true);
  17857. }
  17858. minorTicks[pos].render(null, false, 1);
  17859. };
  17860. /**
  17861. * Render a major tick into the given position. If a tick already exists
  17862. * in this position, move it.
  17863. *
  17864. * @function Highcharts.Axis#renderTick
  17865. *
  17866. * @param {number} pos
  17867. * The position in axis values.
  17868. *
  17869. * @param {number} i
  17870. * The tick index.
  17871. */
  17872. Axis.prototype.renderTick = function (pos, i) {
  17873. var axis = this;
  17874. var isLinked = axis.isLinked;
  17875. var ticks = axis.ticks;
  17876. var slideInTicks = axis.chart.hasRendered && axis.old;
  17877. // Linked axes need an extra check to find out if
  17878. if (!isLinked ||
  17879. (pos >= axis.min && pos <= axis.max) ||
  17880. (axis.grid && axis.grid.isColumn)) {
  17881. if (!ticks[pos]) {
  17882. ticks[pos] = new Tick(axis, pos);
  17883. }
  17884. // NOTE this seems like overkill. Could be handled in tick.render by
  17885. // setting old position in attr, then set new position in animate.
  17886. // render new ticks in old position
  17887. if (slideInTicks && ticks[pos].isNew) {
  17888. // Start with negative opacity so that it is visible from
  17889. // halfway into the animation
  17890. ticks[pos].render(i, true, -1);
  17891. }
  17892. ticks[pos].render(i);
  17893. }
  17894. };
  17895. /**
  17896. * Render the axis.
  17897. *
  17898. * @private
  17899. * @function Highcharts.Axis#render
  17900. *
  17901. * @fires Highcharts.Axis#event:afterRender
  17902. */
  17903. Axis.prototype.render = function () {
  17904. var axis = this,
  17905. chart = axis.chart,
  17906. log = axis.logarithmic,
  17907. renderer = chart.renderer,
  17908. options = axis.options,
  17909. isLinked = axis.isLinked,
  17910. tickPositions = axis.tickPositions,
  17911. axisTitle = axis.axisTitle,
  17912. ticks = axis.ticks,
  17913. minorTicks = axis.minorTicks,
  17914. alternateBands = axis.alternateBands,
  17915. stackLabelOptions = options.stackLabels,
  17916. alternateGridColor = options.alternateGridColor,
  17917. tickmarkOffset = axis.tickmarkOffset,
  17918. axisLine = axis.axisLine,
  17919. showAxis = axis.showAxis,
  17920. animation = animObject(renderer.globalAnimation),
  17921. from,
  17922. to;
  17923. // Reset
  17924. axis.labelEdge.length = 0;
  17925. axis.overlap = false;
  17926. // Mark all elements inActive before we go over and mark the active ones
  17927. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17928. objectEach(coll, function (tick) {
  17929. tick.isActive = false;
  17930. });
  17931. });
  17932. // If the series has data draw the ticks. Else only the line and title
  17933. if (axis.hasData() || isLinked) {
  17934. // minor ticks
  17935. if (axis.minorTickInterval && !axis.categories) {
  17936. axis.getMinorTickPositions().forEach(function (pos) {
  17937. axis.renderMinorTick(pos);
  17938. });
  17939. }
  17940. // Major ticks. Pull out the first item and render it last so that
  17941. // we can get the position of the neighbour label. #808.
  17942. if (tickPositions.length) { // #1300
  17943. tickPositions.forEach(function (pos, i) {
  17944. axis.renderTick(pos, i);
  17945. });
  17946. // In a categorized axis, the tick marks are displayed
  17947. // between labels. So we need to add a tick mark and
  17948. // grid line at the left edge of the X axis.
  17949. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  17950. if (!ticks[-1]) {
  17951. ticks[-1] = new Tick(axis, -1, null, true);
  17952. }
  17953. ticks[-1].render(-1);
  17954. }
  17955. }
  17956. // alternate grid color
  17957. if (alternateGridColor) {
  17958. tickPositions.forEach(function (pos, i) {
  17959. to = typeof tickPositions[i + 1] !== 'undefined' ?
  17960. tickPositions[i + 1] + tickmarkOffset :
  17961. axis.max - tickmarkOffset;
  17962. if (i % 2 === 0 &&
  17963. pos < axis.max &&
  17964. to <= axis.max + (chart.polar ?
  17965. -tickmarkOffset :
  17966. tickmarkOffset)) { // #2248, #4660
  17967. if (!alternateBands[pos]) {
  17968. // Should be imported from PlotLineOrBand.js, but
  17969. // the dependency cycle with axis is a problem
  17970. alternateBands[pos] = new H.PlotLineOrBand(axis);
  17971. }
  17972. from = pos + tickmarkOffset; // #949
  17973. alternateBands[pos].options = {
  17974. from: log ? log.lin2log(from) : from,
  17975. to: log ? log.lin2log(to) : to,
  17976. color: alternateGridColor,
  17977. className: 'highcharts-alternate-grid'
  17978. };
  17979. alternateBands[pos].render();
  17980. alternateBands[pos].isActive = true;
  17981. }
  17982. });
  17983. }
  17984. // custom plot lines and bands
  17985. if (!axis._addedPlotLB) { // only first time
  17986. axis._addedPlotLB = true;
  17987. (options.plotLines || [])
  17988. .concat(options.plotBands || [])
  17989. .forEach(function (plotLineOptions) {
  17990. axis.addPlotBandOrLine(plotLineOptions);
  17991. });
  17992. }
  17993. } // end if hasData
  17994. // Remove inactive ticks
  17995. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17996. var i,
  17997. forDestruction = [],
  17998. delay = animation.duration,
  17999. destroyInactiveItems = function () {
  18000. i = forDestruction.length;
  18001. while (i--) {
  18002. // When resizing rapidly, the same items
  18003. // may be destroyed in different timeouts,
  18004. // or the may be reactivated
  18005. if (coll[forDestruction[i]] &&
  18006. !coll[forDestruction[i]].isActive) {
  18007. coll[forDestruction[i]].destroy();
  18008. delete coll[forDestruction[i]];
  18009. }
  18010. }
  18011. };
  18012. objectEach(coll, function (tick, pos) {
  18013. if (!tick.isActive) {
  18014. // Render to zero opacity
  18015. tick.render(pos, false, 0);
  18016. tick.isActive = false;
  18017. forDestruction.push(pos);
  18018. }
  18019. });
  18020. // When the objects are finished fading out, destroy them
  18021. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  18022. !chart.hasRendered ||
  18023. !delay ?
  18024. 0 :
  18025. delay);
  18026. });
  18027. // Set the axis line path
  18028. if (axisLine) {
  18029. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  18030. d: this.getLinePath(axisLine.strokeWidth())
  18031. });
  18032. axisLine.isPlaced = true;
  18033. // Show or hide the line depending on options.showEmpty
  18034. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  18035. }
  18036. if (axisTitle && showAxis) {
  18037. var titleXy = axis.getTitlePosition();
  18038. if (isNumber(titleXy.y)) {
  18039. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  18040. axisTitle.isNew = false;
  18041. }
  18042. else {
  18043. axisTitle.attr('y', -9999);
  18044. axisTitle.isNew = true;
  18045. }
  18046. }
  18047. // Stacked totals:
  18048. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  18049. axis.stacking.renderStackTotals();
  18050. }
  18051. // End stacked totals
  18052. // Record old scaling for updating/animation
  18053. axis.old = {
  18054. len: axis.len,
  18055. max: axis.max,
  18056. min: axis.min,
  18057. transA: axis.transA,
  18058. userMax: axis.userMax,
  18059. userMin: axis.userMin
  18060. };
  18061. axis.isDirty = false;
  18062. fireEvent(this, 'afterRender');
  18063. };
  18064. /**
  18065. * Redraw the axis to reflect changes in the data or axis extremes. Called
  18066. * internally from Highcharts.Chart#redraw.
  18067. *
  18068. * @private
  18069. * @function Highcharts.Axis#redraw
  18070. */
  18071. Axis.prototype.redraw = function () {
  18072. if (this.visible) {
  18073. // render the axis
  18074. this.render();
  18075. // move plot lines and bands
  18076. this.plotLinesAndBands.forEach(function (plotLine) {
  18077. plotLine.render();
  18078. });
  18079. }
  18080. // mark associated series as dirty and ready for redraw
  18081. this.series.forEach(function (series) {
  18082. series.isDirty = true;
  18083. });
  18084. };
  18085. /**
  18086. * Returns an array of axis properties, that should be untouched during
  18087. * reinitialization.
  18088. *
  18089. * @private
  18090. * @function Highcharts.Axis#getKeepProps
  18091. *
  18092. * @return {Array<string>}
  18093. */
  18094. Axis.prototype.getKeepProps = function () {
  18095. return (this.keepProps || Axis.keepProps);
  18096. };
  18097. /**
  18098. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  18099. * to fully remove the axis.
  18100. *
  18101. * @private
  18102. * @function Highcharts.Axis#destroy
  18103. *
  18104. * @param {boolean} [keepEvents]
  18105. * Whether to preserve events, used internally in Axis.update.
  18106. */
  18107. Axis.prototype.destroy = function (keepEvents) {
  18108. var axis = this,
  18109. plotLinesAndBands = axis.plotLinesAndBands,
  18110. plotGroup,
  18111. i;
  18112. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  18113. // Remove the events
  18114. if (!keepEvents) {
  18115. removeEvent(axis);
  18116. }
  18117. // Destroy collections
  18118. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  18119. destroyObjectProperties(coll);
  18120. });
  18121. if (plotLinesAndBands) {
  18122. i = plotLinesAndBands.length;
  18123. while (i--) { // #1975
  18124. plotLinesAndBands[i].destroy();
  18125. }
  18126. }
  18127. // Destroy elements
  18128. ['axisLine', 'axisTitle', 'axisGroup',
  18129. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  18130. if (axis[prop]) {
  18131. axis[prop] = axis[prop].destroy();
  18132. }
  18133. });
  18134. // Destroy each generated group for plotlines and plotbands
  18135. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  18136. axis.plotLinesAndBandsGroups[plotGroup] =
  18137. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  18138. }
  18139. // Delete all properties and fall back to the prototype.
  18140. objectEach(axis, function (val, key) {
  18141. if (axis.getKeepProps().indexOf(key) === -1) {
  18142. delete axis[key];
  18143. }
  18144. });
  18145. };
  18146. /**
  18147. * Internal function to draw a crosshair.
  18148. *
  18149. * @function Highcharts.Axis#drawCrosshair
  18150. *
  18151. * @param {Highcharts.PointerEventObject} [e]
  18152. * The event arguments from the modified pointer event, extended with
  18153. * `chartX` and `chartY`
  18154. *
  18155. * @param {Highcharts.Point} [point]
  18156. * The Point object if the crosshair snaps to points.
  18157. *
  18158. * @fires Highcharts.Axis#event:afterDrawCrosshair
  18159. * @fires Highcharts.Axis#event:drawCrosshair
  18160. */
  18161. Axis.prototype.drawCrosshair = function (e, point) {
  18162. var path,
  18163. options = this.crosshair,
  18164. snap = pick(options && options.snap,
  18165. true),
  18166. pos,
  18167. categorized,
  18168. graphic = this.cross,
  18169. crossOptions,
  18170. chart = this.chart;
  18171. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  18172. // Use last available event when updating non-snapped crosshairs without
  18173. // mouse interaction (#5287)
  18174. if (!e) {
  18175. e = this.cross && this.cross.e;
  18176. }
  18177. if (
  18178. // Disabled in options
  18179. !options ||
  18180. // Snap
  18181. ((defined(point) || !snap) === false)) {
  18182. this.hideCrosshair();
  18183. }
  18184. else {
  18185. // Get the path
  18186. if (!snap) {
  18187. pos = e &&
  18188. (this.horiz ?
  18189. e.chartX - this.pos :
  18190. this.len - e.chartY + this.pos);
  18191. }
  18192. else if (defined(point)) {
  18193. // #3834
  18194. pos = pick(this.coll !== 'colorAxis' ?
  18195. point.crosshairPos : // 3D axis extension
  18196. null, this.isXAxis ?
  18197. point.plotX :
  18198. this.len - point.plotY);
  18199. }
  18200. if (defined(pos)) {
  18201. crossOptions = {
  18202. // value, only used on radial
  18203. value: point && (this.isXAxis ?
  18204. point.x :
  18205. pick(point.stackY, point.y)),
  18206. translatedValue: pos
  18207. };
  18208. if (chart.polar) {
  18209. // Additional information required for crosshairs in
  18210. // polar chart
  18211. extend(crossOptions, {
  18212. isCrosshair: true,
  18213. chartX: e && e.chartX,
  18214. chartY: e && e.chartY,
  18215. point: point
  18216. });
  18217. }
  18218. path = this.getPlotLinePath(crossOptions) ||
  18219. null; // #3189
  18220. }
  18221. if (!defined(path)) {
  18222. this.hideCrosshair();
  18223. return;
  18224. }
  18225. categorized = this.categories && !this.isRadial;
  18226. // Draw the cross
  18227. if (!graphic) {
  18228. this.cross = graphic = chart.renderer
  18229. .path()
  18230. .addClass('highcharts-crosshair highcharts-crosshair-' +
  18231. (categorized ? 'category ' : 'thin ') +
  18232. (options.className || ''))
  18233. .attr({
  18234. zIndex: pick(options.zIndex, 2)
  18235. })
  18236. .add();
  18237. // Presentational attributes
  18238. if (!chart.styledMode) {
  18239. graphic.attr({
  18240. stroke: options.color ||
  18241. (categorized ?
  18242. Color
  18243. .parse(palette.highlightColor20)
  18244. .setOpacity(0.25)
  18245. .get() :
  18246. palette.neutralColor20),
  18247. 'stroke-width': pick(options.width, 1)
  18248. }).css({
  18249. 'pointer-events': 'none'
  18250. });
  18251. if (options.dashStyle) {
  18252. graphic.attr({
  18253. dashstyle: options.dashStyle
  18254. });
  18255. }
  18256. }
  18257. }
  18258. graphic.show().attr({
  18259. d: path
  18260. });
  18261. if (categorized && !options.width) {
  18262. graphic.attr({
  18263. 'stroke-width': this.transA
  18264. });
  18265. }
  18266. this.cross.e = e;
  18267. }
  18268. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  18269. };
  18270. /**
  18271. * Hide the crosshair if visible.
  18272. *
  18273. * @function Highcharts.Axis#hideCrosshair
  18274. */
  18275. Axis.prototype.hideCrosshair = function () {
  18276. if (this.cross) {
  18277. this.cross.hide();
  18278. }
  18279. fireEvent(this, 'afterHideCrosshair');
  18280. };
  18281. /**
  18282. * Check whether the chart has vertical panning ('y' or 'xy' type).
  18283. *
  18284. * @private
  18285. * @function Highcharts.Axis#hasVerticalPanning
  18286. * @return {boolean}
  18287. *
  18288. */
  18289. Axis.prototype.hasVerticalPanning = function () {
  18290. var panningOptions = this.chart.options.chart.panning;
  18291. return Boolean(panningOptions &&
  18292. panningOptions.enabled && // #14624
  18293. /y/.test(panningOptions.type));
  18294. };
  18295. /**
  18296. * Check whether the given value is a positive valid axis value.
  18297. *
  18298. * @private
  18299. * @function Highcharts.Axis#validatePositiveValue
  18300. *
  18301. * @param {unknown} value
  18302. * The axis value
  18303. *
  18304. * @return {boolean}
  18305. */
  18306. Axis.prototype.validatePositiveValue = function (value) {
  18307. return isNumber(value) && value > 0;
  18308. };
  18309. /**
  18310. * Update an axis object with a new set of options. The options are merged
  18311. * with the existing options, so only new or altered options need to be
  18312. * specified.
  18313. *
  18314. * @sample highcharts/members/axis-update/
  18315. * Axis update demo
  18316. *
  18317. * @function Highcharts.Axis#update
  18318. *
  18319. * @param {Highcharts.AxisOptions} options
  18320. * The new options that will be merged in with existing options on
  18321. * the axis.
  18322. *
  18323. * @param {boolean} [redraw=true]
  18324. * Whether to redraw the chart after the axis is altered. If doing
  18325. * more operations on the chart, it is a good idea to set redraw to
  18326. * false and call {@link Chart#redraw} after.
  18327. */
  18328. Axis.prototype.update = function (options, redraw) {
  18329. var chart = this.chart,
  18330. newEvents = ((options && options.events) || {});
  18331. options = merge(this.userOptions, options);
  18332. // Remove old events, if no new exist (#8161)
  18333. objectEach(chart.options[this.coll].events, function (fn, ev) {
  18334. if (typeof newEvents[ev] === 'undefined') {
  18335. newEvents[ev] = void 0;
  18336. }
  18337. });
  18338. this.destroy(true);
  18339. this.init(chart, extend(options, { events: newEvents }));
  18340. chart.isDirtyBox = true;
  18341. if (pick(redraw, true)) {
  18342. chart.redraw();
  18343. }
  18344. };
  18345. /**
  18346. * Remove the axis from the chart.
  18347. *
  18348. * @sample highcharts/members/chart-addaxis/
  18349. * Add and remove axes
  18350. *
  18351. * @function Highcharts.Axis#remove
  18352. *
  18353. * @param {boolean} [redraw=true]
  18354. * Whether to redraw the chart following the remove.
  18355. */
  18356. Axis.prototype.remove = function (redraw) {
  18357. var chart = this.chart,
  18358. key = this.coll, // xAxis or yAxis
  18359. axisSeries = this.series,
  18360. i = axisSeries.length;
  18361. // Remove associated series (#2687)
  18362. while (i--) {
  18363. if (axisSeries[i]) {
  18364. axisSeries[i].remove(false);
  18365. }
  18366. }
  18367. // Remove the axis
  18368. erase(chart.axes, this);
  18369. erase(chart[key], this);
  18370. chart[key].forEach(function (axis, i) {
  18371. // Re-index, #1706, #8075
  18372. axis.options.index = axis.userOptions.index = i;
  18373. });
  18374. this.destroy();
  18375. chart.isDirtyBox = true;
  18376. if (pick(redraw, true)) {
  18377. chart.redraw();
  18378. }
  18379. };
  18380. /**
  18381. * Update the axis title by options after render time.
  18382. *
  18383. * @sample highcharts/members/axis-settitle/
  18384. * Set a new Y axis title
  18385. *
  18386. * @function Highcharts.Axis#setTitle
  18387. *
  18388. * @param {Highcharts.AxisTitleOptions} titleOptions
  18389. * The additional title options.
  18390. *
  18391. * @param {boolean} [redraw=true]
  18392. * Whether to redraw the chart after setting the title.
  18393. *
  18394. * @return {void}
  18395. */
  18396. Axis.prototype.setTitle = function (titleOptions, redraw) {
  18397. this.update({ title: titleOptions }, redraw);
  18398. };
  18399. /**
  18400. * Set new axis categories and optionally redraw.
  18401. *
  18402. * @sample highcharts/members/axis-setcategories/
  18403. * Set categories by click on a button
  18404. *
  18405. * @function Highcharts.Axis#setCategories
  18406. *
  18407. * @param {Array<string>} categories
  18408. * The new categories.
  18409. *
  18410. * @param {boolean} [redraw=true]
  18411. * Whether to redraw the chart.
  18412. */
  18413. Axis.prototype.setCategories = function (categories, redraw) {
  18414. this.update({ categories: categories }, redraw);
  18415. };
  18416. /* *
  18417. *
  18418. * Static Properties
  18419. *
  18420. * */
  18421. /**
  18422. * The X axis or category axis. Normally this is the horizontal axis,
  18423. * though if the chart is inverted this is the vertical axis. In case of
  18424. * multiple axes, the xAxis node is an array of configuration objects.
  18425. *
  18426. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  18427. * access to the axis.
  18428. *
  18429. * @productdesc {highmaps}
  18430. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  18431. * control features like zooming and panning. Zooming is in effect the same
  18432. * as setting the extremes of one of the exes.
  18433. *
  18434. * @type {*|Array<*>}
  18435. * @optionparent xAxis
  18436. *
  18437. * @private
  18438. */
  18439. Axis.defaultOptions = {
  18440. /**
  18441. * When using multiple axis, the ticks of two or more opposite axes
  18442. * will automatically be aligned by adding ticks to the axis or axes
  18443. * with the least ticks, as if `tickAmount` were specified.
  18444. *
  18445. * This can be prevented by setting `alignTicks` to false. If the grid
  18446. * lines look messy, it's a good idea to hide them for the secondary
  18447. * axis by setting `gridLineWidth` to 0.
  18448. *
  18449. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  18450. * then the `alignTicks ` will be disabled for the Axis.
  18451. *
  18452. * Disabled for logarithmic axes.
  18453. *
  18454. * @product highcharts highstock gantt
  18455. */
  18456. alignTicks: true,
  18457. /**
  18458. * Whether to allow decimals in this axis' ticks. When counting
  18459. * integers, like persons or hits on a web page, decimals should
  18460. * be avoided in the labels. By default, decimals are allowed on small
  18461. * scale axes.
  18462. *
  18463. * @see [minTickInterval](#xAxis.minTickInterval)
  18464. *
  18465. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  18466. * True by default
  18467. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  18468. * False
  18469. *
  18470. * @type {boolean|undefined}
  18471. * @default undefined
  18472. * @since 2.0
  18473. */
  18474. allowDecimals: void 0,
  18475. /**
  18476. * When using an alternate grid color, a band is painted across the
  18477. * plot area between every other grid line.
  18478. *
  18479. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  18480. * Alternate grid color on the Y axis
  18481. * @sample {highstock} stock/xaxis/alternategridcolor/
  18482. * Alternate grid color on the Y axis
  18483. *
  18484. * @type {Highcharts.ColorType}
  18485. * @apioption xAxis.alternateGridColor
  18486. */
  18487. /**
  18488. * An array defining breaks in the axis, the sections defined will be
  18489. * left out and all the points shifted closer to each other.
  18490. *
  18491. * @productdesc {highcharts}
  18492. * Requires that the broken-axis.js module is loaded.
  18493. *
  18494. * @sample {highcharts} highcharts/axisbreak/break-simple/
  18495. * Simple break
  18496. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  18497. * Advanced with callback
  18498. * @sample {highstock} stock/demo/intraday-breaks/
  18499. * Break on nights and weekends
  18500. *
  18501. * @type {Array<*>}
  18502. * @since 4.1.0
  18503. * @product highcharts highstock gantt
  18504. * @apioption xAxis.breaks
  18505. */
  18506. /**
  18507. * A number indicating how much space should be left between the start
  18508. * and the end of the break. The break size is given in axis units,
  18509. * so for instance on a `datetime` axis, a break size of 3600000 would
  18510. * indicate the equivalent of an hour.
  18511. *
  18512. * @type {number}
  18513. * @default 0
  18514. * @since 4.1.0
  18515. * @product highcharts highstock gantt
  18516. * @apioption xAxis.breaks.breakSize
  18517. */
  18518. /**
  18519. * The point where the break starts.
  18520. *
  18521. * @type {number}
  18522. * @since 4.1.0
  18523. * @product highcharts highstock gantt
  18524. * @apioption xAxis.breaks.from
  18525. */
  18526. /**
  18527. * Defines an interval after which the break appears again. By default
  18528. * the breaks do not repeat.
  18529. *
  18530. * @type {number}
  18531. * @default 0
  18532. * @since 4.1.0
  18533. * @product highcharts highstock gantt
  18534. * @apioption xAxis.breaks.repeat
  18535. */
  18536. /**
  18537. * The point where the break ends.
  18538. *
  18539. * @type {number}
  18540. * @since 4.1.0
  18541. * @product highcharts highstock gantt
  18542. * @apioption xAxis.breaks.to
  18543. */
  18544. /**
  18545. * If categories are present for the xAxis, names are used instead of
  18546. * numbers for that axis.
  18547. *
  18548. * Since Highcharts 3.0, categories can also
  18549. * be extracted by giving each point a [name](#series.data) and setting
  18550. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  18551. * series, best practice remains defining the `categories` array.
  18552. *
  18553. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  18554. *
  18555. * @sample {highcharts} highcharts/demo/line-labels/
  18556. * With
  18557. * @sample {highcharts} highcharts/xaxis/categories/
  18558. * Without
  18559. *
  18560. * @type {Array<string>}
  18561. * @product highcharts gantt
  18562. * @apioption xAxis.categories
  18563. */
  18564. /**
  18565. * The highest allowed value for automatically computed axis extremes.
  18566. *
  18567. * @see [floor](#xAxis.floor)
  18568. *
  18569. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  18570. * Floor and ceiling
  18571. *
  18572. * @type {number}
  18573. * @since 4.0
  18574. * @product highcharts highstock gantt
  18575. * @apioption xAxis.ceiling
  18576. */
  18577. /**
  18578. * A class name that opens for styling the axis by CSS, especially in
  18579. * Highcharts styled mode. The class name is applied to group elements
  18580. * for the grid, axis elements and labels.
  18581. *
  18582. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  18583. * Multiple axes with separate styling
  18584. *
  18585. * @type {string}
  18586. * @since 5.0.0
  18587. * @apioption xAxis.className
  18588. */
  18589. /**
  18590. * Configure a crosshair that follows either the mouse pointer or the
  18591. * hovered point.
  18592. *
  18593. * In styled mode, the crosshairs are styled in the
  18594. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  18595. * `.highcharts-xaxis-category` classes.
  18596. *
  18597. * @productdesc {highstock}
  18598. * In Highcharts stock, by default, the crosshair is enabled on the
  18599. * X axis and disabled on the Y axis.
  18600. *
  18601. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  18602. * Crosshair on both axes
  18603. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18604. * Crosshair on both axes
  18605. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  18606. * Crosshair on both axes
  18607. *
  18608. * @declare Highcharts.AxisCrosshairOptions
  18609. * @type {boolean|*}
  18610. * @default false
  18611. * @since 4.1
  18612. * @apioption xAxis.crosshair
  18613. */
  18614. /**
  18615. * A class name for the crosshair, especially as a hook for styling.
  18616. *
  18617. * @type {string}
  18618. * @since 5.0.0
  18619. * @apioption xAxis.crosshair.className
  18620. */
  18621. /**
  18622. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  18623. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  18624. * the crosshair by default highlights the whole category.
  18625. *
  18626. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  18627. * Customized crosshairs
  18628. *
  18629. * @type {Highcharts.ColorType}
  18630. * @default #cccccc
  18631. * @since 4.1
  18632. * @apioption xAxis.crosshair.color
  18633. */
  18634. /**
  18635. * The dash style for the crosshair. See
  18636. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  18637. * for possible values.
  18638. *
  18639. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  18640. * Dotted crosshair
  18641. * @sample {highstock} stock/xaxis/crosshair-dashed/
  18642. * Dashed X axis crosshair
  18643. *
  18644. * @type {Highcharts.DashStyleValue}
  18645. * @default Solid
  18646. * @since 4.1
  18647. * @apioption xAxis.crosshair.dashStyle
  18648. */
  18649. /**
  18650. * A label on the axis next to the crosshair.
  18651. *
  18652. * In styled mode, the label is styled with the
  18653. * `.highcharts-crosshair-label` class.
  18654. *
  18655. * @sample {highstock} stock/xaxis/crosshair-label/
  18656. * Crosshair labels
  18657. * @sample {highstock} highcharts/css/crosshair-label/
  18658. * Style mode
  18659. *
  18660. * @declare Highcharts.AxisCrosshairLabelOptions
  18661. * @since 2.1
  18662. * @product highstock
  18663. * @apioption xAxis.crosshair.label
  18664. */
  18665. /**
  18666. * Alignment of the label compared to the axis. Defaults to `"left"` for
  18667. * right-side axes, `"right"` for left-side axes and `"center"` for
  18668. * horizontal axes.
  18669. *
  18670. * @type {Highcharts.AlignValue}
  18671. * @since 2.1
  18672. * @product highstock
  18673. * @apioption xAxis.crosshair.label.align
  18674. */
  18675. /**
  18676. * The background color for the label. Defaults to the related series
  18677. * color, or `#666666` if that is not available.
  18678. *
  18679. * @type {Highcharts.ColorType}
  18680. * @since 2.1
  18681. * @product highstock
  18682. * @apioption xAxis.crosshair.label.backgroundColor
  18683. */
  18684. /**
  18685. * The border color for the crosshair label
  18686. *
  18687. * @type {Highcharts.ColorType}
  18688. * @since 2.1
  18689. * @product highstock
  18690. * @apioption xAxis.crosshair.label.borderColor
  18691. */
  18692. /**
  18693. * The border corner radius of the crosshair label.
  18694. *
  18695. * @type {number}
  18696. * @default 3
  18697. * @since 2.1.10
  18698. * @product highstock
  18699. * @apioption xAxis.crosshair.label.borderRadius
  18700. */
  18701. /**
  18702. * The border width for the crosshair label.
  18703. *
  18704. * @type {number}
  18705. * @default 0
  18706. * @since 2.1
  18707. * @product highstock
  18708. * @apioption xAxis.crosshair.label.borderWidth
  18709. */
  18710. /**
  18711. * Flag to enable crosshair's label.
  18712. *
  18713. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18714. * Enabled label for yAxis' crosshair
  18715. *
  18716. * @type {boolean}
  18717. * @default false
  18718. * @since 2.1
  18719. * @product highstock
  18720. * @apioption xAxis.crosshair.label.enabled
  18721. */
  18722. /**
  18723. * A format string for the crosshair label. Defaults to `{value}` for
  18724. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  18725. *
  18726. * @type {string}
  18727. * @since 2.1
  18728. * @product highstock
  18729. * @apioption xAxis.crosshair.label.format
  18730. */
  18731. /**
  18732. * Formatter function for the label text.
  18733. *
  18734. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  18735. * @since 2.1
  18736. * @product highstock
  18737. * @apioption xAxis.crosshair.label.formatter
  18738. */
  18739. /**
  18740. * Padding inside the crosshair label.
  18741. *
  18742. * @type {number}
  18743. * @default 8
  18744. * @since 2.1
  18745. * @product highstock
  18746. * @apioption xAxis.crosshair.label.padding
  18747. */
  18748. /**
  18749. * The shape to use for the label box.
  18750. *
  18751. * @type {string}
  18752. * @default callout
  18753. * @since 2.1
  18754. * @product highstock
  18755. * @apioption xAxis.crosshair.label.shape
  18756. */
  18757. /**
  18758. * Text styles for the crosshair label.
  18759. *
  18760. * @type {Highcharts.CSSObject}
  18761. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  18762. * @since 2.1
  18763. * @product highstock
  18764. * @apioption xAxis.crosshair.label.style
  18765. */
  18766. /**
  18767. * Whether the crosshair should snap to the point or follow the pointer
  18768. * independent of points.
  18769. *
  18770. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  18771. * True by default
  18772. * @sample {highmaps} maps/demo/latlon-advanced/
  18773. * Snap is false
  18774. *
  18775. * @type {boolean}
  18776. * @default true
  18777. * @since 4.1
  18778. * @apioption xAxis.crosshair.snap
  18779. */
  18780. /**
  18781. * The pixel width of the crosshair. Defaults to 1 for numeric or
  18782. * datetime axes, and for one category width for category axes.
  18783. *
  18784. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  18785. * Customized crosshairs
  18786. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  18787. * Customized crosshairs
  18788. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  18789. * Customized crosshairs
  18790. *
  18791. * @type {number}
  18792. * @default 1
  18793. * @since 4.1
  18794. * @apioption xAxis.crosshair.width
  18795. */
  18796. /**
  18797. * The Z index of the crosshair. Higher Z indices allow drawing the
  18798. * crosshair on top of the series or behind the grid lines.
  18799. *
  18800. * @type {number}
  18801. * @default 2
  18802. * @since 4.1
  18803. * @apioption xAxis.crosshair.zIndex
  18804. */
  18805. /**
  18806. * The Z index for the axis group.
  18807. */
  18808. zIndex: 2,
  18809. /**
  18810. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  18811. * to disable zooming on an individual axis.
  18812. *
  18813. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  18814. * Zoom enabled is false
  18815. */
  18816. zoomEnabled: true,
  18817. /**
  18818. * For a datetime axis, the scale will automatically adjust to the
  18819. * appropriate unit. This member gives the default string
  18820. * representations used for each unit. For intermediate values,
  18821. * different units may be used, for example the `day` unit can be used
  18822. * on midnight and `hour` unit be used for intermediate values on the
  18823. * same axis.
  18824. *
  18825. * For an overview of the replacement codes, see
  18826. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  18827. *
  18828. * Defaults to:
  18829. * ```js
  18830. * {
  18831. * millisecond: '%H:%M:%S.%L',
  18832. * second: '%H:%M:%S',
  18833. * minute: '%H:%M',
  18834. * hour: '%H:%M',
  18835. * day: '%e. %b',
  18836. * week: '%e. %b',
  18837. * month: '%b \'%y',
  18838. * year: '%Y'
  18839. * }
  18840. * ```
  18841. *
  18842. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  18843. * Different day format on X axis
  18844. * @sample {highstock} stock/xaxis/datetimelabelformats/
  18845. * More information in x axis labels
  18846. *
  18847. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  18848. * @product highcharts highstock gantt
  18849. */
  18850. dateTimeLabelFormats: {
  18851. /**
  18852. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18853. * @type {string|*}
  18854. */
  18855. millisecond: {
  18856. main: '%H:%M:%S.%L',
  18857. range: false
  18858. },
  18859. /**
  18860. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18861. * @type {string|*}
  18862. */
  18863. second: {
  18864. main: '%H:%M:%S',
  18865. range: false
  18866. },
  18867. /**
  18868. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18869. * @type {string|*}
  18870. */
  18871. minute: {
  18872. main: '%H:%M',
  18873. range: false
  18874. },
  18875. /**
  18876. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18877. * @type {string|*}
  18878. */
  18879. hour: {
  18880. main: '%H:%M',
  18881. range: false
  18882. },
  18883. /**
  18884. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18885. * @type {string|*}
  18886. */
  18887. day: {
  18888. main: '%e. %b'
  18889. },
  18890. /**
  18891. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18892. * @type {string|*}
  18893. */
  18894. week: {
  18895. main: '%e. %b'
  18896. },
  18897. /**
  18898. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18899. * @type {string|*}
  18900. */
  18901. month: {
  18902. main: '%b \'%y'
  18903. },
  18904. /**
  18905. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18906. * @type {string|*}
  18907. */
  18908. year: {
  18909. main: '%Y'
  18910. }
  18911. },
  18912. /**
  18913. * Whether to force the axis to end on a tick. Use this option with
  18914. * the `maxPadding` option to control the axis end.
  18915. *
  18916. * @productdesc {highstock}
  18917. * In Highcharts Stock, `endOnTick` is always `false` when the navigator
  18918. * is enabled, to prevent jumpy scrolling.
  18919. *
  18920. * @sample {highcharts} highcharts/chart/reflow-true/
  18921. * True by default
  18922. * @sample {highcharts} highcharts/yaxis/endontick/
  18923. * False
  18924. * @sample {highstock} stock/demo/basic-line/
  18925. * True by default
  18926. * @sample {highstock} stock/xaxis/endontick/
  18927. * False
  18928. *
  18929. * @since 1.2.0
  18930. */
  18931. endOnTick: false,
  18932. /**
  18933. * Event handlers for the axis.
  18934. *
  18935. * @type {*}
  18936. * @apioption xAxis.events
  18937. */
  18938. /**
  18939. * An event fired after the breaks have rendered.
  18940. *
  18941. * @see [breaks](#xAxis.breaks)
  18942. *
  18943. * @sample {highcharts} highcharts/axisbreak/break-event/
  18944. * AfterBreak Event
  18945. *
  18946. * @type {Highcharts.AxisEventCallbackFunction}
  18947. * @since 4.1.0
  18948. * @product highcharts gantt
  18949. * @apioption xAxis.events.afterBreaks
  18950. */
  18951. /**
  18952. * As opposed to the `setExtremes` event, this event fires after the
  18953. * final min and max values are computed and corrected for `minRange`.
  18954. *
  18955. * Fires when the minimum and maximum is set for the axis, either by
  18956. * calling the `.setExtremes()` method or by selecting an area in the
  18957. * chart. One parameter, `event`, is passed to the function, containing
  18958. * common event information.
  18959. *
  18960. * The new user set minimum and maximum values can be found by
  18961. * `event.min` and `event.max`. These reflect the axis minimum and
  18962. * maximum in axis values. The actual data extremes are found in
  18963. * `event.dataMin` and `event.dataMax`.
  18964. *
  18965. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18966. * @since 2.3
  18967. * @context Highcharts.Axis
  18968. * @apioption xAxis.events.afterSetExtremes
  18969. */
  18970. /**
  18971. * An event fired when a break from this axis occurs on a point.
  18972. *
  18973. * @see [breaks](#xAxis.breaks)
  18974. *
  18975. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  18976. * Visualization of a Break
  18977. *
  18978. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18979. * @since 4.1.0
  18980. * @product highcharts gantt
  18981. * @context Highcharts.Axis
  18982. * @apioption xAxis.events.pointBreak
  18983. */
  18984. /**
  18985. * An event fired when a point falls inside a break from this axis.
  18986. *
  18987. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18988. * @product highcharts highstock gantt
  18989. * @context Highcharts.Axis
  18990. * @apioption xAxis.events.pointInBreak
  18991. */
  18992. /**
  18993. * Fires when the minimum and maximum is set for the axis, either by
  18994. * calling the `.setExtremes()` method or by selecting an area in the
  18995. * chart. One parameter, `event`, is passed to the function,
  18996. * containing common event information.
  18997. *
  18998. * The new user set minimum and maximum values can be found by
  18999. * `event.min` and `event.max`. These reflect the axis minimum and
  19000. * maximum in data values. When an axis is zoomed all the way out from
  19001. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  19002. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  19003. *
  19004. * @sample {highstock} stock/xaxis/events-setextremes/
  19005. * Log new extremes on x axis
  19006. *
  19007. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  19008. * @since 1.2.0
  19009. * @context Highcharts.Axis
  19010. * @apioption xAxis.events.setExtremes
  19011. */
  19012. /**
  19013. * The lowest allowed value for automatically computed axis extremes.
  19014. *
  19015. * @see [ceiling](#yAxis.ceiling)
  19016. *
  19017. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  19018. * Floor and ceiling
  19019. * @sample {highstock} stock/demo/lazy-loading/
  19020. * Prevent negative stock price on Y axis
  19021. *
  19022. * @type {number}
  19023. * @since 4.0
  19024. * @product highcharts highstock gantt
  19025. * @apioption xAxis.floor
  19026. */
  19027. /**
  19028. * The dash or dot style of the grid lines. For possible values, see
  19029. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19030. *
  19031. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  19032. * Long dashes
  19033. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  19034. * Long dashes
  19035. *
  19036. * @type {Highcharts.DashStyleValue}
  19037. * @since 1.2
  19038. */
  19039. gridLineDashStyle: 'Solid',
  19040. /**
  19041. * The Z index of the grid lines.
  19042. *
  19043. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  19044. * A Z index of 4 renders the grid above the graph
  19045. *
  19046. * @product highcharts highstock gantt
  19047. */
  19048. gridZIndex: 1,
  19049. /**
  19050. * An id for the axis. This can be used after render time to get
  19051. * a pointer to the axis object through `chart.get()`.
  19052. *
  19053. * @sample {highcharts} highcharts/xaxis/id/
  19054. * Get the object
  19055. * @sample {highstock} stock/xaxis/id/
  19056. * Get the object
  19057. *
  19058. * @type {string}
  19059. * @since 1.2.0
  19060. * @apioption xAxis.id
  19061. */
  19062. /**
  19063. * The axis labels show the number or category for each tick.
  19064. *
  19065. * Since v8.0.0: Labels are animated in categorized x-axis with
  19066. * updating data if `tickInterval` and `step` is set to 1.
  19067. *
  19068. * @productdesc {highmaps}
  19069. * X and Y axis labels are by default disabled in Highmaps, but the
  19070. * functionality is inherited from Highcharts and used on `colorAxis`,
  19071. * and can be enabled on X and Y axes too.
  19072. */
  19073. labels: {
  19074. /**
  19075. * What part of the string the given position is anchored to.
  19076. * If `left`, the left side of the string is at the axis position.
  19077. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  19078. * an intelligent guess based on which side of the chart the axis
  19079. * is on and the rotation of the label.
  19080. *
  19081. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  19082. *
  19083. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  19084. * Left
  19085. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  19086. * Right
  19087. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19088. * Left-aligned labels on a vertical category axis
  19089. *
  19090. * @type {Highcharts.AlignValue}
  19091. * @apioption xAxis.labels.align
  19092. */
  19093. /**
  19094. * Whether to allow the axis labels to overlap.
  19095. * When false, overlapping labels are hidden.
  19096. *
  19097. * @sample {highcharts} highcharts/xaxis/labels-allowoverlap-true/
  19098. * X axis labels overlap enabled
  19099. *
  19100. * @type {boolean}
  19101. * @default false
  19102. * @apioption xAxis.labels.allowOverlap
  19103. *
  19104. */
  19105. /**
  19106. * For horizontal axes, the allowed degrees of label rotation
  19107. * to prevent overlapping labels. If there is enough space,
  19108. * labels are not rotated. As the chart gets narrower, it
  19109. * will start rotating the labels -45 degrees, then remove
  19110. * every second label and try again with rotations 0 and -45 etc.
  19111. * Set it to `undefined` to disable rotation, which will
  19112. * cause the labels to word-wrap if possible. Defaults to `[-45]``
  19113. * on bottom and top axes, `undefined` on left and right axes.
  19114. *
  19115. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  19116. * Default auto rotation of 0 or -45
  19117. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  19118. * Custom graded auto rotation
  19119. *
  19120. * @type {Array<number>}
  19121. * @default undefined
  19122. * @since 4.1.0
  19123. * @product highcharts highstock gantt
  19124. * @apioption xAxis.labels.autoRotation
  19125. */
  19126. autoRotation: void 0,
  19127. /**
  19128. * When each category width is more than this many pixels, we don't
  19129. * apply auto rotation. Instead, we lay out the axis label with word
  19130. * wrap. A lower limit makes sense when the label contains multiple
  19131. * short words that don't extend the available horizontal space for
  19132. * each label.
  19133. *
  19134. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  19135. * Lower limit
  19136. *
  19137. * @since 4.1.5
  19138. * @product highcharts gantt
  19139. */
  19140. autoRotationLimit: 80,
  19141. /**
  19142. * Polar charts only. The label's pixel distance from the perimeter
  19143. * of the plot area.
  19144. *
  19145. * @type {number}
  19146. * @default undefined
  19147. * @product highcharts gantt
  19148. */
  19149. distance: void 0,
  19150. /**
  19151. * Enable or disable the axis labels.
  19152. *
  19153. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  19154. * X axis labels disabled
  19155. * @sample {highstock} stock/xaxis/labels-enabled/
  19156. * X axis labels disabled
  19157. *
  19158. * @default {highcharts|highstock|gantt} true
  19159. * @default {highmaps} false
  19160. */
  19161. enabled: true,
  19162. /**
  19163. * A format string for the axis label. The context is available as
  19164. * format string variables. For example, you can use `{text}` to
  19165. * insert the default formatted text. The recommended way of adding
  19166. * units for the label is using `text`, for example `{text} km`.
  19167. *
  19168. * To add custom numeric or datetime formatting, use `{value}` with
  19169. * formatting, for example `{value:.1f}` or `{value:%Y-%m-%d}`.
  19170. *
  19171. * See
  19172. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  19173. * for more examples of formatting.
  19174. *
  19175. * The default value is not specified due to the dynamic
  19176. * nature of the default implementation.
  19177. *
  19178. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  19179. * Add units to Y axis label
  19180. * @sample {highcharts} highcharts/xaxis/labels-format-linked/
  19181. * Linked category names
  19182. * @sample {highcharts} highcharts/xaxis/labels-format-custom/
  19183. * Custom number format
  19184. *
  19185. * @type {string}
  19186. * @since 3.0
  19187. * @apioption xAxis.labels.format
  19188. */
  19189. /**
  19190. * Callback JavaScript function to format the label. The value
  19191. * is given by `this.value`. Additional properties for `this` are
  19192. * `axis`, `chart`, `isFirst`, `isLast` and `text` which holds the
  19193. * value of the default formatter.
  19194. *
  19195. * Defaults to a built in function returning a formatted string
  19196. * depending on whether the axis is `category`, `datetime`,
  19197. * `numeric` or other.
  19198. *
  19199. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  19200. * Linked category names
  19201. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  19202. * Modified numeric labels
  19203. * @sample {highstock} stock/xaxis/labels-formatter/
  19204. * Added units on Y axis
  19205. *
  19206. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  19207. * @apioption xAxis.labels.formatter
  19208. */
  19209. /**
  19210. * The number of pixels to indent the labels per level in a treegrid
  19211. * axis.
  19212. *
  19213. * @sample gantt/treegrid-axis/demo
  19214. * Indentation 10px by default.
  19215. * @sample gantt/treegrid-axis/indentation-0px
  19216. * Indentation set to 0px.
  19217. *
  19218. * @product gantt
  19219. */
  19220. indentation: 10,
  19221. /**
  19222. * Horizontal axis only. When `staggerLines` is not set,
  19223. * `maxStaggerLines` defines how many lines the axis is allowed to
  19224. * add to automatically avoid overlapping X labels. Set to `1` to
  19225. * disable overlap detection.
  19226. *
  19227. * @deprecated
  19228. * @type {number}
  19229. * @default 5
  19230. * @since 1.3.3
  19231. * @apioption xAxis.labels.maxStaggerLines
  19232. */
  19233. /**
  19234. * How to handle overflowing labels on horizontal axis. If set to
  19235. * `"allow"`, it will not be aligned at all. By default it
  19236. * `"justify"` labels inside the chart area. If there is room to
  19237. * move it, it will be aligned to the edge, else it will be removed.
  19238. *
  19239. * @since 2.2.5
  19240. * @validvalue ["allow", "justify"]
  19241. */
  19242. overflow: 'justify',
  19243. /**
  19244. * The pixel padding for axis labels, to ensure white space between
  19245. * them.
  19246. *
  19247. * @product highcharts gantt
  19248. */
  19249. padding: 5,
  19250. /**
  19251. * Whether to reserve space for the labels. By default, space is
  19252. * reserved for the labels in these cases:
  19253. *
  19254. * * On all horizontal axes.
  19255. * * On vertical axes if `label.align` is `right` on a left-side
  19256. * axis or `left` on a right-side axis.
  19257. * * On vertical axes if `label.align` is `center`.
  19258. *
  19259. * This can be turned off when for example the labels are rendered
  19260. * inside the plot area instead of outside.
  19261. *
  19262. * @see [labels.align](#xAxis.labels.align)
  19263. *
  19264. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  19265. * No reserved space, labels inside plot
  19266. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19267. * Left-aligned labels on a vertical category axis
  19268. *
  19269. * @type {boolean}
  19270. * @since 4.1.10
  19271. * @product highcharts gantt
  19272. * @apioption xAxis.labels.reserveSpace
  19273. */
  19274. reserveSpace: void 0,
  19275. /**
  19276. * Rotation of the labels in degrees. When `undefined`, the
  19277. * `autoRotation` option takes precedence.
  19278. *
  19279. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  19280. * X axis labels rotated 90°
  19281. *
  19282. * @type {number}
  19283. * @default 0
  19284. * @apioption xAxis.labels.rotation
  19285. */
  19286. rotation: void 0,
  19287. /**
  19288. * Horizontal axes only. The number of lines to spread the labels
  19289. * over to make room or tighter labels. 0 disables staggering.
  19290. *
  19291. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  19292. * Show labels over two lines
  19293. * @sample {highstock} stock/xaxis/labels-staggerlines/
  19294. * Show labels over two lines
  19295. *
  19296. * @since 2.1
  19297. * @apioption xAxis.labels.staggerLines
  19298. */
  19299. staggerLines: 0,
  19300. /**
  19301. * To show only every _n_'th label on the axis, set the step to _n_.
  19302. * Setting the step to 2 shows every other label.
  19303. *
  19304. * By default, when 0, the step is calculated automatically to avoid
  19305. * overlap. To prevent this, set it to 1\. This usually only
  19306. * happens on a category axis, and is often a sign that you have
  19307. * chosen the wrong axis type.
  19308. *
  19309. * Read more at
  19310. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  19311. * => What axis should I use?
  19312. *
  19313. * @sample {highcharts} highcharts/xaxis/labels-step/
  19314. * Showing only every other axis label on a categorized
  19315. * x-axis
  19316. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  19317. * Auto steps on a category axis
  19318. *
  19319. * @since 2.1
  19320. */
  19321. step: 0,
  19322. /**
  19323. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19324. * to render the labels.
  19325. */
  19326. useHTML: false,
  19327. /**
  19328. * The x position offset of all labels relative to the tick
  19329. * positions on the axis.
  19330. *
  19331. * @sample {highcharts} highcharts/xaxis/labels-x/
  19332. * Y axis labels placed on grid lines
  19333. */
  19334. x: 0,
  19335. /**
  19336. * The y position offset of all labels relative to the tick
  19337. * positions on the axis. The default makes it adapt to the font
  19338. * size of the bottom axis.
  19339. *
  19340. * @sample {highcharts} highcharts/xaxis/labels-x/
  19341. * Y axis labels placed on grid lines
  19342. *
  19343. * @type {number}
  19344. * @apioption xAxis.labels.y
  19345. */
  19346. /**
  19347. * The Z index for the axis labels.
  19348. */
  19349. zIndex: 7,
  19350. /**
  19351. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  19352. * wrapping of category labels. Use `textOverflow: 'none'` to
  19353. * prevent ellipsis (dots).
  19354. *
  19355. * In styled mode, the labels are styled with the
  19356. * `.highcharts-axis-labels` class.
  19357. *
  19358. * @sample {highcharts} highcharts/xaxis/labels-style/
  19359. * Red X axis labels
  19360. *
  19361. * @type {Highcharts.CSSObject}
  19362. */
  19363. style: {
  19364. /** @internal */
  19365. color: palette.neutralColor60,
  19366. /** @internal */
  19367. cursor: 'default',
  19368. /** @internal */
  19369. fontSize: '11px'
  19370. }
  19371. },
  19372. /**
  19373. * The left position as the horizontal axis. If it's a number, it is
  19374. * interpreted as pixel position relative to the chart.
  19375. *
  19376. * Since Highcharts v5.0.13: If it's a percentage string, it is
  19377. * interpreted as percentages of the plot width, offset from plot area
  19378. * left.
  19379. *
  19380. * @type {number|string}
  19381. * @product highcharts highstock
  19382. * @apioption xAxis.left
  19383. */
  19384. /**
  19385. * The top position as the vertical axis. If it's a number, it is
  19386. * interpreted as pixel position relative to the chart.
  19387. *
  19388. * Since Highcharts 2: If it's a percentage string, it is interpreted
  19389. * as percentages of the plot height, offset from plot area top.
  19390. *
  19391. * @type {number|string}
  19392. * @product highcharts highstock
  19393. * @apioption xAxis.top
  19394. */
  19395. /**
  19396. * Index of another axis that this axis is linked to. When an axis is
  19397. * linked to a master axis, it will take the same extremes as
  19398. * the master, but as assigned by min or max or by setExtremes.
  19399. * It can be used to show additional info, or to ease reading the
  19400. * chart by duplicating the scales.
  19401. *
  19402. * @sample {highcharts} highcharts/xaxis/linkedto/
  19403. * Different string formats of the same date
  19404. * @sample {highcharts} highcharts/yaxis/linkedto/
  19405. * Y values on both sides
  19406. *
  19407. * @type {number}
  19408. * @since 2.0.2
  19409. * @product highcharts highstock gantt
  19410. * @apioption xAxis.linkedTo
  19411. */
  19412. /**
  19413. * The maximum value of the axis. If `null`, the max value is
  19414. * automatically calculated.
  19415. *
  19416. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  19417. * might be rounded up.
  19418. *
  19419. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  19420. * beyond the set max in order to reach the given number of ticks. The
  19421. * same may happen in a chart with multiple axes, determined by [chart.
  19422. * alignTicks](#chart), where a `tickAmount` is applied internally.
  19423. *
  19424. * @sample {highcharts} highcharts/yaxis/max-200/
  19425. * Y axis max of 200
  19426. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  19427. * Y axis max on logarithmic axis
  19428. * @sample {highstock} stock/xaxis/min-max/
  19429. * Fixed min and max on X axis
  19430. * @sample {highmaps} maps/axis/min-max/
  19431. * Pre-zoomed to a specific area
  19432. *
  19433. * @type {number|null}
  19434. * @apioption xAxis.max
  19435. */
  19436. /**
  19437. * Padding of the max value relative to the length of the axis. A
  19438. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19439. * when you don't want the highest data value to appear on the edge
  19440. * of the plot area. When the axis' `max` option is set or a max extreme
  19441. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19442. *
  19443. * @sample {highcharts} highcharts/yaxis/maxpadding/
  19444. * Max padding of 0.25 on y axis
  19445. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19446. * Greater min- and maxPadding
  19447. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19448. * Add some padding
  19449. *
  19450. * @default {highcharts} 0.01
  19451. * @default {highstock|highmaps} 0
  19452. * @since 1.2.0
  19453. */
  19454. maxPadding: 0.01,
  19455. /**
  19456. * Deprecated. Use `minRange` instead.
  19457. *
  19458. * @deprecated
  19459. * @type {number}
  19460. * @product highcharts highstock
  19461. * @apioption xAxis.maxZoom
  19462. */
  19463. /**
  19464. * The minimum value of the axis. If `null` the min value is
  19465. * automatically calculated.
  19466. *
  19467. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  19468. * the `min` value might be rounded down.
  19469. *
  19470. * The automatically calculated minimum value is also affected by
  19471. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  19472. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  19473. * as well as [series.threshold](#plotOptions.series.threshold)
  19474. * and [series.softThreshold](#plotOptions.series.softThreshold).
  19475. *
  19476. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  19477. * -50 with startOnTick to false
  19478. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  19479. * -50 with startOnTick true by default
  19480. * @sample {highstock} stock/xaxis/min-max/
  19481. * Set min and max on X axis
  19482. * @sample {highmaps} maps/axis/min-max/
  19483. * Pre-zoomed to a specific area
  19484. *
  19485. * @type {number|null}
  19486. * @apioption xAxis.min
  19487. */
  19488. /**
  19489. * The dash or dot style of the minor grid lines. For possible values,
  19490. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19491. *
  19492. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  19493. * Long dashes on minor grid lines
  19494. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  19495. * Long dashes on minor grid lines
  19496. *
  19497. * @type {Highcharts.DashStyleValue}
  19498. * @since 1.2
  19499. */
  19500. minorGridLineDashStyle: 'Solid',
  19501. /**
  19502. * Specific tick interval in axis units for the minor ticks. On a linear
  19503. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  19504. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  19505. * shown.
  19506. *
  19507. * On logarithmic axes, the unit is the power of the value. For example,
  19508. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  19509. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  19510. * between 1 and 10, 10 and 100 etc.
  19511. *
  19512. * If user settings dictate minor ticks to become too dense, they don't
  19513. * make sense, and will be ignored to prevent performance problems.
  19514. *
  19515. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  19516. * Null by default
  19517. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  19518. * 5 units
  19519. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  19520. * "auto"
  19521. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  19522. * 0.1
  19523. * @sample {highstock} stock/demo/basic-line/
  19524. * Null by default
  19525. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  19526. * "auto"
  19527. *
  19528. * @type {number|string|null}
  19529. * @apioption xAxis.minorTickInterval
  19530. */
  19531. /**
  19532. * The pixel length of the minor tick marks.
  19533. *
  19534. * @sample {highcharts} highcharts/yaxis/minorticklength/
  19535. * 10px on Y axis
  19536. * @sample {highstock} stock/xaxis/minorticks/
  19537. * 10px on Y axis
  19538. */
  19539. minorTickLength: 2,
  19540. /**
  19541. * The position of the minor tick marks relative to the axis line.
  19542. * Can be one of `inside` and `outside`.
  19543. *
  19544. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  19545. * Outside by default
  19546. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  19547. * Inside
  19548. * @sample {highstock} stock/xaxis/minorticks/
  19549. * Inside
  19550. *
  19551. * @validvalue ["inside", "outside"]
  19552. */
  19553. minorTickPosition: 'outside',
  19554. /**
  19555. * Enable or disable minor ticks. Unless
  19556. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  19557. * interval is calculated as a fifth of the `tickInterval`.
  19558. *
  19559. * On a logarithmic axis, minor ticks are laid out based on a best
  19560. * guess, attempting to enter approximately 5 minor ticks between
  19561. * each major tick.
  19562. *
  19563. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  19564. * `minorTickInterval` to `"auto"`.
  19565. *
  19566. * @productdesc {highcharts}
  19567. * On axes using [categories](#xAxis.categories), minor ticks are not
  19568. * supported.
  19569. *
  19570. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  19571. * Enabled on linear Y axis
  19572. *
  19573. * @type {boolean}
  19574. * @default false
  19575. * @since 6.0.0
  19576. * @apioption xAxis.minorTicks
  19577. */
  19578. /**
  19579. * The pixel width of the minor tick mark.
  19580. *
  19581. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  19582. * 3px width
  19583. * @sample {highstock} stock/xaxis/minorticks/
  19584. * 1px width
  19585. *
  19586. * @type {number}
  19587. * @default 0
  19588. * @apioption xAxis.minorTickWidth
  19589. */
  19590. /**
  19591. * Padding of the min value relative to the length of the axis. A
  19592. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19593. * when you don't want the lowest data value to appear on the edge
  19594. * of the plot area. When the axis' `min` option is set or a min extreme
  19595. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  19596. *
  19597. * @sample {highcharts} highcharts/yaxis/minpadding/
  19598. * Min padding of 0.2
  19599. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19600. * Greater min- and maxPadding
  19601. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19602. * Add some padding
  19603. *
  19604. * @default {highcharts} 0.01
  19605. * @default {highstock|highmaps} 0
  19606. * @since 1.2.0
  19607. * @product highcharts highstock gantt
  19608. */
  19609. minPadding: 0.01,
  19610. /**
  19611. * The minimum range to display on this axis. The entire axis will not
  19612. * be allowed to span over a smaller interval than this. For example,
  19613. * for a datetime axis the main unit is milliseconds. If minRange is
  19614. * set to 3600000, you can't zoom in more than to one hour.
  19615. *
  19616. * The default minRange for the x axis is five times the smallest
  19617. * interval between any of the data points.
  19618. *
  19619. * On a logarithmic axis, the unit for the minimum range is the power.
  19620. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  19621. * 100-1000, 1000-10000 etc.
  19622. *
  19623. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  19624. * `endOnTick` settings also affect how the extremes of the axis
  19625. * are computed.
  19626. *
  19627. * @sample {highcharts} highcharts/xaxis/minrange/
  19628. * Minimum range of 5
  19629. * @sample {highstock} stock/xaxis/minrange/
  19630. * Max zoom of 6 months overrides user selections
  19631. * @sample {highmaps} maps/axis/minrange/
  19632. * Minimum range of 1000
  19633. *
  19634. * @type {number}
  19635. * @apioption xAxis.minRange
  19636. */
  19637. /**
  19638. * The minimum tick interval allowed in axis values. For example on
  19639. * zooming in on an axis with daily data, this can be used to prevent
  19640. * the axis from showing hours. Defaults to the closest distance between
  19641. * two points on the axis.
  19642. *
  19643. * @type {number}
  19644. * @since 2.3.0
  19645. * @apioption xAxis.minTickInterval
  19646. */
  19647. /**
  19648. * The distance in pixels from the plot area to the axis line.
  19649. * A positive offset moves the axis with it's line, labels and ticks
  19650. * away from the plot area. This is typically used when two or more
  19651. * axes are displayed on the same side of the plot. With multiple
  19652. * axes the offset is dynamically adjusted to avoid collision, this
  19653. * can be overridden by setting offset explicitly.
  19654. *
  19655. * @sample {highcharts} highcharts/yaxis/offset/
  19656. * Y axis offset of 70
  19657. * @sample {highcharts} highcharts/yaxis/offset-centered/
  19658. * Axes positioned in the center of the plot
  19659. * @sample {highstock} stock/xaxis/offset/
  19660. * Y axis offset by 70 px
  19661. *
  19662. */
  19663. offset: void 0,
  19664. /**
  19665. * Whether to display the axis on the opposite side of the normal. The
  19666. * normal is on the left side for vertical axes and bottom for
  19667. * horizontal, so the opposite sides will be right and top respectively.
  19668. * This is typically used with dual or multiple axes.
  19669. *
  19670. * @sample {highcharts} highcharts/yaxis/opposite/
  19671. * Secondary Y axis opposite
  19672. * @sample {highstock} stock/xaxis/opposite/
  19673. * Y axis on left side
  19674. *
  19675. * @default {highcharts|highstock|highmaps} false
  19676. * @default {gantt} true
  19677. */
  19678. opposite: false,
  19679. /**
  19680. * In an ordinal axis, the points are equally spaced in the chart
  19681. * regardless of the actual time or x distance between them. This means
  19682. * that missing data periods (e.g. nights or weekends for a stock chart)
  19683. * will not take up space in the chart.
  19684. * Having `ordinal: false` will show any gaps created by the `gapSize`
  19685. * setting proportionate to their duration.
  19686. *
  19687. * In stock charts the X axis is ordinal by default, unless
  19688. * the boost module is used and at least one of the series' data length
  19689. * exceeds the [boostThreshold](#series.line.boostThreshold).
  19690. *
  19691. * @sample {highstock} stock/xaxis/ordinal-true/
  19692. * True by default
  19693. * @sample {highstock} stock/xaxis/ordinal-false/
  19694. * False
  19695. *
  19696. * @type {boolean}
  19697. * @default true
  19698. * @since 1.1
  19699. * @product highstock
  19700. * @apioption xAxis.ordinal
  19701. */
  19702. /**
  19703. * Additional range on the right side of the xAxis. Works similar to
  19704. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  19705. * both main `xAxis` and the navigator's `xAxis`.
  19706. *
  19707. * @sample {highstock} stock/xaxis/overscroll/
  19708. * One minute overscroll with live data
  19709. *
  19710. * @type {number}
  19711. * @default 0
  19712. * @since 6.0.0
  19713. * @product highstock
  19714. * @apioption xAxis.overscroll
  19715. */
  19716. /**
  19717. * Refers to the index in the [panes](#panes) array. Used for circular
  19718. * gauges and polar charts. When the option is not set then first pane
  19719. * will be used.
  19720. *
  19721. * @sample highcharts/demo/gauge-vu-meter
  19722. * Two gauges with different center
  19723. *
  19724. * @type {number}
  19725. * @product highcharts
  19726. * @apioption xAxis.pane
  19727. */
  19728. /**
  19729. * The zoomed range to display when only defining one or none of `min`
  19730. * or `max`. For example, to show the latest month, a range of one month
  19731. * can be set.
  19732. *
  19733. * @sample {highstock} stock/xaxis/range/
  19734. * Setting a zoomed range when the rangeSelector is disabled
  19735. *
  19736. * @type {number}
  19737. * @product highstock
  19738. * @apioption xAxis.range
  19739. */
  19740. /**
  19741. * Whether to reverse the axis so that the highest number is closest
  19742. * to the origin. If the chart is inverted, the x axis is reversed by
  19743. * default.
  19744. *
  19745. * @sample {highcharts} highcharts/yaxis/reversed/
  19746. * Reversed Y axis
  19747. * @sample {highstock} stock/xaxis/reversed/
  19748. * Reversed Y axis
  19749. *
  19750. * @type {boolean}
  19751. * @default undefined
  19752. * @apioption xAxis.reversed
  19753. */
  19754. reversed: void 0,
  19755. /**
  19756. * This option determines how stacks should be ordered within a group.
  19757. * For example reversed xAxis also reverses stacks, so first series
  19758. * comes last in a group. To keep order like for non-reversed xAxis
  19759. * enable this option.
  19760. *
  19761. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  19762. * Reversed stacks comparison
  19763. * @sample {highstock} highcharts/xaxis/reversedstacks/
  19764. * Reversed stacks comparison
  19765. *
  19766. * @since 6.1.1
  19767. * @product highcharts highstock
  19768. */
  19769. reversedStacks: false,
  19770. /**
  19771. * An optional scrollbar to display on the X axis in response to
  19772. * limiting the minimum and maximum of the axis values.
  19773. *
  19774. * In styled mode, all the presentational options for the scrollbar are
  19775. * replaced by the classes `.highcharts-scrollbar-thumb`,
  19776. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  19777. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  19778. *
  19779. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  19780. * Heatmap with both scrollbars
  19781. *
  19782. * @extends scrollbar
  19783. * @since 4.2.6
  19784. * @product highstock
  19785. * @apioption xAxis.scrollbar
  19786. */
  19787. /**
  19788. * Whether to show the axis line and title when the axis has no data.
  19789. *
  19790. * @sample {highcharts} highcharts/yaxis/showempty/
  19791. * When clicking the legend to hide series, one axis preserves
  19792. * line and title, the other doesn't
  19793. * @sample {highstock} highcharts/yaxis/showempty/
  19794. * When clicking the legend to hide series, one axis preserves
  19795. * line and title, the other doesn't
  19796. *
  19797. * @since 1.1
  19798. */
  19799. showEmpty: true,
  19800. /**
  19801. * Whether to show the first tick label.
  19802. *
  19803. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  19804. * Set to false on X axis
  19805. * @sample {highstock} stock/xaxis/showfirstlabel/
  19806. * Labels below plot lines on Y axis
  19807. */
  19808. showFirstLabel: true,
  19809. /**
  19810. * Whether to show the last tick label. Defaults to `true` on cartesian
  19811. * charts, and `false` on polar charts.
  19812. *
  19813. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  19814. * Set to true on X axis
  19815. * @sample {highstock} stock/xaxis/showfirstlabel/
  19816. * Labels below plot lines on Y axis
  19817. *
  19818. * @product highcharts highstock gantt
  19819. */
  19820. showLastLabel: true,
  19821. /**
  19822. * A soft maximum for the axis. If the series data maximum is less than
  19823. * this, the axis will stay at this maximum, but if the series data
  19824. * maximum is higher, the axis will flex to show all data.
  19825. *
  19826. * @sample highcharts/yaxis/softmin-softmax/
  19827. * Soft min and max
  19828. *
  19829. * @type {number}
  19830. * @since 5.0.1
  19831. * @product highcharts highstock gantt
  19832. * @apioption xAxis.softMax
  19833. */
  19834. /**
  19835. * A soft minimum for the axis. If the series data minimum is greater
  19836. * than this, the axis will stay at this minimum, but if the series
  19837. * data minimum is lower, the axis will flex to show all data.
  19838. *
  19839. * @sample highcharts/yaxis/softmin-softmax/
  19840. * Soft min and max
  19841. *
  19842. * @type {number}
  19843. * @since 5.0.1
  19844. * @product highcharts highstock gantt
  19845. * @apioption xAxis.softMin
  19846. */
  19847. /**
  19848. * For datetime axes, this decides where to put the tick between weeks.
  19849. * 0 = Sunday, 1 = Monday.
  19850. *
  19851. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  19852. * Monday by default
  19853. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  19854. * Sunday
  19855. * @sample {highstock} stock/xaxis/startofweek-1
  19856. * Monday by default
  19857. * @sample {highstock} stock/xaxis/startofweek-0
  19858. * Sunday
  19859. *
  19860. * @product highcharts highstock gantt
  19861. */
  19862. startOfWeek: 1,
  19863. /**
  19864. * Whether to force the axis to start on a tick. Use this option with
  19865. * the `minPadding` option to control the axis start.
  19866. *
  19867. * @productdesc {highstock}
  19868. * In Highcharts Stock, `startOnTick` is always `false` when
  19869. * the navigator is enabled, to prevent jumpy scrolling.
  19870. *
  19871. * @sample {highcharts} highcharts/xaxis/startontick-false/
  19872. * False by default
  19873. * @sample {highcharts} highcharts/xaxis/startontick-true/
  19874. * True
  19875. *
  19876. * @since 1.2.0
  19877. */
  19878. startOnTick: false,
  19879. /**
  19880. * The amount of ticks to draw on the axis. This opens up for aligning
  19881. * the ticks of multiple charts or panes within a chart. This option
  19882. * overrides the `tickPixelInterval` option.
  19883. *
  19884. * This option only has an effect on linear axes. Datetime, logarithmic
  19885. * or category axes are not affected.
  19886. *
  19887. * @sample {highcharts} highcharts/yaxis/tickamount/
  19888. * 8 ticks on Y axis
  19889. * @sample {highstock} highcharts/yaxis/tickamount/
  19890. * 8 ticks on Y axis
  19891. *
  19892. * @type {number}
  19893. * @since 4.1.0
  19894. * @product highcharts highstock gantt
  19895. * @apioption xAxis.tickAmount
  19896. */
  19897. /**
  19898. * The interval of the tick marks in axis units. When `undefined`, the
  19899. * tick interval is computed to approximately follow the
  19900. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  19901. * axes. On categorized axes, a `undefined` tickInterval will default to
  19902. * 1, one category. Note that datetime axes are based on milliseconds,
  19903. * so for example an interval of one day is expressed as
  19904. * `24 * 3600 * 1000`.
  19905. *
  19906. * On logarithmic axes, the tickInterval is based on powers, so a
  19907. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  19908. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  19909. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  19910. * 40 etc.
  19911. *
  19912. *
  19913. * If the tickInterval is too dense for labels to be drawn, Highcharts
  19914. * may remove ticks.
  19915. *
  19916. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  19917. * option may interfere with the `tickInterval` setting.
  19918. *
  19919. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  19920. * @see [tickPositions](#xAxis.tickPositions)
  19921. * @see [tickPositioner](#xAxis.tickPositioner)
  19922. *
  19923. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  19924. * Tick interval of 5 on a linear axis
  19925. * @sample {highstock} stock/xaxis/tickinterval/
  19926. * Tick interval of 0.01 on Y axis
  19927. *
  19928. * @type {number}
  19929. * @apioption xAxis.tickInterval
  19930. */
  19931. /**
  19932. * The pixel length of the main tick marks.
  19933. *
  19934. * @sample {highcharts} highcharts/xaxis/ticklength/
  19935. * 20 px tick length on the X axis
  19936. * @sample {highstock} stock/xaxis/ticks/
  19937. * Formatted ticks on X axis
  19938. */
  19939. tickLength: 10,
  19940. /**
  19941. * If tickInterval is `null` this option sets the approximate pixel
  19942. * interval of the tick marks. Not applicable to categorized axis.
  19943. *
  19944. * The tick interval is also influenced by the [minTickInterval](
  19945. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  19946. * being denser than the data points.
  19947. *
  19948. * @see [tickInterval](#xAxis.tickInterval)
  19949. * @see [tickPositioner](#xAxis.tickPositioner)
  19950. * @see [tickPositions](#xAxis.tickPositions)
  19951. *
  19952. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  19953. * 50 px on X axis
  19954. * @sample {highstock} stock/xaxis/tickpixelinterval/
  19955. * 200 px on X axis
  19956. */
  19957. tickPixelInterval: 100,
  19958. /**
  19959. * For categorized axes only. If `on` the tick mark is placed in the
  19960. * center of the category, if `between` the tick mark is placed between
  19961. * categories. The default is `between` if the `tickInterval` is 1, else
  19962. * `on`.
  19963. *
  19964. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  19965. * "between" by default
  19966. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  19967. * "on"
  19968. *
  19969. * @product highcharts gantt
  19970. * @validvalue ["on", "between"]
  19971. */
  19972. tickmarkPlacement: 'between',
  19973. /**
  19974. * The position of the major tick marks relative to the axis line.
  19975. * Can be one of `inside` and `outside`.
  19976. *
  19977. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  19978. * "outside" by default
  19979. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  19980. * "inside"
  19981. * @sample {highstock} stock/xaxis/ticks/
  19982. * Formatted ticks on X axis
  19983. *
  19984. * @validvalue ["inside", "outside"]
  19985. */
  19986. tickPosition: 'outside',
  19987. /**
  19988. * A callback function returning array defining where the ticks are
  19989. * laid out on the axis. This overrides the default behaviour of
  19990. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  19991. * #xAxis.tickInterval). The automatic tick positions are accessible
  19992. * through `this.tickPositions` and can be modified by the callback.
  19993. *
  19994. * @see [tickPositions](#xAxis.tickPositions)
  19995. *
  19996. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19997. * Demo of tickPositions and tickPositioner
  19998. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19999. * Demo of tickPositions and tickPositioner
  20000. *
  20001. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  20002. * @apioption xAxis.tickPositioner
  20003. */
  20004. /**
  20005. * An array defining where the ticks are laid out on the axis. This
  20006. * overrides the default behaviour of [tickPixelInterval](
  20007. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  20008. *
  20009. * @see [tickPositioner](#xAxis.tickPositioner)
  20010. *
  20011. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  20012. * Demo of tickPositions and tickPositioner
  20013. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  20014. * Demo of tickPositions and tickPositioner
  20015. *
  20016. * @type {Array<number>}
  20017. * @apioption xAxis.tickPositions
  20018. */
  20019. /**
  20020. * The pixel width of the major tick marks. Defaults to 0 on category
  20021. * axes, otherwise 1.
  20022. *
  20023. * In styled mode, the stroke width is given in the `.highcharts-tick`
  20024. * class, but in order for the element to be generated on category axes,
  20025. * the option must be explicitly set to 1.
  20026. *
  20027. * @sample {highcharts} highcharts/xaxis/tickwidth/
  20028. * 10 px width
  20029. * @sample {highcharts} highcharts/css/axis-grid/
  20030. * Styled mode
  20031. * @sample {highstock} stock/xaxis/ticks/
  20032. * Formatted ticks on X axis
  20033. * @sample {highstock} highcharts/css/axis-grid/
  20034. * Styled mode
  20035. *
  20036. * @type {undefined|number}
  20037. * @default {highstock} 1
  20038. * @default {highmaps} 0
  20039. * @apioption xAxis.tickWidth
  20040. */
  20041. /**
  20042. * The axis title, showing next to the axis line.
  20043. *
  20044. * @productdesc {highmaps}
  20045. * In Highmaps, the axis is hidden by default, but adding an axis title
  20046. * is still possible. X axis and Y axis titles will appear at the bottom
  20047. * and left by default.
  20048. */
  20049. title: {
  20050. /**
  20051. * Alignment of the title relative to the axis values. Possible
  20052. * values are "low", "middle" or "high".
  20053. *
  20054. * @sample {highcharts} highcharts/xaxis/title-align-low/
  20055. * "low"
  20056. * @sample {highcharts} highcharts/xaxis/title-align-center/
  20057. * "middle" by default
  20058. * @sample {highcharts} highcharts/xaxis/title-align-high/
  20059. * "high"
  20060. * @sample {highcharts} highcharts/yaxis/title-offset/
  20061. * Place the Y axis title on top of the axis
  20062. * @sample {highstock} stock/xaxis/title-align/
  20063. * Aligned to "high" value
  20064. *
  20065. * @type {Highcharts.AxisTitleAlignValue}
  20066. */
  20067. align: 'middle',
  20068. /**
  20069. * Deprecated. Set the `text` to `undefined` to disable the title.
  20070. *
  20071. * @deprecated
  20072. * @type {boolean}
  20073. * @product highcharts
  20074. * @apioption xAxis.title.enabled
  20075. */
  20076. /**
  20077. * The pixel distance between the axis labels or line and the title.
  20078. * Defaults to 0 for horizontal axes, 10 for vertical
  20079. *
  20080. * @sample {highcharts} highcharts/xaxis/title-margin/
  20081. * Y axis title margin of 60
  20082. *
  20083. * @type {number}
  20084. * @apioption xAxis.title.margin
  20085. */
  20086. /**
  20087. * The distance of the axis title from the axis line. By default,
  20088. * this distance is computed from the offset width of the labels,
  20089. * the labels' distance from the axis and the title's margin.
  20090. * However when the offset option is set, it overrides all this.
  20091. *
  20092. * @sample {highcharts} highcharts/yaxis/title-offset/
  20093. * Place the axis title on top of the axis
  20094. * @sample {highstock} highcharts/yaxis/title-offset/
  20095. * Place the axis title on top of the Y axis
  20096. *
  20097. * @type {number}
  20098. * @since 2.2.0
  20099. * @apioption xAxis.title.offset
  20100. */
  20101. /**
  20102. * Whether to reserve space for the title when laying out the axis.
  20103. *
  20104. * @type {boolean}
  20105. * @default true
  20106. * @since 5.0.11
  20107. * @product highcharts highstock gantt
  20108. * @apioption xAxis.title.reserveSpace
  20109. */
  20110. /**
  20111. * The rotation of the text in degrees. 0 is horizontal, 270 is
  20112. * vertical reading from bottom to top.
  20113. *
  20114. * @sample {highcharts} highcharts/yaxis/title-offset/
  20115. * Horizontal
  20116. */
  20117. rotation: 0,
  20118. /**
  20119. * The actual text of the axis title. It can contain basic HTML tags
  20120. * like `b`, `i` and `span` with style.
  20121. *
  20122. * @sample {highcharts} highcharts/xaxis/title-text/
  20123. * Custom HTML
  20124. * @sample {highstock} stock/xaxis/title-text/
  20125. * Titles for both axes
  20126. *
  20127. * @type {string|null}
  20128. * @apioption xAxis.title.text
  20129. */
  20130. /**
  20131. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  20132. * Default alignment depends on the
  20133. * [title.align](xAxis.title.align):
  20134. *
  20135. * Horizontal axes:
  20136. * - for `align` = `"low"`, `textAlign` is set to `left`
  20137. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20138. * - for `align` = `"high"`, `textAlign` is set to `right`
  20139. *
  20140. * Vertical axes:
  20141. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  20142. * set to `right`
  20143. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  20144. * set to `left`
  20145. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20146. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  20147. * set to `left`
  20148. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  20149. * set to `right`
  20150. *
  20151. * @type {Highcharts.AlignValue}
  20152. * @apioption xAxis.title.textAlign
  20153. */
  20154. /**
  20155. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20156. * to render the axis title.
  20157. *
  20158. * @product highcharts highstock gantt
  20159. */
  20160. useHTML: false,
  20161. /**
  20162. * Horizontal pixel offset of the title position.
  20163. *
  20164. * @since 4.1.6
  20165. * @product highcharts highstock gantt
  20166. */
  20167. x: 0,
  20168. /**
  20169. * Vertical pixel offset of the title position.
  20170. *
  20171. * @product highcharts highstock gantt
  20172. */
  20173. y: 0,
  20174. /**
  20175. * CSS styles for the title. If the title text is longer than the
  20176. * axis length, it will wrap to multiple lines by default. This can
  20177. * be customized by setting `textOverflow: 'ellipsis'`, by
  20178. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  20179. *
  20180. * In styled mode, the stroke width is given in the
  20181. * `.highcharts-axis-title` class.
  20182. *
  20183. * @sample {highcharts} highcharts/xaxis/title-style/
  20184. * Red
  20185. * @sample {highcharts} highcharts/css/axis/
  20186. * Styled mode
  20187. *
  20188. * @type {Highcharts.CSSObject}
  20189. */
  20190. style: {
  20191. /** @internal */
  20192. color: palette.neutralColor60
  20193. }
  20194. },
  20195. /**
  20196. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  20197. * or `category`. In a datetime axis, the numbers are given in
  20198. * milliseconds, and tick marks are placed on appropriate values like
  20199. * full hours or days. In a category axis, the
  20200. * [point names](#series.line.data.name) of the chart's series are used
  20201. * for categories, if not a [categories](#xAxis.categories) array is
  20202. * defined.
  20203. *
  20204. * @sample {highcharts} highcharts/xaxis/type-linear/
  20205. * Linear
  20206. * @sample {highcharts} highcharts/yaxis/type-log/
  20207. * Logarithmic
  20208. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20209. * Logarithmic with minor grid lines
  20210. * @sample {highcharts} highcharts/xaxis/type-log-both/
  20211. * Logarithmic on two axes
  20212. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20213. * Logarithmic with extension to emulate negative values
  20214. *
  20215. * @type {Highcharts.AxisTypeValue}
  20216. * @product highcharts gantt
  20217. */
  20218. type: 'linear',
  20219. /**
  20220. * If there are multiple axes on the same side of the chart, the pixel
  20221. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  20222. * horizontal axes.
  20223. *
  20224. * @type {number}
  20225. * @since 7.0.3
  20226. * @apioption xAxis.margin
  20227. */
  20228. /**
  20229. * Applies only when the axis `type` is `category`. When `uniqueNames`
  20230. * is true, points are placed on the X axis according to their names.
  20231. * If the same point name is repeated in the same or another series,
  20232. * the point is placed on the same X position as other points of the
  20233. * same name. When `uniqueNames` is false, the points are laid out in
  20234. * increasing X positions regardless of their names, and the X axis
  20235. * category will take the name of the last point in each position.
  20236. *
  20237. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  20238. * True by default
  20239. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  20240. * False
  20241. *
  20242. * @since 4.2.7
  20243. * @product highcharts gantt
  20244. */
  20245. uniqueNames: true,
  20246. /**
  20247. * Datetime axis only. An array determining what time intervals the
  20248. * ticks are allowed to fall on. Each array item is an array where the
  20249. * first value is the time unit and the second value another array of
  20250. * allowed multiples.
  20251. *
  20252. * Defaults to:
  20253. * ```js
  20254. * units: [[
  20255. * 'millisecond', // unit name
  20256. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  20257. * ], [
  20258. * 'second',
  20259. * [1, 2, 5, 10, 15, 30]
  20260. * ], [
  20261. * 'minute',
  20262. * [1, 2, 5, 10, 15, 30]
  20263. * ], [
  20264. * 'hour',
  20265. * [1, 2, 3, 4, 6, 8, 12]
  20266. * ], [
  20267. * 'day',
  20268. * [1, 2]
  20269. * ], [
  20270. * 'week',
  20271. * [1, 2]
  20272. * ], [
  20273. * 'month',
  20274. * [1, 2, 3, 4, 6]
  20275. * ], [
  20276. * 'year',
  20277. * null
  20278. * ]]
  20279. * ```
  20280. *
  20281. * @type {Array<Array<string,(Array<number>|null)>>}
  20282. * @product highcharts highstock gantt
  20283. * @apioption xAxis.units
  20284. */
  20285. /**
  20286. * Whether axis, including axis title, line, ticks and labels, should
  20287. * be visible.
  20288. *
  20289. * @since 4.1.9
  20290. * @product highcharts highstock gantt
  20291. */
  20292. visible: true,
  20293. /**
  20294. * Color of the minor, secondary grid lines.
  20295. *
  20296. * In styled mode, the stroke width is given in the
  20297. * `.highcharts-minor-grid-line` class.
  20298. *
  20299. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  20300. * Bright grey lines from Y axis
  20301. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20302. * Styled mode
  20303. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  20304. * Bright grey lines from Y axis
  20305. *
  20306. * @type {Highcharts.ColorType}
  20307. * @default #f2f2f2
  20308. */
  20309. minorGridLineColor: palette.neutralColor5,
  20310. /**
  20311. * Width of the minor, secondary grid lines.
  20312. *
  20313. * In styled mode, the stroke width is given in the
  20314. * `.highcharts-grid-line` class.
  20315. *
  20316. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  20317. * 2px lines from Y axis
  20318. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20319. * Styled mode
  20320. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  20321. * 2px lines from Y axis
  20322. */
  20323. minorGridLineWidth: 1,
  20324. /**
  20325. * Color for the minor tick marks.
  20326. *
  20327. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  20328. * Black tick marks on Y axis
  20329. * @sample {highstock} stock/xaxis/minorticks/
  20330. * Black tick marks on Y axis
  20331. *
  20332. * @type {Highcharts.ColorType}
  20333. * @default #999999
  20334. */
  20335. minorTickColor: palette.neutralColor40,
  20336. /**
  20337. * The color of the line marking the axis itself.
  20338. *
  20339. * In styled mode, the line stroke is given in the
  20340. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20341. *
  20342. * @productdesc {highmaps}
  20343. * In Highmaps, the axis line is hidden by default, because the axis is
  20344. * not visible by default.
  20345. *
  20346. * @sample {highcharts} highcharts/yaxis/linecolor/
  20347. * A red line on Y axis
  20348. * @sample {highcharts|highstock} highcharts/css/axis/
  20349. * Axes in styled mode
  20350. * @sample {highstock} stock/xaxis/linecolor/
  20351. * A red line on X axis
  20352. *
  20353. * @type {Highcharts.ColorType}
  20354. * @default #ccd6eb
  20355. */
  20356. lineColor: palette.highlightColor20,
  20357. /**
  20358. * The width of the line marking the axis itself.
  20359. *
  20360. * In styled mode, the stroke width is given in the
  20361. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20362. *
  20363. * @sample {highcharts} highcharts/yaxis/linecolor/
  20364. * A 1px line on Y axis
  20365. * @sample {highcharts|highstock} highcharts/css/axis/
  20366. * Axes in styled mode
  20367. * @sample {highstock} stock/xaxis/linewidth/
  20368. * A 2px line on X axis
  20369. *
  20370. * @default {highcharts|highstock} 1
  20371. * @default {highmaps} 0
  20372. */
  20373. lineWidth: 1,
  20374. /**
  20375. * Color of the grid lines extending the ticks across the plot area.
  20376. *
  20377. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  20378. * class.
  20379. *
  20380. * @productdesc {highmaps}
  20381. * In Highmaps, the grid lines are hidden by default.
  20382. *
  20383. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  20384. * Green lines
  20385. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20386. * Styled mode
  20387. * @sample {highstock} stock/xaxis/gridlinecolor/
  20388. * Green lines
  20389. *
  20390. * @type {Highcharts.ColorType}
  20391. * @default #e6e6e6
  20392. */
  20393. gridLineColor: palette.neutralColor10,
  20394. /**
  20395. * The width of the grid lines extending the ticks across the plot area.
  20396. * Defaults to 1 on the Y axis and 0 on the X axis, except for 3d
  20397. * charts.
  20398. *
  20399. * In styled mode, the stroke width is given in the
  20400. * `.highcharts-grid-line` class.
  20401. *
  20402. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  20403. * 2px lines
  20404. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20405. * Styled mode
  20406. * @sample {highstock} stock/xaxis/gridlinewidth/
  20407. * 2px lines
  20408. *
  20409. * @type {number}
  20410. * @apioption xAxis.gridLineWidth
  20411. */
  20412. gridLineWidth: void 0,
  20413. /**
  20414. * The height as the vertical axis. If it's a number, it is
  20415. * interpreted as pixels.
  20416. *
  20417. * Since Highcharts 2: If it's a percentage string, it is interpreted
  20418. * as percentages of the total plot height.
  20419. *
  20420. * @type {number|string}
  20421. * @product highcharts highstock
  20422. * @apioption xAxis.height
  20423. */
  20424. /**
  20425. * The width as the horizontal axis. If it's a number, it is interpreted
  20426. * as pixels.
  20427. *
  20428. * Since Highcharts v5.0.13: If it's a percentage string, it is
  20429. * interpreted as percentages of the total plot width.
  20430. *
  20431. * @type {number|string}
  20432. * @product highcharts highstock
  20433. * @apioption xAxis.width
  20434. */
  20435. /**
  20436. * Color for the main tick marks.
  20437. *
  20438. * In styled mode, the stroke is given in the `.highcharts-tick`
  20439. * class.
  20440. *
  20441. * @sample {highcharts} highcharts/xaxis/tickcolor/
  20442. * Red ticks on X axis
  20443. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20444. * Styled mode
  20445. * @sample {highstock} stock/xaxis/ticks/
  20446. * Formatted ticks on X axis
  20447. *
  20448. * @type {Highcharts.ColorType}
  20449. * @default #ccd6eb
  20450. */
  20451. tickColor: palette.highlightColor20
  20452. // tickWidth: 1
  20453. };
  20454. /**
  20455. * The Y axis or value axis. Normally this is the vertical axis,
  20456. * though if the chart is inverted this is the horizontal axis.
  20457. * In case of multiple axes, the yAxis node is an array of
  20458. * configuration objects.
  20459. *
  20460. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  20461. * access to the axis.
  20462. *
  20463. * @type {*|Array<*>}
  20464. * @extends xAxis
  20465. * @excluding currentDateIndicator,ordinal,overscroll
  20466. * @optionparent yAxis
  20467. *
  20468. * @private
  20469. */
  20470. Axis.defaultYAxisOptions = {
  20471. /**
  20472. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  20473. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  20474. * `linear` for other chart types.
  20475. *
  20476. * In a datetime axis, the numbers are given in milliseconds, and tick
  20477. * marks are placed on appropriate values, like full hours or days. In a
  20478. * category or treegrid axis, the [point names](#series.line.data.name)
  20479. * of the chart's series are used for categories, if a
  20480. * [categories](#xAxis.categories) array is not defined.
  20481. *
  20482. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20483. * Logarithmic with minor grid lines
  20484. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20485. * Logarithmic with extension to emulate negative values
  20486. * @sample {gantt} gantt/treegrid-axis/demo
  20487. * Treegrid axis
  20488. *
  20489. * @type {Highcharts.AxisTypeValue}
  20490. * @default {highcharts} linear
  20491. * @default {gantt} treegrid
  20492. * @product highcharts gantt
  20493. * @apioption yAxis.type
  20494. */
  20495. /**
  20496. * The height of the Y axis. If it's a number, it is interpreted as
  20497. * pixels.
  20498. *
  20499. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  20500. * percentages of the total plot height.
  20501. *
  20502. * @see [yAxis.top](#yAxis.top)
  20503. *
  20504. * @sample {highstock} stock/demo/candlestick-and-volume/
  20505. * Percentage height panes
  20506. *
  20507. * @type {number|string}
  20508. * @product highcharts highstock
  20509. * @apioption yAxis.height
  20510. */
  20511. /**
  20512. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20513. * to represent the maximum value of the Y axis.
  20514. *
  20515. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20516. * Min and max colors
  20517. *
  20518. * @type {Highcharts.ColorType}
  20519. * @default #003399
  20520. * @since 4.0
  20521. * @product highcharts
  20522. * @apioption yAxis.maxColor
  20523. */
  20524. /**
  20525. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20526. * to represent the minimum value of the Y axis.
  20527. *
  20528. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20529. * Min and max color
  20530. *
  20531. * @type {Highcharts.ColorType}
  20532. * @default #e6ebf5
  20533. * @since 4.0
  20534. * @product highcharts
  20535. * @apioption yAxis.minColor
  20536. */
  20537. /**
  20538. * Whether to reverse the axis so that the highest number is closest
  20539. * to the origin.
  20540. *
  20541. * @sample {highcharts} highcharts/yaxis/reversed/
  20542. * Reversed Y axis
  20543. * @sample {highstock} stock/xaxis/reversed/
  20544. * Reversed Y axis
  20545. *
  20546. * @type {boolean}
  20547. * @default {highcharts} false
  20548. * @default {highstock} false
  20549. * @default {highmaps} true
  20550. * @default {gantt} true
  20551. * @apioption yAxis.reversed
  20552. */
  20553. /**
  20554. * If `true`, the first series in a stack will be drawn on top in a
  20555. * positive, non-reversed Y axis. If `false`, the first series is in
  20556. * the base of the stack.
  20557. *
  20558. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  20559. * Non-reversed stacks
  20560. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  20561. * Non-reversed stacks
  20562. *
  20563. * @type {boolean}
  20564. * @default true
  20565. * @since 3.0.10
  20566. * @product highcharts highstock
  20567. * @apioption yAxis.reversedStacks
  20568. */
  20569. reversedStacks: true,
  20570. /**
  20571. * Solid gauge series only. Color stops for the solid gauge. Use this
  20572. * in cases where a linear gradient between a `minColor` and `maxColor`
  20573. * is not sufficient. The stops is an array of tuples, where the first
  20574. * item is a float between 0 and 1 assigning the relative position in
  20575. * the gradient, and the second item is the color.
  20576. *
  20577. * For solid gauges, the Y axis also inherits the concept of
  20578. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  20579. * from the Highmaps color axis.
  20580. *
  20581. * @see [minColor](#yAxis.minColor)
  20582. * @see [maxColor](#yAxis.maxColor)
  20583. *
  20584. * @sample {highcharts} highcharts/demo/gauge-solid/
  20585. * True by default
  20586. *
  20587. * @type {Array<Array<number,Highcharts.ColorType>>}
  20588. * @since 4.0
  20589. * @product highcharts
  20590. * @apioption yAxis.stops
  20591. */
  20592. /**
  20593. * The pixel width of the major tick marks.
  20594. *
  20595. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  20596. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  20597. *
  20598. * @type {number}
  20599. * @default 0
  20600. * @product highcharts highstock gantt
  20601. * @apioption yAxis.tickWidth
  20602. */
  20603. /**
  20604. * Whether to force the axis to end on a tick. Use this option with
  20605. * the `maxPadding` option to control the axis end.
  20606. *
  20607. * This option is always disabled, when panning type is
  20608. * either `y` or `xy`.
  20609. *
  20610. * @see [type](#chart.panning.type)
  20611. *
  20612. *
  20613. * @sample {highcharts} highcharts/chart/reflow-true/
  20614. * True by default
  20615. * @sample {highcharts} highcharts/yaxis/endontick/
  20616. * False
  20617. * @sample {highstock} stock/demo/basic-line/
  20618. * True by default
  20619. * @sample {highstock} stock/xaxis/endontick/
  20620. * False for Y axis
  20621. *
  20622. * @since 1.2.0
  20623. */
  20624. endOnTick: true,
  20625. /**
  20626. * Padding of the max value relative to the length of the axis. A
  20627. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20628. * when you don't want the highest data value to appear on the edge
  20629. * of the plot area. When the axis' `max` option is set or a max extreme
  20630. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20631. *
  20632. * Also the `softThreshold` option takes precedence over `maxPadding`,
  20633. * so if the data is tangent to the threshold, `maxPadding` may not
  20634. * apply unless `softThreshold` is set to false.
  20635. *
  20636. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  20637. * Max padding of 0.2
  20638. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20639. * Greater min- and maxPadding
  20640. *
  20641. * @since 1.2.0
  20642. * @product highcharts highstock gantt
  20643. */
  20644. maxPadding: 0.05,
  20645. /**
  20646. * Padding of the min value relative to the length of the axis. A
  20647. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20648. * when you don't want the lowest data value to appear on the edge
  20649. * of the plot area. When the axis' `min` option is set or a max extreme
  20650. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20651. *
  20652. * Also the `softThreshold` option takes precedence over `minPadding`,
  20653. * so if the data is tangent to the threshold, `minPadding` may not
  20654. * apply unless `softThreshold` is set to false.
  20655. *
  20656. * @sample {highcharts} highcharts/yaxis/minpadding/
  20657. * Min padding of 0.2
  20658. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20659. * Greater min- and maxPadding
  20660. *
  20661. * @since 1.2.0
  20662. * @product highcharts highstock gantt
  20663. */
  20664. minPadding: 0.05,
  20665. /**
  20666. * @productdesc {highstock}
  20667. * In Highcharts Stock 1.x, the Y axis was placed
  20668. * on the left side by default.
  20669. *
  20670. * @sample {highcharts} highcharts/yaxis/opposite/
  20671. * Secondary Y axis opposite
  20672. * @sample {highstock} stock/xaxis/opposite/
  20673. * Y axis on left side
  20674. *
  20675. * @type {boolean}
  20676. * @default {highstock} true
  20677. * @default {highcharts} false
  20678. * @product highstock highcharts gantt
  20679. * @apioption yAxis.opposite
  20680. */
  20681. /**
  20682. * @see [tickInterval](#xAxis.tickInterval)
  20683. * @see [tickPositioner](#xAxis.tickPositioner)
  20684. * @see [tickPositions](#xAxis.tickPositions)
  20685. */
  20686. tickPixelInterval: 72,
  20687. showLastLabel: true,
  20688. /**
  20689. * @extends xAxis.labels
  20690. */
  20691. labels: {
  20692. /**
  20693. * Angular gauges and solid gauges only.
  20694. * The label's pixel distance from the perimeter of the plot area.
  20695. *
  20696. * Since v7.1.2: If it's a percentage string, it is interpreted the
  20697. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  20698. * aligned under the gauge's shape.
  20699. *
  20700. * @sample {highcharts} highcharts/yaxis/labels-distance/
  20701. * Labels centered under the arc
  20702. *
  20703. * @type {number|string}
  20704. * @default -25
  20705. * @product highcharts
  20706. * @apioption yAxis.labels.distance
  20707. */
  20708. /**
  20709. * The y position offset of all labels relative to the tick
  20710. * positions on the axis. For polar and radial axis consider the use
  20711. * of the [distance](#yAxis.labels.distance) option.
  20712. *
  20713. * @sample {highcharts} highcharts/xaxis/labels-x/
  20714. * Y axis labels placed on grid lines
  20715. *
  20716. * @type {number}
  20717. * @default {highcharts} 3
  20718. * @default {highstock} -2
  20719. * @default {highmaps} 3
  20720. * @apioption yAxis.labels.y
  20721. */
  20722. /**
  20723. * What part of the string the given position is anchored to. Can
  20724. * be one of `"left"`, `"center"` or `"right"`. The exact position
  20725. * also depends on the `labels.x` setting.
  20726. *
  20727. * Angular gauges and solid gauges defaults to `"center"`.
  20728. * Solid gauges with two labels have additional option `"auto"`
  20729. * for automatic horizontal and vertical alignment.
  20730. *
  20731. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  20732. *
  20733. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  20734. * Left
  20735. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  20736. * Solid gauge labels auto aligned
  20737. *
  20738. * @type {Highcharts.AlignValue}
  20739. * @default {highcharts|highmaps} right
  20740. * @default {highstock} left
  20741. * @apioption yAxis.labels.align
  20742. */
  20743. /**
  20744. * The x position offset of all labels relative to the tick
  20745. * positions on the axis. Defaults to -15 for left axis, 15 for
  20746. * right axis.
  20747. *
  20748. * @sample {highcharts} highcharts/xaxis/labels-x/
  20749. * Y axis labels placed on grid lines
  20750. */
  20751. x: -8
  20752. },
  20753. /**
  20754. * @productdesc {highmaps}
  20755. * In Highmaps, the axis line is hidden by default, because the axis is
  20756. * not visible by default.
  20757. *
  20758. * @type {Highcharts.ColorType}
  20759. * @apioption yAxis.lineColor
  20760. */
  20761. /**
  20762. * @sample {highcharts} highcharts/yaxis/max-200/
  20763. * Y axis max of 200
  20764. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  20765. * Y axis max on logarithmic axis
  20766. * @sample {highstock} stock/yaxis/min-max/
  20767. * Fixed min and max on Y axis
  20768. * @sample {highmaps} maps/axis/min-max/
  20769. * Pre-zoomed to a specific area
  20770. *
  20771. * @apioption yAxis.max
  20772. */
  20773. /**
  20774. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  20775. * -50 with startOnTick to false
  20776. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  20777. * -50 with startOnTick true by default
  20778. * @sample {highstock} stock/yaxis/min-max/
  20779. * Fixed min and max on Y axis
  20780. * @sample {highmaps} maps/axis/min-max/
  20781. * Pre-zoomed to a specific area
  20782. *
  20783. * @apioption yAxis.min
  20784. */
  20785. /**
  20786. * An optional scrollbar to display on the Y axis in response to
  20787. * limiting the minimum an maximum of the axis values.
  20788. *
  20789. * In styled mode, all the presentational options for the scrollbar
  20790. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  20791. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  20792. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  20793. *
  20794. * @sample {highstock} stock/yaxis/scrollbar/
  20795. * Scrollbar on the Y axis
  20796. *
  20797. * @extends scrollbar
  20798. * @since 4.2.6
  20799. * @product highstock
  20800. * @excluding height
  20801. * @apioption yAxis.scrollbar
  20802. */
  20803. /**
  20804. * Enable the scrollbar on the Y axis.
  20805. *
  20806. * @sample {highstock} stock/yaxis/scrollbar/
  20807. * Enabled on Y axis
  20808. *
  20809. * @type {boolean}
  20810. * @default false
  20811. * @since 4.2.6
  20812. * @product highstock
  20813. * @apioption yAxis.scrollbar.enabled
  20814. */
  20815. /**
  20816. * Pixel margin between the scrollbar and the axis elements.
  20817. *
  20818. * @type {number}
  20819. * @default 10
  20820. * @since 4.2.6
  20821. * @product highstock
  20822. * @apioption yAxis.scrollbar.margin
  20823. */
  20824. /**
  20825. * Whether to show the scrollbar when it is fully zoomed out at max
  20826. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  20827. * hidden until the user zooms in, like common in browsers.
  20828. *
  20829. * @type {boolean}
  20830. * @default true
  20831. * @since 4.2.6
  20832. * @product highstock
  20833. * @apioption yAxis.scrollbar.showFull
  20834. */
  20835. /**
  20836. * The width of a vertical scrollbar or height of a horizontal
  20837. * scrollbar. Defaults to 20 on touch devices.
  20838. *
  20839. * @type {number}
  20840. * @default 14
  20841. * @since 4.2.6
  20842. * @product highstock
  20843. * @apioption yAxis.scrollbar.size
  20844. */
  20845. /**
  20846. * Z index of the scrollbar elements.
  20847. *
  20848. * @type {number}
  20849. * @default 3
  20850. * @since 4.2.6
  20851. * @product highstock
  20852. * @apioption yAxis.scrollbar.zIndex
  20853. */
  20854. /**
  20855. * A soft maximum for the axis. If the series data maximum is less
  20856. * than this, the axis will stay at this maximum, but if the series
  20857. * data maximum is higher, the axis will flex to show all data.
  20858. *
  20859. * **Note**: The [series.softThreshold](
  20860. * #plotOptions.series.softThreshold) option takes precedence over this
  20861. * option.
  20862. *
  20863. * @sample highcharts/yaxis/softmin-softmax/
  20864. * Soft min and max
  20865. *
  20866. * @type {number}
  20867. * @since 5.0.1
  20868. * @product highcharts highstock gantt
  20869. * @apioption yAxis.softMax
  20870. */
  20871. /**
  20872. * A soft minimum for the axis. If the series data minimum is greater
  20873. * than this, the axis will stay at this minimum, but if the series
  20874. * data minimum is lower, the axis will flex to show all data.
  20875. *
  20876. * **Note**: The [series.softThreshold](
  20877. * #plotOptions.series.softThreshold) option takes precedence over this
  20878. * option.
  20879. *
  20880. * @sample highcharts/yaxis/softmin-softmax/
  20881. * Soft min and max
  20882. *
  20883. * @type {number}
  20884. * @since 5.0.1
  20885. * @product highcharts highstock gantt
  20886. * @apioption yAxis.softMin
  20887. */
  20888. /**
  20889. * Defines the horizontal alignment of the stack total label. Can be one
  20890. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  20891. * at runtime and depends on orientation and whether the stack is
  20892. * positive or negative.
  20893. *
  20894. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  20895. * Aligned to the left
  20896. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  20897. * Aligned in center
  20898. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  20899. * Aligned to the right
  20900. *
  20901. * @type {Highcharts.AlignValue}
  20902. * @since 2.1.5
  20903. * @product highcharts
  20904. * @apioption yAxis.stackLabels.align
  20905. */
  20906. /**
  20907. * A format string for the data label. Available variables are the same
  20908. * as for `formatter`.
  20909. *
  20910. * @type {string}
  20911. * @default {total}
  20912. * @since 3.0.2
  20913. * @product highcharts highstock
  20914. * @apioption yAxis.stackLabels.format
  20915. */
  20916. /**
  20917. * Rotation of the labels in degrees.
  20918. *
  20919. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  20920. * Labels rotated 45°
  20921. *
  20922. * @type {number}
  20923. * @default 0
  20924. * @since 2.1.5
  20925. * @product highcharts
  20926. * @apioption yAxis.stackLabels.rotation
  20927. */
  20928. /**
  20929. * The text alignment for the label. While `align` determines where the
  20930. * texts anchor point is placed with regards to the stack, `textAlign`
  20931. * determines how the text is aligned against its anchor point. Possible
  20932. * values are `"left"`, `"center"` and `"right"`. The default value is
  20933. * calculated at runtime and depends on orientation and whether the
  20934. * stack is positive or negative.
  20935. *
  20936. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  20937. * Label in center position but text-aligned left
  20938. *
  20939. * @type {Highcharts.AlignValue}
  20940. * @since 2.1.5
  20941. * @product highcharts
  20942. * @apioption yAxis.stackLabels.textAlign
  20943. */
  20944. /**
  20945. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20946. * to render the labels.
  20947. *
  20948. * @type {boolean}
  20949. * @default false
  20950. * @since 3.0
  20951. * @product highcharts highstock
  20952. * @apioption yAxis.stackLabels.useHTML
  20953. */
  20954. /**
  20955. * Defines the vertical alignment of the stack total label. Can be one
  20956. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  20957. * at runtime and depends on orientation and whether the stack is
  20958. * positive or negative.
  20959. *
  20960. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  20961. * Vertically aligned top
  20962. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  20963. * Vertically aligned middle
  20964. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  20965. * Vertically aligned bottom
  20966. *
  20967. * @type {Highcharts.VerticalAlignValue}
  20968. * @since 2.1.5
  20969. * @product highcharts
  20970. * @apioption yAxis.stackLabels.verticalAlign
  20971. */
  20972. /**
  20973. * The x position offset of the label relative to the left of the
  20974. * stacked bar. The default value is calculated at runtime and depends
  20975. * on orientation and whether the stack is positive or negative.
  20976. *
  20977. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  20978. * Stack total labels with x offset
  20979. *
  20980. * @type {number}
  20981. * @since 2.1.5
  20982. * @product highcharts
  20983. * @apioption yAxis.stackLabels.x
  20984. */
  20985. /**
  20986. * The y position offset of the label relative to the tick position
  20987. * on the axis. The default value is calculated at runtime and depends
  20988. * on orientation and whether the stack is positive or negative.
  20989. *
  20990. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  20991. * Stack total labels with y offset
  20992. *
  20993. * @type {number}
  20994. * @since 2.1.5
  20995. * @product highcharts
  20996. * @apioption yAxis.stackLabels.y
  20997. */
  20998. /**
  20999. * Whether to force the axis to start on a tick. Use this option with
  21000. * the `maxPadding` option to control the axis start.
  21001. *
  21002. * This option is always disabled, when panning type is
  21003. * either `y` or `xy`.
  21004. *
  21005. * @see [type](#chart.panning.type)
  21006. *
  21007. * @sample {highcharts} highcharts/xaxis/startontick-false/
  21008. * False by default
  21009. * @sample {highcharts} highcharts/xaxis/startontick-true/
  21010. * True
  21011. * @sample {highstock} stock/xaxis/endontick/
  21012. * False for Y axis
  21013. *
  21014. * @since 1.2.0
  21015. * @product highcharts highstock gantt
  21016. */
  21017. startOnTick: true,
  21018. title: {
  21019. /**
  21020. * The pixel distance between the axis labels and the title.
  21021. * Positive values are outside the axis line, negative are inside.
  21022. *
  21023. * @sample {highcharts} highcharts/xaxis/title-margin/
  21024. * Y axis title margin of 60
  21025. *
  21026. * @type {number}
  21027. * @default 40
  21028. * @apioption yAxis.title.margin
  21029. */
  21030. /**
  21031. * The rotation of the text in degrees. 0 is horizontal, 270 is
  21032. * vertical reading from bottom to top.
  21033. *
  21034. * @sample {highcharts} highcharts/yaxis/title-offset/
  21035. * Horizontal
  21036. */
  21037. rotation: 270,
  21038. /**
  21039. * The actual text of the axis title. Horizontal texts can contain
  21040. * HTML, but rotated texts are painted using vector techniques and
  21041. * must be clean text. The Y axis title is disabled by setting the
  21042. * `text` option to `undefined`.
  21043. *
  21044. * @sample {highcharts} highcharts/xaxis/title-text/
  21045. * Custom HTML
  21046. *
  21047. * @type {string|null}
  21048. * @default {highcharts} Values
  21049. * @default {highstock} undefined
  21050. * @product highcharts highstock gantt
  21051. */
  21052. text: 'Values'
  21053. },
  21054. /**
  21055. * The top position of the Y axis. If it's a number, it is interpreted
  21056. * as pixel position relative to the chart.
  21057. *
  21058. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  21059. * percentages of the plot height, offset from plot area top.
  21060. *
  21061. * @see [yAxis.height](#yAxis.height)
  21062. *
  21063. * @sample {highstock} stock/demo/candlestick-and-volume/
  21064. * Percentage height panes
  21065. *
  21066. * @type {number|string}
  21067. * @product highcharts highstock
  21068. * @apioption yAxis.top
  21069. */
  21070. /**
  21071. * The stack labels show the total value for each bar in a stacked
  21072. * column or bar chart. The label will be placed on top of positive
  21073. * columns and below negative columns. In case of an inverted column
  21074. * chart or a bar chart the label is placed to the right of positive
  21075. * bars and to the left of negative bars.
  21076. *
  21077. * @product highcharts
  21078. */
  21079. stackLabels: {
  21080. /**
  21081. * Enable or disable the initial animation when a series is
  21082. * displayed for the `stackLabels`. The animation can also be set as
  21083. * a configuration object. Please note that this option only
  21084. * applies to the initial animation.
  21085. * For other animations, see [chart.animation](#chart.animation)
  21086. * and the animation parameter under the API methods.
  21087. * The following properties are supported:
  21088. *
  21089. * - `defer`: The animation delay time in milliseconds.
  21090. *
  21091. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  21092. * Animation defer settings
  21093. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  21094. * @since 8.2.0
  21095. * @apioption yAxis.stackLabels.animation
  21096. */
  21097. animation: {},
  21098. /**
  21099. * The animation delay time in milliseconds.
  21100. * Set to `0` renders stackLabel immediately.
  21101. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  21102. *
  21103. * @type {number}
  21104. * @since 8.2.0
  21105. * @apioption yAxis.stackLabels.animation.defer
  21106. */
  21107. /**
  21108. * Allow the stack labels to overlap.
  21109. *
  21110. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  21111. * Default false
  21112. *
  21113. * @since 5.0.13
  21114. * @product highcharts
  21115. */
  21116. allowOverlap: false,
  21117. /**
  21118. * The background color or gradient for the stack label.
  21119. *
  21120. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21121. * Stack labels box options
  21122. * @type {Highcharts.ColorType}
  21123. * @since 8.1.0
  21124. * @apioption yAxis.stackLabels.backgroundColor
  21125. */
  21126. /**
  21127. * The border color for the stack label. Defaults to `undefined`.
  21128. *
  21129. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21130. * Stack labels box options
  21131. * @type {Highcharts.ColorType}
  21132. * @since 8.1.0
  21133. * @apioption yAxis.stackLabels.borderColor
  21134. */
  21135. /**
  21136. * The border radius in pixels for the stack label.
  21137. *
  21138. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21139. * Stack labels box options
  21140. * @type {number}
  21141. * @default 0
  21142. * @since 8.1.0
  21143. * @apioption yAxis.stackLabels.borderRadius
  21144. */
  21145. /**
  21146. * The border width in pixels for the stack label.
  21147. *
  21148. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21149. * Stack labels box options
  21150. * @type {number}
  21151. * @default 0
  21152. * @since 8.1.0
  21153. * @apioption yAxis.stackLabels.borderWidth
  21154. */
  21155. /**
  21156. * Enable or disable the stack total labels.
  21157. *
  21158. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  21159. * Enabled stack total labels
  21160. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  21161. * Enabled stack labels in waterfall chart
  21162. *
  21163. * @since 2.1.5
  21164. * @product highcharts
  21165. */
  21166. enabled: false,
  21167. /**
  21168. * Whether to hide stack labels that are outside the plot area.
  21169. * By default, the stack label is moved
  21170. * inside the plot area according to the
  21171. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  21172. * option.
  21173. *
  21174. * @type {boolean}
  21175. * @since 7.1.3
  21176. */
  21177. crop: true,
  21178. /**
  21179. * How to handle stack total labels that flow outside the plot area.
  21180. * The default is set to `"justify"`,
  21181. * which aligns them inside the plot area.
  21182. * For columns and bars, this means it will be moved inside the bar.
  21183. * To display stack labels outside the plot area,
  21184. * set `crop` to `false` and `overflow` to `"allow"`.
  21185. *
  21186. * @sample highcharts/yaxis/stacklabels-overflow/
  21187. * Stack labels flows outside the plot area.
  21188. *
  21189. * @type {Highcharts.DataLabelsOverflowValue}
  21190. * @since 7.1.3
  21191. */
  21192. overflow: 'justify',
  21193. /* eslint-disable valid-jsdoc */
  21194. /**
  21195. * Callback JavaScript function to format the label. The value is
  21196. * given by `this.total`.
  21197. *
  21198. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  21199. * Added units to stack total value
  21200. *
  21201. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  21202. * @since 2.1.5
  21203. * @product highcharts
  21204. */
  21205. formatter: function () {
  21206. var numberFormatter = this.axis.chart.numberFormatter;
  21207. /* eslint-enable valid-jsdoc */
  21208. return numberFormatter(this.total, -1);
  21209. },
  21210. /**
  21211. * CSS styles for the label.
  21212. *
  21213. * In styled mode, the styles are set in the
  21214. * `.highcharts-stack-label` class.
  21215. *
  21216. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  21217. * Red stack total labels
  21218. *
  21219. * @type {Highcharts.CSSObject}
  21220. * @since 2.1.5
  21221. * @product highcharts
  21222. */
  21223. style: {
  21224. /** @internal */
  21225. color: palette.neutralColor100,
  21226. /** @internal */
  21227. fontSize: '11px',
  21228. /** @internal */
  21229. fontWeight: 'bold',
  21230. /** @internal */
  21231. textOutline: '1px contrast'
  21232. }
  21233. },
  21234. gridLineWidth: 1,
  21235. lineWidth: 0
  21236. // tickWidth: 0
  21237. };
  21238. /**
  21239. * The Z axis or depth axis for 3D plots.
  21240. *
  21241. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  21242. * access to the axis.
  21243. *
  21244. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  21245. * Z-Axis with Categories
  21246. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  21247. * Z-Axis with styling
  21248. *
  21249. * @type {*|Array<*>}
  21250. * @extends xAxis
  21251. * @since 5.0.0
  21252. * @product highcharts
  21253. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  21254. * nameToX, showEmpty, top, width
  21255. * @apioption zAxis
  21256. *
  21257. * @private
  21258. */
  21259. // This variable extends the defaultOptions for left axes.
  21260. Axis.defaultLeftAxisOptions = {
  21261. labels: {
  21262. x: -15
  21263. },
  21264. title: {
  21265. rotation: 270
  21266. }
  21267. };
  21268. // This variable extends the defaultOptions for right axes.
  21269. Axis.defaultRightAxisOptions = {
  21270. labels: {
  21271. x: 15
  21272. },
  21273. title: {
  21274. rotation: 90
  21275. }
  21276. };
  21277. // This variable extends the defaultOptions for bottom axes.
  21278. Axis.defaultBottomAxisOptions = {
  21279. labels: {
  21280. autoRotation: [-45],
  21281. x: 0
  21282. // overflow: undefined,
  21283. // staggerLines: null
  21284. },
  21285. margin: 15,
  21286. title: {
  21287. rotation: 0
  21288. }
  21289. };
  21290. // This variable extends the defaultOptions for top axes.
  21291. Axis.defaultTopAxisOptions = {
  21292. labels: {
  21293. autoRotation: [-45],
  21294. x: 0
  21295. // overflow: undefined
  21296. // staggerLines: null
  21297. },
  21298. margin: 15,
  21299. title: {
  21300. rotation: 0
  21301. }
  21302. };
  21303. // Properties to survive after destroy, needed for Axis.update (#4317,
  21304. // #5773, #5881).
  21305. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  21306. return Axis;
  21307. }());
  21308. H.Axis = Axis;
  21309. return H.Axis;
  21310. });
  21311. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21312. /* *
  21313. *
  21314. * (c) 2010-2021 Torstein Honsi
  21315. *
  21316. * License: www.highcharts.com/license
  21317. *
  21318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21319. *
  21320. * */
  21321. var addEvent = U.addEvent,
  21322. getMagnitude = U.getMagnitude,
  21323. normalizeTickInterval = U.normalizeTickInterval,
  21324. timeUnits = U.timeUnits;
  21325. /* eslint-disable valid-jsdoc */
  21326. var DateTimeAxisAdditions = /** @class */ (function () {
  21327. /* *
  21328. *
  21329. * Constructors
  21330. *
  21331. * */
  21332. function DateTimeAxisAdditions(axis) {
  21333. this.axis = axis;
  21334. }
  21335. /* *
  21336. *
  21337. * Functions
  21338. *
  21339. * */
  21340. /**
  21341. * Get a normalized tick interval for dates. Returns a configuration object
  21342. * with unit range (interval), count and name. Used to prepare data for
  21343. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21344. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21345. * logic was extracted in order to prevent it for running over again for
  21346. * each segment having the same interval. #662, #697.
  21347. * @private
  21348. */
  21349. /**
  21350. * Get a normalized tick interval for dates. Returns a configuration object
  21351. * with unit range (interval), count and name. Used to prepare data for
  21352. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21353. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21354. * logic was extracted in order to prevent it for running over again for
  21355. * each segment having the same interval. #662, #697.
  21356. * @private
  21357. */
  21358. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  21359. var units = unitsOption || [[
  21360. 'millisecond',
  21361. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  21362. ],
  21363. [
  21364. 'second',
  21365. [1, 2, 5, 10, 15, 30]
  21366. ],
  21367. [
  21368. 'minute',
  21369. [1, 2, 5, 10, 15, 30]
  21370. ],
  21371. [
  21372. 'hour',
  21373. [1, 2, 3, 4, 6, 8, 12]
  21374. ],
  21375. [
  21376. 'day',
  21377. [1, 2]
  21378. ],
  21379. [
  21380. 'week',
  21381. [1, 2]
  21382. ],
  21383. [
  21384. 'month',
  21385. [1, 2, 3, 4, 6]
  21386. ],
  21387. [
  21388. 'year',
  21389. null
  21390. ]],
  21391. unit = units[units.length - 1], // default unit is years
  21392. interval = timeUnits[unit[0]],
  21393. multiples = unit[1],
  21394. count,
  21395. i;
  21396. // loop through the units to find the one that best fits the
  21397. // tickInterval
  21398. for (i = 0; i < units.length; i++) {
  21399. unit = units[i];
  21400. interval = timeUnits[unit[0]];
  21401. multiples = unit[1];
  21402. if (units[i + 1]) {
  21403. // lessThan is in the middle between the highest multiple and
  21404. // the next unit.
  21405. var lessThan = (interval *
  21406. multiples[multiples.length - 1] +
  21407. timeUnits[units[i + 1][0]]) / 2;
  21408. // break and keep the current unit
  21409. if (tickInterval <= lessThan) {
  21410. break;
  21411. }
  21412. }
  21413. }
  21414. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  21415. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  21416. multiples = [1, 2, 5];
  21417. }
  21418. // get the count
  21419. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  21420. Math.max(getMagnitude(tickInterval / interval), 1) :
  21421. 1);
  21422. return {
  21423. unitRange: interval,
  21424. count: count,
  21425. unitName: unit[0]
  21426. };
  21427. };
  21428. return DateTimeAxisAdditions;
  21429. }());
  21430. /**
  21431. * Date and time support for axes.
  21432. *
  21433. * @private
  21434. * @class
  21435. */
  21436. var DateTimeAxis = /** @class */ (function () {
  21437. function DateTimeAxis() {
  21438. }
  21439. /* *
  21440. *
  21441. * Static Functions
  21442. *
  21443. * */
  21444. /**
  21445. * Extends axis class with date and time support.
  21446. * @private
  21447. */
  21448. DateTimeAxis.compose = function (AxisClass) {
  21449. AxisClass.keepProps.push('dateTime');
  21450. var axisProto = AxisClass.prototype;
  21451. /**
  21452. * Set the tick positions to a time unit that makes sense, for example
  21453. * on the first of each month or on every Monday. Return an array with
  21454. * the time positions. Used in datetime axes as well as for grouping
  21455. * data on a datetime axis.
  21456. *
  21457. * @private
  21458. * @function Highcharts.Axis#getTimeTicks
  21459. *
  21460. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  21461. * The interval in axis values (ms) and thecount.
  21462. *
  21463. * @param {number} min
  21464. * The minimum in axis values.
  21465. *
  21466. * @param {number} max
  21467. * The maximum in axis values.
  21468. *
  21469. * @param {number} startOfWeek
  21470. *
  21471. * @return {Highcharts.AxisTickPositionsArray}
  21472. */
  21473. axisProto.getTimeTicks = function () {
  21474. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  21475. };
  21476. /* eslint-disable no-invalid-this */
  21477. addEvent(AxisClass, 'init', function (e) {
  21478. var axis = this;
  21479. var options = e.userOptions;
  21480. if (options.type !== 'datetime') {
  21481. axis.dateTime = void 0;
  21482. return;
  21483. }
  21484. if (!axis.dateTime) {
  21485. axis.dateTime = new DateTimeAxisAdditions(axis);
  21486. }
  21487. });
  21488. /* eslint-enable no-invalid-this */
  21489. };
  21490. /* *
  21491. *
  21492. * Static Properties
  21493. *
  21494. * */
  21495. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  21496. return DateTimeAxis;
  21497. }());
  21498. DateTimeAxis.compose(Axis);
  21499. return DateTimeAxis;
  21500. });
  21501. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21502. /* *
  21503. *
  21504. * (c) 2010-2021 Torstein Honsi
  21505. *
  21506. * License: www.highcharts.com/license
  21507. *
  21508. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21509. *
  21510. * */
  21511. var addEvent = U.addEvent,
  21512. getMagnitude = U.getMagnitude,
  21513. normalizeTickInterval = U.normalizeTickInterval,
  21514. pick = U.pick;
  21515. /* eslint-disable valid-jsdoc */
  21516. /**
  21517. * Provides logarithmic support for axes.
  21518. *
  21519. * @private
  21520. * @class
  21521. */
  21522. var LogarithmicAxisAdditions = /** @class */ (function () {
  21523. /* *
  21524. *
  21525. * Constructors
  21526. *
  21527. * */
  21528. function LogarithmicAxisAdditions(axis) {
  21529. this.axis = axis;
  21530. }
  21531. /* *
  21532. *
  21533. * Functions
  21534. *
  21535. * */
  21536. /**
  21537. * Set the tick positions of a logarithmic axis.
  21538. */
  21539. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  21540. var log = this;
  21541. var axis = log.axis;
  21542. var axisLength = axis.len;
  21543. var options = axis.options;
  21544. // Since we use this method for both major and minor ticks,
  21545. // use a local variable and return the result
  21546. var positions = [];
  21547. // Reset
  21548. if (!minor) {
  21549. log.minorAutoInterval = void 0;
  21550. }
  21551. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  21552. if (interval >= 0.5) {
  21553. interval = Math.round(interval);
  21554. positions = axis.getLinearTickPositions(interval, min, max);
  21555. // Second case: We need intermediary ticks. For example
  21556. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  21557. }
  21558. else if (interval >= 0.08) {
  21559. var roundedMin = Math.floor(min),
  21560. intermediate = void 0,
  21561. i = void 0,
  21562. j = void 0,
  21563. len = void 0,
  21564. pos = void 0,
  21565. lastPos = void 0,
  21566. break2 = void 0;
  21567. if (interval > 0.3) {
  21568. intermediate = [1, 2, 4];
  21569. // 0.2 equals five minor ticks per 1, 10, 100 etc
  21570. }
  21571. else if (interval > 0.15) {
  21572. intermediate = [1, 2, 4, 6, 8];
  21573. }
  21574. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  21575. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  21576. }
  21577. for (i = roundedMin; i < max + 1 && !break2; i++) {
  21578. len = intermediate.length;
  21579. for (j = 0; j < len && !break2; j++) {
  21580. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  21581. // #1670, lastPos is #3113
  21582. if (pos > min &&
  21583. (!minor || lastPos <= max) &&
  21584. typeof lastPos !== 'undefined') {
  21585. positions.push(lastPos);
  21586. }
  21587. if (lastPos > max) {
  21588. break2 = true;
  21589. }
  21590. lastPos = pos;
  21591. }
  21592. }
  21593. // Third case: We are so deep in between whole logarithmic values that
  21594. // we might as well handle the tick positions like a linear axis. For
  21595. // example 1.01, 1.02, 1.03, 1.04.
  21596. }
  21597. else {
  21598. var realMin = log.lin2log(min),
  21599. realMax = log.lin2log(max),
  21600. tickIntervalOption = minor ?
  21601. axis.getMinorTickInterval() :
  21602. options.tickInterval,
  21603. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  21604. null :
  21605. tickIntervalOption,
  21606. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  21607. totalPixelLength = minor ?
  21608. axisLength / axis.tickPositions.length :
  21609. axisLength;
  21610. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  21611. tickPixelIntervalOption / (totalPixelLength || 1));
  21612. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  21613. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  21614. if (!minor) {
  21615. log.minorAutoInterval = interval / 5;
  21616. }
  21617. }
  21618. // Set the axis-level tickInterval variable
  21619. if (!minor) {
  21620. axis.tickInterval = interval;
  21621. }
  21622. return positions;
  21623. };
  21624. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  21625. return Math.pow(10, num);
  21626. };
  21627. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  21628. return Math.log(num) / Math.LN10;
  21629. };
  21630. return LogarithmicAxisAdditions;
  21631. }());
  21632. var LogarithmicAxis = /** @class */ (function () {
  21633. function LogarithmicAxis() {
  21634. }
  21635. /**
  21636. * Provides logarithmic support for axes.
  21637. *
  21638. * @private
  21639. */
  21640. LogarithmicAxis.compose = function (AxisClass) {
  21641. AxisClass.keepProps.push('logarithmic');
  21642. /* eslint-disable no-invalid-this */
  21643. addEvent(AxisClass, 'init', function (e) {
  21644. var axis = this;
  21645. var options = e.userOptions;
  21646. var logarithmic = axis.logarithmic;
  21647. if (options.type !== 'logarithmic') {
  21648. axis.logarithmic = void 0;
  21649. }
  21650. else {
  21651. if (!logarithmic) {
  21652. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  21653. }
  21654. }
  21655. });
  21656. addEvent(AxisClass, 'afterInit', function () {
  21657. var axis = this;
  21658. var log = axis.logarithmic;
  21659. // extend logarithmic axis
  21660. if (log) {
  21661. axis.lin2val = function (num) {
  21662. return log.lin2log(num);
  21663. };
  21664. axis.val2lin = function (num) {
  21665. return log.log2lin(num);
  21666. };
  21667. }
  21668. });
  21669. };
  21670. return LogarithmicAxis;
  21671. }());
  21672. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  21673. return LogarithmicAxis;
  21674. });
  21675. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (Axis, H, palette, U) {
  21676. /* *
  21677. *
  21678. * (c) 2010-2021 Torstein Honsi
  21679. *
  21680. * License: www.highcharts.com/license
  21681. *
  21682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21683. *
  21684. * */
  21685. /**
  21686. * Options for plot bands on axes.
  21687. *
  21688. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  21689. */
  21690. /**
  21691. * Options for plot band labels on axes.
  21692. *
  21693. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  21694. */
  21695. /**
  21696. * Options for plot lines on axes.
  21697. *
  21698. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  21699. */
  21700. /**
  21701. * Options for plot line labels on axes.
  21702. *
  21703. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  21704. */
  21705. var arrayMax = U.arrayMax,
  21706. arrayMin = U.arrayMin,
  21707. defined = U.defined,
  21708. destroyObjectProperties = U.destroyObjectProperties,
  21709. erase = U.erase,
  21710. extend = U.extend,
  21711. fireEvent = U.fireEvent,
  21712. isNumber = U.isNumber,
  21713. merge = U.merge,
  21714. objectEach = U.objectEach,
  21715. pick = U.pick;
  21716. /* eslint-disable no-invalid-this, valid-jsdoc */
  21717. /**
  21718. * The object wrapper for plot lines and plot bands
  21719. *
  21720. * @class
  21721. * @name Highcharts.PlotLineOrBand
  21722. *
  21723. * @param {Highcharts.Axis} axis
  21724. *
  21725. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  21726. */
  21727. var PlotLineOrBand = /** @class */ (function () {
  21728. function PlotLineOrBand(axis, options) {
  21729. this.axis = axis;
  21730. if (options) {
  21731. this.options = options;
  21732. this.id = options.id;
  21733. }
  21734. }
  21735. /**
  21736. * Render the plot line or plot band. If it is already existing,
  21737. * move it.
  21738. *
  21739. * @private
  21740. * @function Highcharts.PlotLineOrBand#render
  21741. * @return {Highcharts.PlotLineOrBand|undefined}
  21742. */
  21743. PlotLineOrBand.prototype.render = function () {
  21744. fireEvent(this, 'render');
  21745. var plotLine = this,
  21746. axis = plotLine.axis,
  21747. horiz = axis.horiz,
  21748. log = axis.logarithmic,
  21749. options = plotLine.options,
  21750. optionsLabel = options.label,
  21751. label = plotLine.label,
  21752. to = options.to,
  21753. from = options.from,
  21754. value = options.value,
  21755. isBand = defined(from) && defined(to),
  21756. isLine = defined(value),
  21757. svgElem = plotLine.svgElem,
  21758. isNew = !svgElem,
  21759. path = [],
  21760. color = options.color,
  21761. zIndex = pick(options.zIndex, 0),
  21762. events = options.events,
  21763. attribs = {
  21764. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  21765. (options.className || '')
  21766. },
  21767. groupAttribs = {},
  21768. renderer = axis.chart.renderer,
  21769. groupName = isBand ? 'bands' : 'lines',
  21770. group;
  21771. // logarithmic conversion
  21772. if (log) {
  21773. from = log.log2lin(from);
  21774. to = log.log2lin(to);
  21775. value = log.log2lin(value);
  21776. }
  21777. // Set the presentational attributes
  21778. if (!axis.chart.styledMode) {
  21779. if (isLine) {
  21780. attribs.stroke = color || palette.neutralColor40;
  21781. attribs['stroke-width'] = pick(options.width, 1);
  21782. if (options.dashStyle) {
  21783. attribs.dashstyle =
  21784. options.dashStyle;
  21785. }
  21786. }
  21787. else if (isBand) { // plot band
  21788. attribs.fill = color || palette.highlightColor10;
  21789. if (options.borderWidth) {
  21790. attribs.stroke = options.borderColor;
  21791. attribs['stroke-width'] = options.borderWidth;
  21792. }
  21793. }
  21794. }
  21795. // Grouping and zIndex
  21796. groupAttribs.zIndex = zIndex;
  21797. groupName += '-' + zIndex;
  21798. group = axis.plotLinesAndBandsGroups[groupName];
  21799. if (!group) {
  21800. axis.plotLinesAndBandsGroups[groupName] = group =
  21801. renderer.g('plot-' + groupName)
  21802. .attr(groupAttribs).add();
  21803. }
  21804. // Create the path
  21805. if (isNew) {
  21806. /**
  21807. * SVG element of the plot line or band.
  21808. *
  21809. * @name Highcharts.PlotLineOrBand#svgElement
  21810. * @type {Highcharts.SVGElement}
  21811. */
  21812. plotLine.svgElem = svgElem = renderer
  21813. .path()
  21814. .attr(attribs)
  21815. .add(group);
  21816. }
  21817. // Set the path or return
  21818. if (isLine) {
  21819. path = axis.getPlotLinePath({
  21820. value: value,
  21821. lineWidth: svgElem.strokeWidth(),
  21822. acrossPanes: options.acrossPanes
  21823. });
  21824. }
  21825. else if (isBand) { // plot band
  21826. path = axis.getPlotBandPath(from, to, options);
  21827. }
  21828. else {
  21829. return;
  21830. }
  21831. // common for lines and bands
  21832. // Add events only if they were not added before.
  21833. if (!plotLine.eventsAdded && events) {
  21834. objectEach(events, function (event, eventType) {
  21835. svgElem.on(eventType, function (e) {
  21836. events[eventType].apply(plotLine, [e]);
  21837. });
  21838. });
  21839. plotLine.eventsAdded = true;
  21840. }
  21841. if ((isNew || !svgElem.d) && path && path.length) {
  21842. svgElem.attr({ d: path });
  21843. }
  21844. else if (svgElem) {
  21845. if (path) {
  21846. svgElem.show(true);
  21847. svgElem.animate({ d: path });
  21848. }
  21849. else if (svgElem.d) {
  21850. svgElem.hide();
  21851. if (label) {
  21852. plotLine.label = label = label.destroy();
  21853. }
  21854. }
  21855. }
  21856. // the plot band/line label
  21857. if (optionsLabel &&
  21858. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  21859. path &&
  21860. path.length &&
  21861. axis.width > 0 &&
  21862. axis.height > 0 &&
  21863. !path.isFlat) {
  21864. // apply defaults
  21865. optionsLabel = merge({
  21866. align: horiz && isBand && 'center',
  21867. x: horiz ? !isBand && 4 : 10,
  21868. verticalAlign: !horiz && isBand && 'middle',
  21869. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  21870. rotation: horiz && !isBand && 90
  21871. }, optionsLabel);
  21872. this.renderLabel(optionsLabel, path, isBand, zIndex);
  21873. }
  21874. else if (label) { // move out of sight
  21875. label.hide();
  21876. }
  21877. // chainable
  21878. return plotLine;
  21879. };
  21880. /**
  21881. * Render and align label for plot line or band.
  21882. *
  21883. * @private
  21884. * @function Highcharts.PlotLineOrBand#renderLabel
  21885. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21886. * @param {Highcharts.SVGPathArray} path
  21887. * @param {boolean} [isBand]
  21888. * @param {number} [zIndex]
  21889. * @return {void}
  21890. */
  21891. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  21892. var plotLine = this,
  21893. label = plotLine.label,
  21894. renderer = plotLine.axis.chart.renderer,
  21895. attribs,
  21896. xBounds,
  21897. yBounds,
  21898. x,
  21899. y,
  21900. labelText;
  21901. // add the SVG element
  21902. if (!label) {
  21903. attribs = {
  21904. align: optionsLabel.textAlign || optionsLabel.align,
  21905. rotation: optionsLabel.rotation,
  21906. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  21907. '-label ' + (optionsLabel.className || '')
  21908. };
  21909. attribs.zIndex = zIndex;
  21910. labelText = this.getLabelText(optionsLabel);
  21911. /**
  21912. * SVG element of the label.
  21913. *
  21914. * @name Highcharts.PlotLineOrBand#label
  21915. * @type {Highcharts.SVGElement}
  21916. */
  21917. plotLine.label = label = renderer
  21918. .text(labelText, 0, 0, optionsLabel.useHTML)
  21919. .attr(attribs)
  21920. .add();
  21921. if (!this.axis.chart.styledMode) {
  21922. label.css(optionsLabel.style);
  21923. }
  21924. }
  21925. // get the bounding box and align the label
  21926. // #3000 changed to better handle choice between plotband or plotline
  21927. xBounds = path.xBounds ||
  21928. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  21929. yBounds = path.yBounds ||
  21930. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  21931. x = arrayMin(xBounds);
  21932. y = arrayMin(yBounds);
  21933. label.align(optionsLabel, false, {
  21934. x: x,
  21935. y: y,
  21936. width: arrayMax(xBounds) - x,
  21937. height: arrayMax(yBounds) - y
  21938. });
  21939. label.show(true);
  21940. };
  21941. /**
  21942. * Get label's text content.
  21943. *
  21944. * @private
  21945. * @function Highcharts.PlotLineOrBand#getLabelText
  21946. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21947. * @return {string}
  21948. */
  21949. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  21950. return defined(optionsLabel.formatter) ?
  21951. optionsLabel.formatter
  21952. .call(this) :
  21953. optionsLabel.text;
  21954. };
  21955. /**
  21956. * Remove the plot line or band.
  21957. *
  21958. * @function Highcharts.PlotLineOrBand#destroy
  21959. * @return {void}
  21960. */
  21961. PlotLineOrBand.prototype.destroy = function () {
  21962. // remove it from the lookup
  21963. erase(this.axis.plotLinesAndBands, this);
  21964. delete this.axis;
  21965. destroyObjectProperties(this);
  21966. };
  21967. return PlotLineOrBand;
  21968. }());
  21969. /* eslint-enable no-invalid-this, valid-jsdoc */
  21970. // Object with members for extending the Axis prototype
  21971. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  21972. /**
  21973. * An array of colored bands stretching across the plot area marking an
  21974. * interval on the axis.
  21975. *
  21976. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  21977. * class in addition to the `className` option.
  21978. *
  21979. * @productdesc {highcharts}
  21980. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  21981. * perimeter of the gauge.
  21982. *
  21983. * @type {Array<*>}
  21984. * @product highcharts highstock gantt
  21985. * @apioption xAxis.plotBands
  21986. */
  21987. /**
  21988. * Flag to decide if plotBand should be rendered across all panes.
  21989. *
  21990. * @since 7.1.2
  21991. * @product highstock
  21992. * @type {boolean}
  21993. * @default true
  21994. * @apioption xAxis.plotBands.acrossPanes
  21995. */
  21996. /**
  21997. * Border color for the plot band. Also requires `borderWidth` to be set.
  21998. *
  21999. * @type {Highcharts.ColorString}
  22000. * @apioption xAxis.plotBands.borderColor
  22001. */
  22002. /**
  22003. * Border width for the plot band. Also requires `borderColor` to be set.
  22004. *
  22005. * @type {number}
  22006. * @default 0
  22007. * @apioption xAxis.plotBands.borderWidth
  22008. */
  22009. /**
  22010. * A custom class name, in addition to the default `highcharts-plot-band`,
  22011. * to apply to each individual band.
  22012. *
  22013. * @type {string}
  22014. * @since 5.0.0
  22015. * @apioption xAxis.plotBands.className
  22016. */
  22017. /**
  22018. * The color of the plot band.
  22019. *
  22020. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22021. * Color band
  22022. * @sample {highstock} stock/xaxis/plotbands/
  22023. * Plot band on Y axis
  22024. *
  22025. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22026. * @default ${palette.highlightColor10}
  22027. * @apioption xAxis.plotBands.color
  22028. */
  22029. /**
  22030. * An object defining mouse events for the plot band. Supported properties
  22031. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  22032. *
  22033. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  22034. * Mouse events demonstrated
  22035. *
  22036. * @since 1.2
  22037. * @apioption xAxis.plotBands.events
  22038. */
  22039. /**
  22040. * Click event on a plot band.
  22041. *
  22042. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22043. * @apioption xAxis.plotBands.events.click
  22044. */
  22045. /**
  22046. * Mouse move event on a plot band.
  22047. *
  22048. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22049. * @apioption xAxis.plotBands.events.mousemove
  22050. */
  22051. /**
  22052. * Mouse out event on the corner of a plot band.
  22053. *
  22054. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22055. * @apioption xAxis.plotBands.events.mouseout
  22056. */
  22057. /**
  22058. * Mouse over event on a plot band.
  22059. *
  22060. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22061. * @apioption xAxis.plotBands.events.mouseover
  22062. */
  22063. /**
  22064. * The start position of the plot band in axis units.
  22065. *
  22066. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22067. * Datetime axis
  22068. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22069. * Categorized axis
  22070. * @sample {highstock} stock/xaxis/plotbands/
  22071. * Plot band on Y axis
  22072. *
  22073. * @type {number}
  22074. * @apioption xAxis.plotBands.from
  22075. */
  22076. /**
  22077. * An id used for identifying the plot band in Axis.removePlotBand.
  22078. *
  22079. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  22080. * Remove plot band by id
  22081. * @sample {highstock} highcharts/xaxis/plotbands-id/
  22082. * Remove plot band by id
  22083. *
  22084. * @type {string}
  22085. * @apioption xAxis.plotBands.id
  22086. */
  22087. /**
  22088. * The end position of the plot band in axis units.
  22089. *
  22090. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22091. * Datetime axis
  22092. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22093. * Categorized axis
  22094. * @sample {highstock} stock/xaxis/plotbands/
  22095. * Plot band on Y axis
  22096. *
  22097. * @type {number}
  22098. * @apioption xAxis.plotBands.to
  22099. */
  22100. /**
  22101. * The z index of the plot band within the chart, relative to other
  22102. * elements. Using the same z index as another element may give
  22103. * unpredictable results, as the last rendered element will be on top.
  22104. * Values from 0 to 20 make sense.
  22105. *
  22106. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22107. * Behind plot lines by default
  22108. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  22109. * Above plot lines
  22110. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  22111. * Above plot lines and series
  22112. *
  22113. * @type {number}
  22114. * @since 1.2
  22115. * @apioption xAxis.plotBands.zIndex
  22116. */
  22117. /**
  22118. * Text labels for the plot bands
  22119. *
  22120. * @product highcharts highstock gantt
  22121. * @apioption xAxis.plotBands.label
  22122. */
  22123. /**
  22124. * Horizontal alignment of the label. Can be one of "left", "center" or
  22125. * "right".
  22126. *
  22127. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22128. * Aligned to the right
  22129. * @sample {highstock} stock/xaxis/plotbands-label/
  22130. * Plot band with labels
  22131. *
  22132. * @type {Highcharts.AlignValue}
  22133. * @default center
  22134. * @since 2.1
  22135. * @apioption xAxis.plotBands.label.align
  22136. */
  22137. /**
  22138. * Rotation of the text label in degrees .
  22139. *
  22140. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22141. * Vertical text
  22142. *
  22143. * @type {number}
  22144. * @default 0
  22145. * @since 2.1
  22146. * @apioption xAxis.plotBands.label.rotation
  22147. */
  22148. /**
  22149. * CSS styles for the text label.
  22150. *
  22151. * In styled mode, the labels are styled by the
  22152. * `.highcharts-plot-band-label` class.
  22153. *
  22154. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  22155. * Blue and bold label
  22156. *
  22157. * @type {Highcharts.CSSObject}
  22158. * @since 2.1
  22159. * @apioption xAxis.plotBands.label.style
  22160. */
  22161. /**
  22162. * The string text itself. A subset of HTML is supported.
  22163. *
  22164. * @type {string}
  22165. * @since 2.1
  22166. * @apioption xAxis.plotBands.label.text
  22167. */
  22168. /**
  22169. * The text alignment for the label. While `align` determines where the
  22170. * texts anchor point is placed within the plot band, `textAlign` determines
  22171. * how the text is aligned against its anchor point. Possible values are
  22172. * "left", "center" and "right". Defaults to the same as the `align` option.
  22173. *
  22174. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22175. * Vertical text in center position but text-aligned left
  22176. *
  22177. * @type {Highcharts.AlignValue}
  22178. * @since 2.1
  22179. * @apioption xAxis.plotBands.label.textAlign
  22180. */
  22181. /**
  22182. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22183. * to render the labels.
  22184. *
  22185. * @type {boolean}
  22186. * @default false
  22187. * @since 3.0.3
  22188. * @apioption xAxis.plotBands.label.useHTML
  22189. */
  22190. /**
  22191. * Vertical alignment of the label relative to the plot band. Can be one of
  22192. * "top", "middle" or "bottom".
  22193. *
  22194. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  22195. * Vertically centered label
  22196. * @sample {highstock} stock/xaxis/plotbands-label/
  22197. * Plot band with labels
  22198. *
  22199. * @type {Highcharts.VerticalAlignValue}
  22200. * @default top
  22201. * @since 2.1
  22202. * @apioption xAxis.plotBands.label.verticalAlign
  22203. */
  22204. /**
  22205. * Horizontal position relative the alignment. Default varies by
  22206. * orientation.
  22207. *
  22208. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22209. * Aligned 10px from the right edge
  22210. * @sample {highstock} stock/xaxis/plotbands-label/
  22211. * Plot band with labels
  22212. *
  22213. * @type {number}
  22214. * @since 2.1
  22215. * @apioption xAxis.plotBands.label.x
  22216. */
  22217. /**
  22218. * Vertical position of the text baseline relative to the alignment. Default
  22219. * varies by orientation.
  22220. *
  22221. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  22222. * Label on x axis
  22223. * @sample {highstock} stock/xaxis/plotbands-label/
  22224. * Plot band with labels
  22225. *
  22226. * @type {number}
  22227. * @since 2.1
  22228. * @apioption xAxis.plotBands.label.y
  22229. */
  22230. /**
  22231. * An array of lines stretching across the plot area, marking a specific
  22232. * value on one of the axes.
  22233. *
  22234. * In styled mode, the plot lines are styled by the
  22235. * `.highcharts-plot-line` class in addition to the `className` option.
  22236. *
  22237. * @type {Array<*>}
  22238. * @product highcharts highstock gantt
  22239. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22240. * Basic plot line
  22241. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  22242. * Solid gauge plot line
  22243. * @apioption xAxis.plotLines
  22244. */
  22245. /**
  22246. * Flag to decide if plotLine should be rendered across all panes.
  22247. *
  22248. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  22249. * Plot lines on different panes
  22250. *
  22251. * @since 7.1.2
  22252. * @product highstock
  22253. * @type {boolean}
  22254. * @default true
  22255. * @apioption xAxis.plotLines.acrossPanes
  22256. */
  22257. /**
  22258. * A custom class name, in addition to the default `highcharts-plot-line`,
  22259. * to apply to each individual line.
  22260. *
  22261. * @type {string}
  22262. * @since 5.0.0
  22263. * @apioption xAxis.plotLines.className
  22264. */
  22265. /**
  22266. * The color of the line.
  22267. *
  22268. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22269. * A red line from X axis
  22270. * @sample {highstock} stock/xaxis/plotlines/
  22271. * Plot line on Y axis
  22272. *
  22273. * @type {Highcharts.ColorString}
  22274. * @default ${palette.neutralColor40}
  22275. * @apioption xAxis.plotLines.color
  22276. */
  22277. /**
  22278. * The dashing or dot style for the plot line. For possible values see
  22279. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  22280. *
  22281. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  22282. * Dash and dot pattern
  22283. * @sample {highstock} stock/xaxis/plotlines/
  22284. * Plot line on Y axis
  22285. *
  22286. * @type {Highcharts.DashStyleValue}
  22287. * @default Solid
  22288. * @since 1.2
  22289. * @apioption xAxis.plotLines.dashStyle
  22290. */
  22291. /**
  22292. * An object defining mouse events for the plot line. Supported
  22293. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  22294. *
  22295. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  22296. * Mouse events demonstrated
  22297. *
  22298. * @since 1.2
  22299. * @apioption xAxis.plotLines.events
  22300. */
  22301. /**
  22302. * Click event on a plot band.
  22303. *
  22304. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22305. * @apioption xAxis.plotLines.events.click
  22306. */
  22307. /**
  22308. * Mouse move event on a plot band.
  22309. *
  22310. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22311. * @apioption xAxis.plotLines.events.mousemove
  22312. */
  22313. /**
  22314. * Mouse out event on the corner of a plot band.
  22315. *
  22316. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22317. * @apioption xAxis.plotLines.events.mouseout
  22318. */
  22319. /**
  22320. * Mouse over event on a plot band.
  22321. *
  22322. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22323. * @apioption xAxis.plotLines.events.mouseover
  22324. */
  22325. /**
  22326. * An id used for identifying the plot line in Axis.removePlotLine.
  22327. *
  22328. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  22329. * Remove plot line by id
  22330. *
  22331. * @type {string}
  22332. * @apioption xAxis.plotLines.id
  22333. */
  22334. /**
  22335. * The position of the line in axis units.
  22336. *
  22337. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22338. * Between two categories on X axis
  22339. * @sample {highstock} stock/xaxis/plotlines/
  22340. * Plot line on Y axis
  22341. *
  22342. * @type {number}
  22343. * @apioption xAxis.plotLines.value
  22344. */
  22345. /**
  22346. * The width or thickness of the plot line.
  22347. *
  22348. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22349. * 2px wide line from X axis
  22350. * @sample {highstock} stock/xaxis/plotlines/
  22351. * Plot line on Y axis
  22352. *
  22353. * @type {number}
  22354. * @default 2
  22355. * @apioption xAxis.plotLines.width
  22356. */
  22357. /**
  22358. * The z index of the plot line within the chart.
  22359. *
  22360. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  22361. * Behind plot lines by default
  22362. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  22363. * Above plot lines
  22364. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  22365. * Above plot lines and series
  22366. *
  22367. * @type {number}
  22368. * @since 1.2
  22369. * @apioption xAxis.plotLines.zIndex
  22370. */
  22371. /**
  22372. * Text labels for the plot bands
  22373. *
  22374. * @apioption xAxis.plotLines.label
  22375. */
  22376. /**
  22377. * Horizontal alignment of the label. Can be one of "left", "center" or
  22378. * "right".
  22379. *
  22380. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22381. * Aligned to the right
  22382. * @sample {highstock} stock/xaxis/plotlines/
  22383. * Plot line on Y axis
  22384. *
  22385. * @type {Highcharts.AlignValue}
  22386. * @default left
  22387. * @since 2.1
  22388. * @apioption xAxis.plotLines.label.align
  22389. */
  22390. /**
  22391. * Callback JavaScript function to format the label. Useful properties like
  22392. * the value of plot line or the range of plot band (`from` & `to`
  22393. * properties) can be found in `this.options` object.
  22394. *
  22395. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  22396. * Label formatters for plot line and plot band.
  22397. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  22398. * @apioption xAxis.plotLines.label.formatter
  22399. */
  22400. /**
  22401. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  22402. * lines and 90 for vertical lines.
  22403. *
  22404. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22405. * Slanted text
  22406. *
  22407. * @type {number}
  22408. * @since 2.1
  22409. * @apioption xAxis.plotLines.label.rotation
  22410. */
  22411. /**
  22412. * CSS styles for the text label.
  22413. *
  22414. * In styled mode, the labels are styled by the
  22415. * `.highcharts-plot-line-label` class.
  22416. *
  22417. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  22418. * Blue and bold label
  22419. *
  22420. * @type {Highcharts.CSSObject}
  22421. * @since 2.1
  22422. * @apioption xAxis.plotLines.label.style
  22423. */
  22424. /**
  22425. * The text itself. A subset of HTML is supported.
  22426. *
  22427. * @type {string}
  22428. * @since 2.1
  22429. * @apioption xAxis.plotLines.label.text
  22430. */
  22431. /**
  22432. * The text alignment for the label. While `align` determines where the
  22433. * texts anchor point is placed within the plot band, `textAlign` determines
  22434. * how the text is aligned against its anchor point. Possible values are
  22435. * "left", "center" and "right". Defaults to the same as the `align` option.
  22436. *
  22437. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  22438. * Text label in bottom position
  22439. *
  22440. * @type {Highcharts.AlignValue}
  22441. * @since 2.1
  22442. * @apioption xAxis.plotLines.label.textAlign
  22443. */
  22444. /**
  22445. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22446. * to render the labels.
  22447. *
  22448. * @type {boolean}
  22449. * @default false
  22450. * @since 3.0.3
  22451. * @apioption xAxis.plotLines.label.useHTML
  22452. */
  22453. /**
  22454. * Vertical alignment of the label relative to the plot line. Can be
  22455. * one of "top", "middle" or "bottom".
  22456. *
  22457. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22458. * Vertically centered label
  22459. *
  22460. * @type {Highcharts.VerticalAlignValue}
  22461. * @default {highcharts} top
  22462. * @default {highstock} top
  22463. * @since 2.1
  22464. * @apioption xAxis.plotLines.label.verticalAlign
  22465. */
  22466. /**
  22467. * Horizontal position relative the alignment. Default varies by
  22468. * orientation.
  22469. *
  22470. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22471. * Aligned 10px from the right edge
  22472. * @sample {highstock} stock/xaxis/plotlines/
  22473. * Plot line on Y axis
  22474. *
  22475. * @type {number}
  22476. * @since 2.1
  22477. * @apioption xAxis.plotLines.label.x
  22478. */
  22479. /**
  22480. * Vertical position of the text baseline relative to the alignment. Default
  22481. * varies by orientation.
  22482. *
  22483. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  22484. * Label below the plot line
  22485. * @sample {highstock} stock/xaxis/plotlines/
  22486. * Plot line on Y axis
  22487. *
  22488. * @type {number}
  22489. * @since 2.1
  22490. * @apioption xAxis.plotLines.label.y
  22491. */
  22492. /**
  22493. *
  22494. * @type {Array<*>}
  22495. * @extends xAxis.plotBands
  22496. * @apioption yAxis.plotBands
  22497. */
  22498. /**
  22499. * In a gauge chart, this option determines the inner radius of the
  22500. * plot band that stretches along the perimeter. It can be given as
  22501. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22502. * By default, the inner radius is controlled by the [thickness](
  22503. * #yAxis.plotBands.thickness) option.
  22504. *
  22505. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22506. * Gauge plot band
  22507. *
  22508. * @type {number|string}
  22509. * @since 2.3
  22510. * @product highcharts
  22511. * @apioption yAxis.plotBands.innerRadius
  22512. */
  22513. /**
  22514. * In a gauge chart, this option determines the outer radius of the
  22515. * plot band that stretches along the perimeter. It can be given as
  22516. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22517. *
  22518. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22519. * Gauge plot band
  22520. *
  22521. * @type {number|string}
  22522. * @default 100%
  22523. * @since 2.3
  22524. * @product highcharts
  22525. * @apioption yAxis.plotBands.outerRadius
  22526. */
  22527. /**
  22528. * In a gauge chart, this option sets the width of the plot band
  22529. * stretching along the perimeter. It can be given as a percentage
  22530. * string, like `"10%"`, or as a pixel number, like `10`. The default
  22531. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  22532. * thus making the plot band act as a background for the tick markers.
  22533. *
  22534. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22535. * Gauge plot band
  22536. *
  22537. * @type {number|string}
  22538. * @default 10
  22539. * @since 2.3
  22540. * @product highcharts
  22541. * @apioption yAxis.plotBands.thickness
  22542. */
  22543. /**
  22544. * @type {Array<*>}
  22545. * @extends xAxis.plotLines
  22546. * @apioption yAxis.plotLines
  22547. */
  22548. /* eslint-disable no-invalid-this, valid-jsdoc */
  22549. /**
  22550. * Internal function to create the SVG path definition for a plot band.
  22551. *
  22552. * @function Highcharts.Axis#getPlotBandPath
  22553. *
  22554. * @param {number} from
  22555. * The axis value to start from.
  22556. *
  22557. * @param {number} to
  22558. * The axis value to end on.
  22559. *
  22560. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22561. * The plotBand or plotLine configuration object.
  22562. *
  22563. * @return {Highcharts.SVGPathArray}
  22564. * The SVG path definition in array form.
  22565. */
  22566. getPlotBandPath: function (from, to, options) {
  22567. if (options === void 0) { options = this.options; }
  22568. var toPath = this.getPlotLinePath({
  22569. value: to,
  22570. force: true,
  22571. acrossPanes: options.acrossPanes
  22572. }),
  22573. path = this.getPlotLinePath({
  22574. value: from,
  22575. force: true,
  22576. acrossPanes: options.acrossPanes
  22577. }),
  22578. result = [],
  22579. i,
  22580. // #4964 check if chart is inverted or plotband is on yAxis
  22581. horiz = this.horiz,
  22582. plus = 1,
  22583. isFlat,
  22584. outside = !isNumber(this.min) ||
  22585. !isNumber(this.max) ||
  22586. (from < this.min && to < this.min) ||
  22587. (from > this.max && to > this.max);
  22588. if (path && toPath) {
  22589. // Flat paths don't need labels (#3836)
  22590. if (outside) {
  22591. isFlat = path.toString() === toPath.toString();
  22592. plus = 0;
  22593. }
  22594. // Go over each subpath - for panes in Highcharts Stock
  22595. for (i = 0; i < path.length; i += 2) {
  22596. var pathStart = path[i],
  22597. pathEnd = path[i + 1],
  22598. toPathStart = toPath[i],
  22599. toPathEnd = toPath[i + 1];
  22600. // Type checking all affected path segments. Consider something
  22601. // smarter.
  22602. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  22603. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  22604. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  22605. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  22606. // Add 1 pixel when coordinates are the same
  22607. if (horiz && toPathStart[1] === pathStart[1]) {
  22608. toPathStart[1] += plus;
  22609. toPathEnd[1] += plus;
  22610. }
  22611. else if (!horiz && toPathStart[2] === pathStart[2]) {
  22612. toPathStart[2] += plus;
  22613. toPathEnd[2] += plus;
  22614. }
  22615. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  22616. }
  22617. result.isFlat = isFlat;
  22618. }
  22619. }
  22620. else { // outside the axis area
  22621. path = null;
  22622. }
  22623. return result;
  22624. },
  22625. /**
  22626. * Add a plot band after render time.
  22627. *
  22628. * @sample highcharts/members/axis-addplotband/
  22629. * Toggle the plot band from a button
  22630. *
  22631. * @function Highcharts.Axis#addPlotBand
  22632. *
  22633. * @param {Highcharts.AxisPlotBandsOptions} options
  22634. * A configuration object for the plot band, as defined in
  22635. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  22636. *
  22637. * @return {Highcharts.PlotLineOrBand|undefined}
  22638. * The added plot band.
  22639. */
  22640. addPlotBand: function (options) {
  22641. return this.addPlotBandOrLine(options, 'plotBands');
  22642. },
  22643. /**
  22644. * Add a plot line after render time.
  22645. *
  22646. * @sample highcharts/members/axis-addplotline/
  22647. * Toggle the plot line from a button
  22648. *
  22649. * @function Highcharts.Axis#addPlotLine
  22650. *
  22651. * @param {Highcharts.AxisPlotLinesOptions} options
  22652. * A configuration object for the plot line, as defined in
  22653. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  22654. *
  22655. * @return {Highcharts.PlotLineOrBand|undefined}
  22656. * The added plot line.
  22657. */
  22658. addPlotLine: function (options) {
  22659. return this.addPlotBandOrLine(options, 'plotLines');
  22660. },
  22661. /**
  22662. * Add a plot band or plot line after render time. Called from addPlotBand
  22663. * and addPlotLine internally.
  22664. *
  22665. * @private
  22666. * @function Highcharts.Axis#addPlotBandOrLine
  22667. *
  22668. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22669. * The plotBand or plotLine configuration object.
  22670. *
  22671. * @param {"plotBands"|"plotLines"} [coll]
  22672. *
  22673. * @return {Highcharts.PlotLineOrBand|undefined}
  22674. */
  22675. addPlotBandOrLine: function (options, coll) {
  22676. var _this = this;
  22677. var obj = new H.PlotLineOrBand(this,
  22678. options),
  22679. userOptions = this.userOptions;
  22680. if (this.visible) {
  22681. obj = obj.render();
  22682. }
  22683. if (obj) { // #2189
  22684. if (!this._addedPlotLB) {
  22685. this._addedPlotLB = true;
  22686. (userOptions.plotLines || [])
  22687. .concat(userOptions.plotBands || [])
  22688. .forEach(function (plotLineOptions) {
  22689. _this.addPlotBandOrLine(plotLineOptions);
  22690. });
  22691. }
  22692. // Add it to the user options for exporting and Axis.update
  22693. if (coll) {
  22694. // Workaround Microsoft/TypeScript issue #32693
  22695. var updatedOptions = (userOptions[coll] || []);
  22696. updatedOptions.push(options);
  22697. userOptions[coll] = updatedOptions;
  22698. }
  22699. this.plotLinesAndBands.push(obj);
  22700. }
  22701. return obj;
  22702. },
  22703. /**
  22704. * Remove a plot band or plot line from the chart by id. Called internally
  22705. * from `removePlotBand` and `removePlotLine`.
  22706. *
  22707. * @private
  22708. * @function Highcharts.Axis#removePlotBandOrLine
  22709. * @param {string} id
  22710. * @return {void}
  22711. */
  22712. removePlotBandOrLine: function (id) {
  22713. var plotLinesAndBands = this.plotLinesAndBands,
  22714. options = this.options,
  22715. userOptions = this.userOptions,
  22716. i = plotLinesAndBands.length;
  22717. while (i--) {
  22718. if (plotLinesAndBands[i].id === id) {
  22719. plotLinesAndBands[i].destroy();
  22720. }
  22721. }
  22722. ([
  22723. options.plotLines || [],
  22724. userOptions.plotLines || [],
  22725. options.plotBands || [],
  22726. userOptions.plotBands || []
  22727. ]).forEach(function (arr) {
  22728. i = arr.length;
  22729. while (i--) {
  22730. if ((arr[i] || {}).id === id) {
  22731. erase(arr, arr[i]);
  22732. }
  22733. }
  22734. });
  22735. },
  22736. /**
  22737. * Remove a plot band by its id.
  22738. *
  22739. * @sample highcharts/members/axis-removeplotband/
  22740. * Remove plot band by id
  22741. * @sample highcharts/members/axis-addplotband/
  22742. * Toggle the plot band from a button
  22743. *
  22744. * @function Highcharts.Axis#removePlotBand
  22745. *
  22746. * @param {string} id
  22747. * The plot band's `id` as given in the original configuration
  22748. * object or in the `addPlotBand` option.
  22749. *
  22750. * @return {void}
  22751. */
  22752. removePlotBand: function (id) {
  22753. this.removePlotBandOrLine(id);
  22754. },
  22755. /**
  22756. * Remove a plot line by its id.
  22757. *
  22758. * @sample highcharts/xaxis/plotlines-id/
  22759. * Remove plot line by id
  22760. * @sample highcharts/members/axis-addplotline/
  22761. * Toggle the plot line from a button
  22762. *
  22763. * @function Highcharts.Axis#removePlotLine
  22764. *
  22765. * @param {string} id
  22766. * The plot line's `id` as given in the original configuration
  22767. * object or in the `addPlotLine` option.
  22768. */
  22769. removePlotLine: function (id) {
  22770. this.removePlotBandOrLine(id);
  22771. }
  22772. });
  22773. H.PlotLineOrBand = PlotLineOrBand;
  22774. return H.PlotLineOrBand;
  22775. });
  22776. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (F, H, palette, U) {
  22777. /* *
  22778. *
  22779. * (c) 2010-2021 Torstein Honsi
  22780. *
  22781. * License: www.highcharts.com/license
  22782. *
  22783. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22784. *
  22785. * */
  22786. var format = F.format;
  22787. var doc = H.doc;
  22788. var clamp = U.clamp,
  22789. css = U.css,
  22790. defined = U.defined,
  22791. discardElement = U.discardElement,
  22792. extend = U.extend,
  22793. fireEvent = U.fireEvent,
  22794. isArray = U.isArray,
  22795. isNumber = U.isNumber,
  22796. isString = U.isString,
  22797. merge = U.merge,
  22798. pick = U.pick,
  22799. splat = U.splat,
  22800. syncTimeout = U.syncTimeout,
  22801. timeUnits = U.timeUnits;
  22802. /**
  22803. * Callback function to format the text of the tooltip from scratch.
  22804. *
  22805. * In case of single or shared tooltips, a string should be be returned. In case
  22806. * of splitted tooltips, it should return an array where the first item is the
  22807. * header, and subsequent items are mapped to the points. Return `false` to
  22808. * disable tooltip for a specific point on series.
  22809. *
  22810. * @callback Highcharts.TooltipFormatterCallbackFunction
  22811. *
  22812. * @param {Highcharts.TooltipFormatterContextObject} this
  22813. * Context to format
  22814. *
  22815. * @param {Highcharts.Tooltip} tooltip
  22816. * The tooltip instance
  22817. *
  22818. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  22819. * Formatted text or false
  22820. */
  22821. /**
  22822. * @interface Highcharts.TooltipFormatterContextObject
  22823. */ /**
  22824. * @name Highcharts.TooltipFormatterContextObject#color
  22825. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22826. */ /**
  22827. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  22828. * @type {number|undefined}
  22829. */ /**
  22830. * @name Highcharts.TooltipFormatterContextObject#key
  22831. * @type {number}
  22832. */ /**
  22833. * @name Highcharts.TooltipFormatterContextObject#percentage
  22834. * @type {number|undefined}
  22835. */ /**
  22836. * @name Highcharts.TooltipFormatterContextObject#point
  22837. * @type {Highcharts.Point}
  22838. */ /**
  22839. * @name Highcharts.TooltipFormatterContextObject#points
  22840. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  22841. */ /**
  22842. * @name Highcharts.TooltipFormatterContextObject#series
  22843. * @type {Highcharts.Series}
  22844. */ /**
  22845. * @name Highcharts.TooltipFormatterContextObject#total
  22846. * @type {number|undefined}
  22847. */ /**
  22848. * @name Highcharts.TooltipFormatterContextObject#x
  22849. * @type {number}
  22850. */ /**
  22851. * @name Highcharts.TooltipFormatterContextObject#y
  22852. * @type {number}
  22853. */
  22854. /**
  22855. * A callback function to place the tooltip in a specific position.
  22856. *
  22857. * @callback Highcharts.TooltipPositionerCallbackFunction
  22858. *
  22859. * @param {Highcharts.Tooltip} this
  22860. * Tooltip context of the callback.
  22861. *
  22862. * @param {number} labelWidth
  22863. * Width of the tooltip.
  22864. *
  22865. * @param {number} labelHeight
  22866. * Height of the tooltip.
  22867. *
  22868. * @param {Highcharts.TooltipPositionerPointObject} point
  22869. * Point information for positioning a tooltip.
  22870. *
  22871. * @return {Highcharts.PositionObject}
  22872. * New position for the tooltip.
  22873. */
  22874. /**
  22875. * Point information for positioning a tooltip.
  22876. *
  22877. * @interface Highcharts.TooltipPositionerPointObject
  22878. * @extends Highcharts.Point
  22879. */ /**
  22880. * If `tooltip.split` option is enabled and positioner is called for each of the
  22881. * boxes separately, this property indicates the call on the xAxis header, which
  22882. * is not a point itself.
  22883. * @name Highcharts.TooltipPositionerPointObject#isHeader
  22884. * @type {boolean}
  22885. */ /**
  22886. * The reference point relative to the plot area. Add chart.plotLeft to get the
  22887. * full coordinates.
  22888. * @name Highcharts.TooltipPositionerPointObject#plotX
  22889. * @type {number}
  22890. */ /**
  22891. * The reference point relative to the plot area. Add chart.plotTop to get the
  22892. * full coordinates.
  22893. * @name Highcharts.TooltipPositionerPointObject#plotY
  22894. * @type {number}
  22895. */
  22896. /**
  22897. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  22898. */
  22899. ''; // separates doclets above from variables below
  22900. /* eslint-disable no-invalid-this, valid-jsdoc */
  22901. /**
  22902. * Tooltip of a chart.
  22903. *
  22904. * @class
  22905. * @name Highcharts.Tooltip
  22906. *
  22907. * @param {Highcharts.Chart} chart
  22908. * The chart instance.
  22909. *
  22910. * @param {Highcharts.TooltipOptions} options
  22911. * Tooltip options.
  22912. */
  22913. var Tooltip = /** @class */ (function () {
  22914. /* *
  22915. *
  22916. * Constructors
  22917. *
  22918. * */
  22919. function Tooltip(chart, options) {
  22920. this.container = void 0;
  22921. this.crosshairs = [];
  22922. this.distance = 0;
  22923. this.isHidden = true;
  22924. this.isSticky = false;
  22925. this.now = {};
  22926. this.options = {};
  22927. this.outside = false;
  22928. this.chart = chart;
  22929. this.init(chart, options);
  22930. }
  22931. /* *
  22932. *
  22933. * Functions
  22934. *
  22935. * */
  22936. /**
  22937. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  22938. * needs to have an id specific to the chart, otherwise there will be issues
  22939. * when one tooltip adopts the filter of a different chart, specifically one
  22940. * where the container is hidden.
  22941. *
  22942. * @private
  22943. * @function Highcharts.Tooltip#applyFilter
  22944. */
  22945. Tooltip.prototype.applyFilter = function () {
  22946. var chart = this.chart;
  22947. chart.renderer.definition({
  22948. tagName: 'filter',
  22949. attributes: {
  22950. id: 'drop-shadow-' + chart.index,
  22951. opacity: 0.5
  22952. },
  22953. children: [{
  22954. tagName: 'feGaussianBlur',
  22955. attributes: {
  22956. 'in': 'SourceAlpha',
  22957. stdDeviation: 1
  22958. }
  22959. }, {
  22960. tagName: 'feOffset',
  22961. attributes: {
  22962. dx: 1,
  22963. dy: 1
  22964. }
  22965. }, {
  22966. tagName: 'feComponentTransfer',
  22967. children: [{
  22968. tagName: 'feFuncA',
  22969. attributes: {
  22970. type: 'linear',
  22971. slope: 0.3
  22972. }
  22973. }]
  22974. }, {
  22975. tagName: 'feMerge',
  22976. children: [{
  22977. tagName: 'feMergeNode'
  22978. }, {
  22979. tagName: 'feMergeNode',
  22980. attributes: {
  22981. 'in': 'SourceGraphic'
  22982. }
  22983. }]
  22984. }]
  22985. });
  22986. chart.renderer.definition({
  22987. tagName: 'style',
  22988. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  22989. 'filter:url(#drop-shadow-' + chart.index + ')' +
  22990. '}'
  22991. });
  22992. };
  22993. /**
  22994. * Build the body (lines) of the tooltip by iterating over the items and
  22995. * returning one entry for each item, abstracting this functionality allows
  22996. * to easily overwrite and extend it.
  22997. *
  22998. * @private
  22999. * @function Highcharts.Tooltip#bodyFormatter
  23000. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  23001. * @return {Array<string>}
  23002. */
  23003. Tooltip.prototype.bodyFormatter = function (items) {
  23004. return items.map(function (item) {
  23005. var tooltipOptions = item.series.tooltipOptions;
  23006. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  23007. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  23008. });
  23009. };
  23010. /**
  23011. * Destroy the single tooltips in a split tooltip.
  23012. * If the tooltip is active then it is not destroyed, unless forced to.
  23013. *
  23014. * @private
  23015. * @function Highcharts.Tooltip#cleanSplit
  23016. *
  23017. * @param {boolean} [force]
  23018. * Force destroy all tooltips.
  23019. */
  23020. Tooltip.prototype.cleanSplit = function (force) {
  23021. this.chart.series.forEach(function (series) {
  23022. var tt = series && series.tt;
  23023. if (tt) {
  23024. if (!tt.isActive || force) {
  23025. series.tt = tt.destroy();
  23026. }
  23027. else {
  23028. tt.isActive = false;
  23029. }
  23030. }
  23031. });
  23032. };
  23033. /**
  23034. * In case no user defined formatter is given, this will be used. Note that
  23035. * the context here is an object holding point, series, x, y etc.
  23036. *
  23037. * @function Highcharts.Tooltip#defaultFormatter
  23038. *
  23039. * @param {Highcharts.Tooltip} tooltip
  23040. *
  23041. * @return {Array<string>}
  23042. */
  23043. Tooltip.prototype.defaultFormatter = function (tooltip) {
  23044. var items = this.points || splat(this),
  23045. s;
  23046. // Build the header
  23047. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  23048. // build the values
  23049. s = s.concat(tooltip.bodyFormatter(items));
  23050. // footer
  23051. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  23052. return s;
  23053. };
  23054. /**
  23055. * Removes and destroys the tooltip and its elements.
  23056. *
  23057. * @function Highcharts.Tooltip#destroy
  23058. */
  23059. Tooltip.prototype.destroy = function () {
  23060. // Destroy and clear local variables
  23061. if (this.label) {
  23062. this.label = this.label.destroy();
  23063. }
  23064. if (this.split && this.tt) {
  23065. this.cleanSplit(this.chart, true);
  23066. this.tt = this.tt.destroy();
  23067. }
  23068. if (this.renderer) {
  23069. this.renderer = this.renderer.destroy();
  23070. discardElement(this.container);
  23071. }
  23072. U.clearTimeout(this.hideTimer);
  23073. U.clearTimeout(this.tooltipTimeout);
  23074. };
  23075. /**
  23076. * Extendable method to get the anchor position of the tooltip
  23077. * from a point or set of points
  23078. *
  23079. * @private
  23080. * @function Highcharts.Tooltip#getAnchor
  23081. *
  23082. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  23083. *
  23084. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23085. *
  23086. * @return {Array<number>}
  23087. */
  23088. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  23089. var ret,
  23090. chart = this.chart,
  23091. pointer = chart.pointer,
  23092. inverted = chart.inverted,
  23093. plotTop = chart.plotTop,
  23094. plotLeft = chart.plotLeft,
  23095. plotX = 0,
  23096. plotY = 0,
  23097. yAxis,
  23098. xAxis;
  23099. points = splat(points);
  23100. // When tooltip follows mouse, relate the position to the mouse
  23101. if (this.followPointer && mouseEvent) {
  23102. if (typeof mouseEvent.chartX === 'undefined') {
  23103. mouseEvent = pointer.normalize(mouseEvent);
  23104. }
  23105. ret = [
  23106. mouseEvent.chartX - plotLeft,
  23107. mouseEvent.chartY - plotTop
  23108. ];
  23109. // Some series types use a specificly calculated tooltip position for
  23110. // each point
  23111. }
  23112. else if (points[0].tooltipPos) {
  23113. ret = points[0].tooltipPos;
  23114. // Calculate the average position and adjust for axis positions
  23115. }
  23116. else {
  23117. points.forEach(function (point) {
  23118. yAxis = point.series.yAxis;
  23119. xAxis = point.series.xAxis;
  23120. plotX += point.plotX || 0;
  23121. plotY += (point.plotLow ?
  23122. (point.plotLow + (point.plotHigh || 0)) / 2 :
  23123. (point.plotY || 0));
  23124. // Adjust position for positioned axes (top/left settings)
  23125. if (xAxis && yAxis) {
  23126. if (!inverted) { // #1151
  23127. plotX += xAxis.pos - plotLeft;
  23128. plotY += yAxis.pos - plotTop;
  23129. }
  23130. else { // #14771
  23131. plotX += plotTop + chart.plotHeight - xAxis.len - xAxis.pos;
  23132. plotY += plotLeft + chart.plotWidth - yAxis.len - yAxis.pos;
  23133. }
  23134. }
  23135. });
  23136. plotX /= points.length;
  23137. plotY /= points.length;
  23138. // Use the average position for multiple points
  23139. ret = [
  23140. inverted ? chart.plotWidth - plotY : plotX,
  23141. inverted ? chart.plotHeight - plotX : plotY
  23142. ];
  23143. // When shared, place the tooltip next to the mouse (#424)
  23144. if (this.shared && points.length > 1 && mouseEvent) {
  23145. if (inverted) {
  23146. ret[0] = mouseEvent.chartX - plotLeft;
  23147. }
  23148. else {
  23149. ret[1] = mouseEvent.chartY - plotTop;
  23150. }
  23151. }
  23152. }
  23153. return ret.map(Math.round);
  23154. };
  23155. /**
  23156. * Get the optimal date format for a point, based on a range.
  23157. *
  23158. * @private
  23159. * @function Highcharts.Tooltip#getDateFormat
  23160. *
  23161. * @param {number} range
  23162. * The time range
  23163. *
  23164. * @param {number} date
  23165. * The date of the point in question
  23166. *
  23167. * @param {number} startOfWeek
  23168. * An integer representing the first day of the week, where 0 is
  23169. * Sunday.
  23170. *
  23171. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  23172. * A map of time units to formats.
  23173. *
  23174. * @return {string}
  23175. * The optimal date format for a point.
  23176. */
  23177. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  23178. var time = this.chart.time, dateStr = time.dateFormat('%m-%d %H:%M:%S.%L', date), format, n, blank = '01-01 00:00:00.000', strpos = {
  23179. millisecond: 15,
  23180. second: 12,
  23181. minute: 9,
  23182. hour: 6,
  23183. day: 3
  23184. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  23185. for (n in timeUnits) { // eslint-disable-line guard-for-in
  23186. // If the range is exactly one week and we're looking at a
  23187. // Sunday/Monday, go for the week format
  23188. if (range === timeUnits.week &&
  23189. +time.dateFormat('%w', date) === startOfWeek &&
  23190. dateStr.substr(6) === blank.substr(6)) {
  23191. n = 'week';
  23192. break;
  23193. }
  23194. // The first format that is too great for the range
  23195. if (timeUnits[n] > range) {
  23196. n = lastN;
  23197. break;
  23198. }
  23199. // If the point is placed every day at 23:59, we need to show
  23200. // the minutes as well. #2637.
  23201. if (strpos[n] &&
  23202. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  23203. break;
  23204. }
  23205. // Weeks are outside the hierarchy, only apply them on
  23206. // Mondays/Sundays like in the first condition
  23207. if (n !== 'week') {
  23208. lastN = n;
  23209. }
  23210. }
  23211. if (n) {
  23212. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  23213. }
  23214. return format;
  23215. };
  23216. /**
  23217. * Creates the Tooltip label element if it does not exist, then returns it.
  23218. *
  23219. * @function Highcharts.Tooltip#getLabel
  23220. * @return {Highcharts.SVGElement}
  23221. */
  23222. Tooltip.prototype.getLabel = function () {
  23223. var tooltip = this,
  23224. renderer = this.chart.renderer,
  23225. styledMode = this.chart.styledMode,
  23226. options = this.options,
  23227. className = ('tooltip' + (defined(options.className) ?
  23228. ' ' + options.className :
  23229. '')),
  23230. pointerEvents = ((options.style && options.style.pointerEvents) ||
  23231. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  23232. container,
  23233. onMouseEnter = function () {
  23234. tooltip.inContact = true;
  23235. }, onMouseLeave = function () {
  23236. var series = tooltip.chart.hoverSeries;
  23237. tooltip.inContact = false;
  23238. if (series &&
  23239. series.onMouseOut) {
  23240. series.onMouseOut();
  23241. }
  23242. };
  23243. if (!this.label) {
  23244. if (this.outside) {
  23245. var chartStyle = this.chart.options.chart.style;
  23246. /**
  23247. * Reference to the tooltip's container, when
  23248. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23249. * it's undefined.
  23250. *
  23251. * @name Highcharts.Tooltip#container
  23252. * @type {Highcharts.HTMLDOMElement|undefined}
  23253. */
  23254. this.container = container = H.doc.createElement('div');
  23255. container.className = 'highcharts-tooltip-container';
  23256. css(container, {
  23257. position: 'absolute',
  23258. top: '1px',
  23259. pointerEvents: pointerEvents,
  23260. zIndex: Math.max((this.options.style && this.options.style.zIndex || 0), (chartStyle && chartStyle.zIndex || 0) + 3)
  23261. });
  23262. H.doc.body.appendChild(container);
  23263. /**
  23264. * Reference to the tooltip's renderer, when
  23265. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23266. * it's undefined.
  23267. *
  23268. * @name Highcharts.Tooltip#renderer
  23269. * @type {Highcharts.SVGRenderer|undefined}
  23270. */
  23271. this.renderer = renderer = new H.Renderer(container, 0, 0, chartStyle, void 0, void 0, renderer.styledMode);
  23272. }
  23273. // Create the label
  23274. if (this.split) {
  23275. this.label = renderer.g(className);
  23276. }
  23277. else {
  23278. this.label = renderer
  23279. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  23280. .attr({
  23281. padding: options.padding,
  23282. r: options.borderRadius
  23283. });
  23284. if (!styledMode) {
  23285. this.label
  23286. .attr({
  23287. fill: options.backgroundColor,
  23288. 'stroke-width': options.borderWidth
  23289. })
  23290. // #2301, #2657
  23291. .css(options.style)
  23292. .css({ pointerEvents: pointerEvents })
  23293. .shadow(options.shadow);
  23294. }
  23295. }
  23296. if (styledMode) {
  23297. // Apply the drop-shadow filter
  23298. this.applyFilter();
  23299. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  23300. }
  23301. // Split tooltip use updateTooltipContainer to position the tooltip
  23302. // container.
  23303. if (tooltip.outside && !tooltip.split) {
  23304. var label_1 = this.label;
  23305. var xSetter_1 = label_1.xSetter,
  23306. ySetter_1 = label_1.ySetter;
  23307. label_1.xSetter = function (value) {
  23308. xSetter_1.call(label_1, tooltip.distance);
  23309. container.style.left = value + 'px';
  23310. };
  23311. label_1.ySetter = function (value) {
  23312. ySetter_1.call(label_1, tooltip.distance);
  23313. container.style.top = value + 'px';
  23314. };
  23315. }
  23316. this.label
  23317. .on('mouseenter', onMouseEnter)
  23318. .on('mouseleave', onMouseLeave)
  23319. .attr({ zIndex: 8 })
  23320. .add();
  23321. }
  23322. return this.label;
  23323. };
  23324. /**
  23325. * Place the tooltip in a chart without spilling over
  23326. * and not covering the point it self.
  23327. *
  23328. * @private
  23329. * @function Highcharts.Tooltip#getPosition
  23330. *
  23331. * @param {number} boxWidth
  23332. *
  23333. * @param {number} boxHeight
  23334. *
  23335. * @param {Highcharts.Point} point
  23336. *
  23337. * @return {Highcharts.PositionObject}
  23338. */
  23339. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  23340. var chart = this.chart,
  23341. distance = this.distance,
  23342. ret = {},
  23343. // Don't use h if chart isn't inverted (#7242) ???
  23344. h = (chart.inverted && point.h) || 0, // #4117 ???
  23345. swapped,
  23346. outside = this.outside,
  23347. outerWidth = outside ?
  23348. // substract distance to prevent scrollbars
  23349. doc.documentElement.clientWidth - 2 * distance :
  23350. chart.chartWidth,
  23351. outerHeight = outside ?
  23352. Math.max(doc.body.scrollHeight,
  23353. doc.documentElement.scrollHeight,
  23354. doc.body.offsetHeight,
  23355. doc.documentElement.offsetHeight,
  23356. doc.documentElement.clientHeight) :
  23357. chart.chartHeight,
  23358. chartPosition = chart.pointer.getChartPosition(),
  23359. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23360. val * chartPosition.scaleX); },
  23361. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23362. val * chartPosition.scaleY); },
  23363. // Build parameter arrays for firstDimension()/secondDimension()
  23364. buildDimensionArray = function (dim) {
  23365. var isX = dim === 'x';
  23366. return [
  23367. dim,
  23368. isX ? outerWidth : outerHeight,
  23369. isX ? boxWidth : boxHeight
  23370. ].concat(outside ? [
  23371. // If we are using tooltip.outside, we need to scale the
  23372. // position to match scaling of the container in case there
  23373. // is a transform/zoom on the container. #11329
  23374. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  23375. isX ? chartPosition.left - distance +
  23376. scaleX(point.plotX + chart.plotLeft) :
  23377. chartPosition.top - distance +
  23378. scaleY(point.plotY + chart.plotTop),
  23379. 0,
  23380. isX ? outerWidth : outerHeight
  23381. ] : [
  23382. // Not outside, no scaling is needed
  23383. isX ? boxWidth : boxHeight,
  23384. isX ? point.plotX + chart.plotLeft :
  23385. point.plotY + chart.plotTop,
  23386. isX ? chart.plotLeft : chart.plotTop,
  23387. isX ? chart.plotLeft + chart.plotWidth :
  23388. chart.plotTop + chart.plotHeight
  23389. ]);
  23390. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  23391. // The far side is right or bottom
  23392. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  23393. /*
  23394. * Handle the preferred dimension. When the preferred dimension is
  23395. * tooltip on top or bottom of the point, it will look for space
  23396. * there.
  23397. *
  23398. * @private
  23399. */
  23400. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23401. point, min, max) {
  23402. var scaledDist = outside ?
  23403. (dim === 'y' ? scaleY(distance) : scaleX(distance)) :
  23404. distance,
  23405. scaleDiff = (innerSize - scaledInnerSize) / 2,
  23406. roomLeft = scaledInnerSize < point - distance,
  23407. roomRight = point + distance + scaledInnerSize < outerSize,
  23408. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  23409. alignedRight = point + scaledDist - scaleDiff;
  23410. if (preferFarSide && roomRight) {
  23411. ret[dim] = alignedRight;
  23412. }
  23413. else if (!preferFarSide && roomLeft) {
  23414. ret[dim] = alignedLeft;
  23415. }
  23416. else if (roomLeft) {
  23417. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  23418. }
  23419. else if (roomRight) {
  23420. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  23421. alignedRight :
  23422. alignedRight + h);
  23423. }
  23424. else {
  23425. return false;
  23426. }
  23427. },
  23428. /*
  23429. * Handle the secondary dimension. If the preferred dimension is
  23430. * tooltip on top or bottom of the point, the second dimension is to
  23431. * align the tooltip above the point, trying to align center but
  23432. * allowing left or right align within the chart box.
  23433. *
  23434. * @private
  23435. */
  23436. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23437. point) {
  23438. var retVal;
  23439. // Too close to the edge, return false and swap dimensions
  23440. if (point < distance || point > outerSize - distance) {
  23441. retVal = false;
  23442. // Align left/top
  23443. }
  23444. else if (point < innerSize / 2) {
  23445. ret[dim] = 1;
  23446. // Align right/bottom
  23447. }
  23448. else if (point > outerSize - scaledInnerSize / 2) {
  23449. ret[dim] = outerSize - scaledInnerSize - 2;
  23450. // Align center
  23451. }
  23452. else {
  23453. ret[dim] = point - innerSize / 2;
  23454. }
  23455. return retVal;
  23456. },
  23457. /*
  23458. * Swap the dimensions
  23459. */
  23460. swap = function (count) {
  23461. var temp = first;
  23462. first = second;
  23463. second = temp;
  23464. swapped = count;
  23465. }, run = function () {
  23466. if (firstDimension.apply(0, first) !== false) {
  23467. if (secondDimension.apply(0, second) === false &&
  23468. !swapped) {
  23469. swap(true);
  23470. run();
  23471. }
  23472. }
  23473. else if (!swapped) {
  23474. swap(true);
  23475. run();
  23476. }
  23477. else {
  23478. ret.x = ret.y = 0;
  23479. }
  23480. };
  23481. // Under these conditions, prefer the tooltip on the side of the point
  23482. if (chart.inverted || this.len > 1) {
  23483. swap();
  23484. }
  23485. run();
  23486. return ret;
  23487. };
  23488. /**
  23489. * Get the best X date format based on the closest point range on the axis.
  23490. *
  23491. * @private
  23492. * @function Highcharts.Tooltip#getXDateFormat
  23493. *
  23494. * @param {Highcharts.Point} point
  23495. *
  23496. * @param {Highcharts.TooltipOptions} options
  23497. *
  23498. * @param {Highcharts.Axis} xAxis
  23499. *
  23500. * @return {string}
  23501. */
  23502. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  23503. var xDateFormat,
  23504. dateTimeLabelFormats = options.dateTimeLabelFormats,
  23505. closestPointRange = xAxis && xAxis.closestPointRange;
  23506. if (closestPointRange) {
  23507. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  23508. }
  23509. else {
  23510. xDateFormat = dateTimeLabelFormats.day;
  23511. }
  23512. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  23513. };
  23514. /**
  23515. * Hides the tooltip with a fade out animation.
  23516. *
  23517. * @function Highcharts.Tooltip#hide
  23518. *
  23519. * @param {number} [delay]
  23520. * The fade out in milliseconds. If no value is provided the value
  23521. * of the tooltip.hideDelay option is used. A value of 0 disables
  23522. * the fade out animation.
  23523. */
  23524. Tooltip.prototype.hide = function (delay) {
  23525. var tooltip = this;
  23526. // disallow duplicate timers (#1728, #1766)
  23527. U.clearTimeout(this.hideTimer);
  23528. delay = pick(delay, this.options.hideDelay, 500);
  23529. if (!this.isHidden) {
  23530. this.hideTimer = syncTimeout(function () {
  23531. // If there is a delay, do fadeOut with the default duration. If
  23532. // the hideDelay is 0, we assume no animation is wanted, so we
  23533. // pass 0 duration. #12994.
  23534. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  23535. tooltip.isHidden = true;
  23536. }, delay);
  23537. }
  23538. };
  23539. /**
  23540. * @private
  23541. * @function Highcharts.Tooltip#init
  23542. *
  23543. * @param {Highcharts.Chart} chart
  23544. * The chart instance.
  23545. *
  23546. * @param {Highcharts.TooltipOptions} options
  23547. * Tooltip options.
  23548. */
  23549. Tooltip.prototype.init = function (chart, options) {
  23550. /**
  23551. * Chart of the tooltip.
  23552. *
  23553. * @readonly
  23554. * @name Highcharts.Tooltip#chart
  23555. * @type {Highcharts.Chart}
  23556. */
  23557. this.chart = chart;
  23558. /**
  23559. * Used tooltip options.
  23560. *
  23561. * @readonly
  23562. * @name Highcharts.Tooltip#options
  23563. * @type {Highcharts.TooltipOptions}
  23564. */
  23565. this.options = options;
  23566. /**
  23567. * List of crosshairs.
  23568. *
  23569. * @private
  23570. * @readonly
  23571. * @name Highcharts.Tooltip#crosshairs
  23572. * @type {Array<null>}
  23573. */
  23574. this.crosshairs = [];
  23575. /**
  23576. * Current values of x and y when animating.
  23577. *
  23578. * @private
  23579. * @readonly
  23580. * @name Highcharts.Tooltip#now
  23581. * @type {Highcharts.PositionObject}
  23582. */
  23583. this.now = { x: 0, y: 0 };
  23584. /**
  23585. * Tooltips are initially hidden.
  23586. *
  23587. * @private
  23588. * @readonly
  23589. * @name Highcharts.Tooltip#isHidden
  23590. * @type {boolean}
  23591. */
  23592. this.isHidden = true;
  23593. /**
  23594. * True, if the tooltip is split into one label per series, with the
  23595. * header close to the axis.
  23596. *
  23597. * @readonly
  23598. * @name Highcharts.Tooltip#split
  23599. * @type {boolean|undefined}
  23600. */
  23601. this.split = options.split && !chart.inverted && !chart.polar;
  23602. /**
  23603. * When the tooltip is shared, the entire plot area will capture mouse
  23604. * movement or touch events.
  23605. *
  23606. * @readonly
  23607. * @name Highcharts.Tooltip#shared
  23608. * @type {boolean|undefined}
  23609. */
  23610. this.shared = options.shared || this.split;
  23611. /**
  23612. * Whether to allow the tooltip to render outside the chart's SVG
  23613. * element box. By default (false), the tooltip is rendered within the
  23614. * chart's SVG element, which results in the tooltip being aligned
  23615. * inside the chart area.
  23616. *
  23617. * @readonly
  23618. * @name Highcharts.Tooltip#outside
  23619. * @type {boolean}
  23620. *
  23621. * @todo
  23622. * Split tooltip does not support outside in the first iteration. Should
  23623. * not be too complicated to implement.
  23624. */
  23625. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  23626. };
  23627. /**
  23628. * Returns true, if the pointer is in contact with the tooltip tracker.
  23629. */
  23630. Tooltip.prototype.isStickyOnContact = function () {
  23631. return !!(!this.followPointer &&
  23632. this.options.stickOnContact &&
  23633. this.inContact);
  23634. };
  23635. /**
  23636. * Moves the tooltip with a soft animation to a new position.
  23637. *
  23638. * @private
  23639. * @function Highcharts.Tooltip#move
  23640. *
  23641. * @param {number} x
  23642. *
  23643. * @param {number} y
  23644. *
  23645. * @param {number} anchorX
  23646. *
  23647. * @param {number} anchorY
  23648. */
  23649. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  23650. var tooltip = this,
  23651. now = tooltip.now,
  23652. animate = tooltip.options.animation !== false &&
  23653. !tooltip.isHidden &&
  23654. // When we get close to the target position, abort animation and
  23655. // land on the right place (#3056)
  23656. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  23657. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  23658. // Get intermediate values for animation
  23659. extend(now, {
  23660. x: animate ? (2 * now.x + x) / 3 : x,
  23661. y: animate ? (now.y + y) / 2 : y,
  23662. anchorX: skipAnchor ?
  23663. void 0 :
  23664. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  23665. anchorY: skipAnchor ?
  23666. void 0 :
  23667. animate ? (now.anchorY + anchorY) / 2 : anchorY
  23668. });
  23669. // Move to the intermediate value
  23670. tooltip.getLabel().attr(now);
  23671. tooltip.drawTracker();
  23672. // Run on next tick of the mouse tracker
  23673. if (animate) {
  23674. // Never allow two timeouts
  23675. U.clearTimeout(this.tooltipTimeout);
  23676. // Set the fixed interval ticking for the smooth tooltip
  23677. this.tooltipTimeout = setTimeout(function () {
  23678. // The interval function may still be running during destroy,
  23679. // so check that the chart is really there before calling.
  23680. if (tooltip) {
  23681. tooltip.move(x, y, anchorX, anchorY);
  23682. }
  23683. }, 32);
  23684. }
  23685. };
  23686. /**
  23687. * Refresh the tooltip's text and position.
  23688. *
  23689. * @function Highcharts.Tooltip#refresh
  23690. *
  23691. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  23692. * Either a point or an array of points.
  23693. *
  23694. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23695. * Mouse event, that is responsible for the refresh and should be
  23696. * used for the tooltip update.
  23697. */
  23698. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  23699. var tooltip = this,
  23700. chart = this.chart,
  23701. options = tooltip.options,
  23702. x,
  23703. y,
  23704. points = splat(pointOrPoints),
  23705. point = points[0],
  23706. anchor,
  23707. textConfig = {},
  23708. text,
  23709. pointConfig = [],
  23710. formatter = options.formatter || tooltip.defaultFormatter,
  23711. shared = tooltip.shared,
  23712. styledMode = chart.styledMode;
  23713. if (!options.enabled) {
  23714. return;
  23715. }
  23716. U.clearTimeout(this.hideTimer);
  23717. // get the reference point coordinates (pie charts use tooltipPos)
  23718. tooltip.followPointer = !tooltip.split && point.series.tooltipOptions.followPointer;
  23719. anchor = tooltip.getAnchor(pointOrPoints, mouseEvent);
  23720. x = anchor[0];
  23721. y = anchor[1];
  23722. // shared tooltip, array is sent over
  23723. if (shared &&
  23724. !(!isArray(pointOrPoints) &&
  23725. pointOrPoints.series &&
  23726. pointOrPoints.series.noSharedTooltip)) {
  23727. chart.pointer.applyInactiveState(points);
  23728. // Now set hover state for the choosen ones:
  23729. points.forEach(function (item) {
  23730. item.setState('hover');
  23731. pointConfig.push(item.getLabelConfig());
  23732. });
  23733. textConfig = {
  23734. x: point.category,
  23735. y: point.y
  23736. };
  23737. textConfig.points = pointConfig;
  23738. // single point tooltip
  23739. }
  23740. else {
  23741. textConfig = point.getLabelConfig();
  23742. }
  23743. this.len = pointConfig.length; // #6128
  23744. text = formatter.call(textConfig, tooltip);
  23745. // register the current series
  23746. var currentSeries = point.series;
  23747. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  23748. // update the inner HTML
  23749. if (text === false) {
  23750. this.hide();
  23751. }
  23752. else {
  23753. // update text
  23754. if (tooltip.split) {
  23755. this.renderSplit(text, points);
  23756. }
  23757. else {
  23758. var checkX = x;
  23759. var checkY = y;
  23760. if (mouseEvent && chart.pointer.isDirectTouch) {
  23761. checkX = mouseEvent.chartX - chart.plotLeft;
  23762. checkY = mouseEvent.chartY - chart.plotTop;
  23763. }
  23764. // #11493, #13095
  23765. if (chart.polar ||
  23766. currentSeries.options.clip === false ||
  23767. currentSeries.shouldShowTooltip(checkX, checkY)) {
  23768. var label = tooltip.getLabel();
  23769. // Prevent the tooltip from flowing over the chart box
  23770. // (#6659)
  23771. if (!options.style.width || styledMode) {
  23772. label.css({
  23773. width: this.chart.spacingBox.width + 'px'
  23774. });
  23775. }
  23776. label.attr({
  23777. text: text && text.join ?
  23778. text.join('') :
  23779. text
  23780. });
  23781. // Set the stroke color of the box to reflect the point
  23782. label.removeClass(/highcharts-color-[\d]+/g)
  23783. .addClass('highcharts-color-' +
  23784. pick(point.colorIndex, currentSeries.colorIndex));
  23785. if (!styledMode) {
  23786. label.attr({
  23787. stroke: (options.borderColor ||
  23788. point.color ||
  23789. currentSeries.color ||
  23790. palette.neutralColor60)
  23791. });
  23792. }
  23793. tooltip.updatePosition({
  23794. plotX: x,
  23795. plotY: y,
  23796. negative: point.negative,
  23797. ttBelow: point.ttBelow,
  23798. h: anchor[2] || 0
  23799. });
  23800. }
  23801. else {
  23802. tooltip.hide();
  23803. return;
  23804. }
  23805. }
  23806. // show it
  23807. if (tooltip.isHidden && tooltip.label) {
  23808. tooltip.label.attr({
  23809. opacity: 1
  23810. }).show();
  23811. }
  23812. tooltip.isHidden = false;
  23813. }
  23814. fireEvent(this, 'refresh');
  23815. };
  23816. /**
  23817. * Render the split tooltip. Loops over each point's text and adds
  23818. * a label next to the point, then uses the distribute function to
  23819. * find best non-overlapping positions.
  23820. *
  23821. * @private
  23822. * @function Highcharts.Tooltip#renderSplit
  23823. *
  23824. * @param {string|Array<(boolean|string)>} labels
  23825. *
  23826. * @param {Array<Highcharts.Point>} points
  23827. */
  23828. Tooltip.prototype.renderSplit = function (labels, points) {
  23829. var tooltip = this;
  23830. var chart = tooltip.chart,
  23831. _a = tooltip.chart,
  23832. chartWidth = _a.chartWidth,
  23833. chartHeight = _a.chartHeight,
  23834. plotHeight = _a.plotHeight,
  23835. plotLeft = _a.plotLeft,
  23836. plotTop = _a.plotTop,
  23837. pointer = _a.pointer,
  23838. _b = _a.scrollablePixelsY,
  23839. scrollablePixelsY = _b === void 0 ? 0 : _b,
  23840. scrollablePixelsX = _a.scrollablePixelsX,
  23841. _c = _a.scrollingContainer,
  23842. _d = _c === void 0 ? { scrollLeft: 0,
  23843. scrollTop: 0 } : _c,
  23844. scrollLeft = _d.scrollLeft,
  23845. scrollTop = _d.scrollTop,
  23846. styledMode = _a.styledMode,
  23847. distance = tooltip.distance,
  23848. options = tooltip.options,
  23849. positioner = tooltip.options.positioner;
  23850. // The area which the tooltip should be limited to. Limit to scrollable
  23851. // plot area if enabled, otherwise limit to the chart container.
  23852. // If outside is true it should be the whole viewport
  23853. var bounds = tooltip.outside && typeof scrollablePixelsX !== 'number' ?
  23854. doc.documentElement.getBoundingClientRect() : {
  23855. left: scrollLeft,
  23856. right: scrollLeft + chartWidth,
  23857. top: scrollTop,
  23858. bottom: scrollTop + chartHeight
  23859. };
  23860. var tooltipLabel = tooltip.getLabel();
  23861. var ren = this.renderer || chart.renderer;
  23862. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  23863. var _e = pointer.getChartPosition(),
  23864. chartLeft = _e.left,
  23865. chartTop = _e.top;
  23866. var distributionBoxTop = plotTop + scrollTop;
  23867. var headerHeight = 0;
  23868. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  23869. /**
  23870. * Calculates the anchor position for the partial tooltip
  23871. *
  23872. * @private
  23873. * @param {Highcharts.Point} point The point related to the tooltip
  23874. * @return {object} Returns an object with anchorX and anchorY
  23875. */
  23876. function getAnchor(point) {
  23877. var isHeader = point.isHeader,
  23878. _a = point.plotX,
  23879. plotX = _a === void 0 ? 0 : _a,
  23880. _b = point.plotY,
  23881. plotY = _b === void 0 ? 0 : _b,
  23882. series = point.series;
  23883. var anchorX;
  23884. var anchorY;
  23885. if (isHeader) {
  23886. // Set anchorX to plotX
  23887. anchorX = plotLeft + plotX;
  23888. // Set anchorY to center of visible plot area.
  23889. anchorY = plotTop + plotHeight / 2;
  23890. }
  23891. else {
  23892. var xAxis = series.xAxis,
  23893. yAxis = series.yAxis;
  23894. // Set anchorX to plotX. Limit to within xAxis.
  23895. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  23896. // Set anchorY, limit to the scrollable plot area
  23897. if (series.shouldShowTooltip(0, yAxis.pos - plotTop + plotY, {
  23898. ignoreX: true
  23899. })) {
  23900. anchorY = yAxis.pos + plotY;
  23901. }
  23902. }
  23903. // Limit values to plot area
  23904. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  23905. return { anchorX: anchorX, anchorY: anchorY };
  23906. }
  23907. /**
  23908. * Calculates the position of the partial tooltip
  23909. *
  23910. * @private
  23911. * @param {number} anchorX The partial tooltip anchor x position
  23912. * @param {number} anchorY The partial tooltip anchor y position
  23913. * @param {boolean} isHeader Whether the partial tooltip is a header
  23914. * @param {number} boxWidth Width of the partial tooltip
  23915. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  23916. * y position
  23917. */
  23918. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  23919. if (alignedLeft === void 0) { alignedLeft = true; }
  23920. var y;
  23921. var x;
  23922. if (isHeader) {
  23923. y = headerTop ? 0 : adjustedPlotHeight;
  23924. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth - (tooltip.outside ? chartLeft : 0));
  23925. }
  23926. else {
  23927. y = anchorY - distributionBoxTop;
  23928. x = alignedLeft ?
  23929. anchorX - boxWidth - distance :
  23930. anchorX + distance;
  23931. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  23932. }
  23933. // NOTE: y is relative to distributionBoxTop
  23934. return { x: x, y: y };
  23935. }
  23936. /**
  23937. * Updates the attributes and styling of the partial tooltip. Creates a
  23938. * new partial tooltip if it does not exists.
  23939. *
  23940. * @private
  23941. * @param {Highcharts.SVGElement|undefined} partialTooltip
  23942. * The partial tooltip to update
  23943. * @param {Highcharts.Point} point
  23944. * The point related to the partial tooltip
  23945. * @param {boolean|string} str The text for the partial tooltip
  23946. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  23947. */
  23948. function updatePartialTooltip(partialTooltip, point, str) {
  23949. var tt = partialTooltip;
  23950. var isHeader = point.isHeader,
  23951. series = point.series;
  23952. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  23953. if (!tt) {
  23954. var attribs = {
  23955. padding: options.padding,
  23956. r: options.borderRadius
  23957. };
  23958. if (!styledMode) {
  23959. attribs.fill = options.backgroundColor;
  23960. attribs['stroke-width'] = options.borderWidth;
  23961. }
  23962. tt = ren
  23963. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  23964. 'callout', void 0, void 0, options.useHTML)
  23965. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  23966. 'highcharts-tooltip-box ' +
  23967. colorClass)
  23968. .attr(attribs)
  23969. .add(tooltipLabel);
  23970. }
  23971. tt.isActive = true;
  23972. tt.attr({
  23973. text: str
  23974. });
  23975. if (!styledMode) {
  23976. tt.css(options.style)
  23977. .shadow(options.shadow)
  23978. .attr({
  23979. stroke: (options.borderColor ||
  23980. point.color ||
  23981. series.color ||
  23982. palette.neutralColor80)
  23983. });
  23984. }
  23985. return tt;
  23986. }
  23987. // Graceful degradation for legacy formatters
  23988. if (isString(labels)) {
  23989. labels = [false, labels];
  23990. }
  23991. // Create the individual labels for header and points, ignore footer
  23992. var boxes = labels.slice(0,
  23993. points.length + 1).reduce(function (boxes,
  23994. str,
  23995. i) {
  23996. if (str !== false && str !== '') {
  23997. var point = (points[i - 1] ||
  23998. {
  23999. // Item 0 is the header. Instead of this, we could also
  24000. // use the crosshair label
  24001. isHeader: true,
  24002. plotX: points[0].plotX,
  24003. plotY: plotHeight,
  24004. series: {}
  24005. });
  24006. var isHeader = point.isHeader;
  24007. // Store the tooltip label referance on the series
  24008. var owner = isHeader ? tooltip : point.series;
  24009. var tt = owner.tt = updatePartialTooltip(owner.tt,
  24010. point,
  24011. str.toString());
  24012. // Get X position now, so we can move all to the other side in
  24013. // case of overflow
  24014. var bBox = tt.getBBox();
  24015. var boxWidth = bBox.width + tt.strokeWidth();
  24016. if (isHeader) {
  24017. headerHeight = bBox.height;
  24018. adjustedPlotHeight += headerHeight;
  24019. if (headerTop) {
  24020. distributionBoxTop -= headerHeight;
  24021. }
  24022. }
  24023. var _a = getAnchor(point),
  24024. anchorX = _a.anchorX,
  24025. anchorY = _a.anchorY;
  24026. if (typeof anchorY === 'number') {
  24027. var size = bBox.height + 1;
  24028. var boxPosition = (positioner ?
  24029. positioner.call(tooltip,
  24030. boxWidth,
  24031. size,
  24032. point) :
  24033. defaultPositioner(anchorX,
  24034. anchorY,
  24035. isHeader,
  24036. boxWidth));
  24037. boxes.push({
  24038. // 0-align to the top, 1-align to the bottom
  24039. align: positioner ? 0 : void 0,
  24040. anchorX: anchorX,
  24041. anchorY: anchorY,
  24042. boxWidth: boxWidth,
  24043. point: point,
  24044. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  24045. size: size,
  24046. target: boxPosition.y,
  24047. tt: tt,
  24048. x: boxPosition.x
  24049. });
  24050. }
  24051. else {
  24052. // Hide tooltips which anchorY is outside the visible plot
  24053. // area
  24054. tt.isActive = false;
  24055. }
  24056. }
  24057. return boxes;
  24058. }, []);
  24059. // Realign the tooltips towards the right if there is not enough
  24060. // space to the left and there is space to to the right
  24061. if (!positioner && boxes.some(function (box) {
  24062. // Always realign if the beginning of a label is outside bounds
  24063. var outside = tooltip.outside;
  24064. var boxStart = (outside ? chartLeft : 0) + box.anchorX;
  24065. if (boxStart < bounds.left && boxStart + box.boxWidth < bounds.right) {
  24066. return true;
  24067. }
  24068. // Otherwise, check if there is more space available to the right
  24069. return boxStart < (chartLeft - bounds.left) + box.boxWidth &&
  24070. bounds.right - boxStart > boxStart;
  24071. })) {
  24072. boxes = boxes.map(function (box) {
  24073. var _a = defaultPositioner(box.anchorX,
  24074. box.anchorY,
  24075. box.point.isHeader,
  24076. box.boxWidth,
  24077. false),
  24078. x = _a.x,
  24079. y = _a.y;
  24080. return extend(box, {
  24081. target: y,
  24082. x: x
  24083. });
  24084. });
  24085. }
  24086. // Clean previous run (for missing points)
  24087. tooltip.cleanSplit();
  24088. // Distribute and put in place
  24089. H.distribute(boxes, adjustedPlotHeight);
  24090. var boxExtremes = {
  24091. left: chartLeft,
  24092. right: chartLeft
  24093. };
  24094. // Get the extremes from series tooltips
  24095. boxes.forEach(function (box) {
  24096. var x = box.x,
  24097. boxWidth = box.boxWidth,
  24098. isHeader = box.isHeader;
  24099. if (!isHeader) {
  24100. if (tooltip.outside && chartLeft + x < boxExtremes.left) {
  24101. boxExtremes.left = chartLeft + x;
  24102. }
  24103. if (!isHeader && tooltip.outside && boxExtremes.left + boxWidth > boxExtremes.right) {
  24104. boxExtremes.right = chartLeft + x;
  24105. }
  24106. }
  24107. });
  24108. boxes.forEach(function (box) {
  24109. var x = box.x,
  24110. anchorX = box.anchorX,
  24111. anchorY = box.anchorY,
  24112. pos = box.pos,
  24113. isHeader = box.point.isHeader;
  24114. var attributes = {
  24115. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  24116. x: x,
  24117. /* NOTE: y should equal pos to be consistent with !split
  24118. * tooltip,
  24119. but is currently relative to plotTop. Is left as is
  24120. * to avoid breaking change. Remove distributionBoxTop to make
  24121. * it consistent.
  24122. */
  24123. y: pos + distributionBoxTop,
  24124. anchorX: anchorX,
  24125. anchorY: anchorY
  24126. };
  24127. // Handle left-aligned tooltips overflowing the chart area
  24128. if (tooltip.outside && x < anchorX) {
  24129. var offset = chartLeft - boxExtremes.left;
  24130. // Skip this if there is no overflow
  24131. if (offset > 0) {
  24132. if (!isHeader) {
  24133. attributes.x = x + offset;
  24134. attributes.anchorX = anchorX + offset;
  24135. }
  24136. if (isHeader) {
  24137. attributes.x = (boxExtremes.right - boxExtremes.left) / 2;
  24138. attributes.anchorX = anchorX + offset;
  24139. }
  24140. }
  24141. }
  24142. // Put the label in place
  24143. box.tt.attr(attributes);
  24144. });
  24145. /* If we have a seperate tooltip container, then update the necessary
  24146. * container properties.
  24147. * Test that tooltip has its own container and renderer before executing
  24148. * the operation.
  24149. */
  24150. var container = tooltip.container,
  24151. outside = tooltip.outside,
  24152. renderer = tooltip.renderer;
  24153. if (outside && container && renderer) {
  24154. // Set container size to fit the bounds
  24155. var _f = tooltipLabel.getBBox(),
  24156. width = _f.width,
  24157. height = _f.height,
  24158. x = _f.x,
  24159. y = _f.y;
  24160. renderer.setSize(width + x, height + y, false);
  24161. // Position the tooltip container to the chart container
  24162. container.style.left = boxExtremes.left + 'px';
  24163. container.style.top = chartTop + 'px';
  24164. }
  24165. };
  24166. /**
  24167. * If the `stickOnContact` option is active, this will add a tracker shape.
  24168. *
  24169. * @private
  24170. * @function Highcharts.Tooltip#drawTracker
  24171. */
  24172. Tooltip.prototype.drawTracker = function () {
  24173. var tooltip = this;
  24174. if (tooltip.followPointer ||
  24175. !tooltip.options.stickOnContact) {
  24176. if (tooltip.tracker) {
  24177. tooltip.tracker.destroy();
  24178. }
  24179. return;
  24180. }
  24181. var chart = tooltip.chart;
  24182. var label = tooltip.label;
  24183. var point = chart.hoverPoint;
  24184. if (!label || !point) {
  24185. return;
  24186. }
  24187. var box = {
  24188. x: 0,
  24189. y: 0,
  24190. width: 0,
  24191. height: 0
  24192. };
  24193. // Combine anchor and tooltip
  24194. var anchorPos = this.getAnchor(point);
  24195. var labelBBox = label.getBBox();
  24196. anchorPos[0] += chart.plotLeft - label.translateX;
  24197. anchorPos[1] += chart.plotTop - label.translateY;
  24198. // When the mouse pointer is between the anchor point and the label,
  24199. // the label should stick.
  24200. box.x = Math.min(0, anchorPos[0]);
  24201. box.y = Math.min(0, anchorPos[1]);
  24202. box.width = (anchorPos[0] < 0 ?
  24203. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  24204. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  24205. box.height = (anchorPos[1] < 0 ?
  24206. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  24207. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  24208. if (tooltip.tracker) {
  24209. tooltip.tracker.attr(box);
  24210. }
  24211. else {
  24212. tooltip.tracker = label.renderer
  24213. .rect(box)
  24214. .addClass('highcharts-tracker')
  24215. .add(label);
  24216. if (!chart.styledMode) {
  24217. tooltip.tracker.attr({
  24218. fill: 'rgba(0,0,0,0)'
  24219. });
  24220. }
  24221. }
  24222. };
  24223. /**
  24224. * @private
  24225. */
  24226. Tooltip.prototype.styledModeFormat = function (formatString) {
  24227. return formatString
  24228. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  24229. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  24230. };
  24231. /**
  24232. * Format the footer/header of the tooltip
  24233. * #3397: abstraction to enable formatting of footer and header
  24234. *
  24235. * @private
  24236. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  24237. * @param {Highcharts.PointLabelObject} labelConfig
  24238. * @param {boolean} [isFooter]
  24239. * @return {string}
  24240. */
  24241. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  24242. var footOrHead = isFooter ? 'footer' : 'header',
  24243. series = labelConfig.series,
  24244. tooltipOptions = series.tooltipOptions,
  24245. xDateFormat = tooltipOptions.xDateFormat,
  24246. xAxis = series.xAxis,
  24247. isDateTime = (xAxis &&
  24248. xAxis.options.type === 'datetime' &&
  24249. isNumber(labelConfig.key)),
  24250. formatString = tooltipOptions[footOrHead + 'Format'],
  24251. e = {
  24252. isFooter: isFooter,
  24253. labelConfig: labelConfig
  24254. };
  24255. fireEvent(this, 'headerFormatter', e, function (e) {
  24256. // Guess the best date format based on the closest point distance
  24257. // (#568, #3418)
  24258. if (isDateTime && !xDateFormat) {
  24259. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  24260. }
  24261. // Insert the footer date format if any
  24262. if (isDateTime && xDateFormat) {
  24263. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  24264. ['key']).forEach(function (key) {
  24265. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  24266. });
  24267. }
  24268. // Replace default header style with class name
  24269. if (series.chart.styledMode) {
  24270. formatString = this.styledModeFormat(formatString);
  24271. }
  24272. e.text = format(formatString, {
  24273. point: labelConfig,
  24274. series: series
  24275. }, this.chart);
  24276. });
  24277. return e.text;
  24278. };
  24279. /**
  24280. * Updates the tooltip with the provided tooltip options.
  24281. *
  24282. * @function Highcharts.Tooltip#update
  24283. *
  24284. * @param {Highcharts.TooltipOptions} options
  24285. * The tooltip options to update.
  24286. */
  24287. Tooltip.prototype.update = function (options) {
  24288. this.destroy();
  24289. // Update user options (#6218)
  24290. merge(true, this.chart.options.tooltip.userOptions, options);
  24291. this.init(this.chart, merge(true, this.options, options));
  24292. };
  24293. /**
  24294. * Find the new position and perform the move
  24295. *
  24296. * @private
  24297. * @function Highcharts.Tooltip#updatePosition
  24298. *
  24299. * @param {Highcharts.Point} point
  24300. */
  24301. Tooltip.prototype.updatePosition = function (point) {
  24302. var chart = this.chart,
  24303. pointer = chart.pointer,
  24304. label = this.getLabel(),
  24305. pos,
  24306. anchorX = point.plotX + chart.plotLeft,
  24307. anchorY = point.plotY + chart.plotTop,
  24308. pad;
  24309. // Needed for outside: true (#11688)
  24310. var chartPosition = pointer.getChartPosition();
  24311. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  24312. // Set the renderer size dynamically to prevent document size to change
  24313. if (this.outside) {
  24314. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  24315. this.renderer.setSize(label.width + pad, label.height + pad, false);
  24316. // Anchor and tooltip container need scaling if chart container has
  24317. // scale transform/css zoom. #11329.
  24318. if (chartPosition.scaleX !== 1 || chartPosition.scaleY !== 1) {
  24319. css(this.container, {
  24320. transform: "scale(" + chartPosition.scaleX + ", " + chartPosition.scaleY + ")"
  24321. });
  24322. anchorX *= chartPosition.scaleX;
  24323. anchorY *= chartPosition.scaleY;
  24324. }
  24325. anchorX += chartPosition.left - pos.x;
  24326. anchorY += chartPosition.top - pos.y;
  24327. }
  24328. // do the move
  24329. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  24330. anchorX, anchorY);
  24331. };
  24332. return Tooltip;
  24333. }());
  24334. H.Tooltip = Tooltip;
  24335. return H.Tooltip;
  24336. });
  24337. _registerModule(_modules, 'Core/Pointer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (Color, H, palette, Tooltip, U) {
  24338. /* *
  24339. *
  24340. * (c) 2010-2021 Torstein Honsi
  24341. *
  24342. * License: www.highcharts.com/license
  24343. *
  24344. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24345. *
  24346. * */
  24347. var color = Color.parse;
  24348. var charts = H.charts,
  24349. noop = H.noop;
  24350. var addEvent = U.addEvent,
  24351. attr = U.attr,
  24352. css = U.css,
  24353. defined = U.defined,
  24354. extend = U.extend,
  24355. find = U.find,
  24356. fireEvent = U.fireEvent,
  24357. isNumber = U.isNumber,
  24358. isObject = U.isObject,
  24359. objectEach = U.objectEach,
  24360. offset = U.offset,
  24361. pick = U.pick,
  24362. splat = U.splat;
  24363. /**
  24364. * One position in relation to an axis.
  24365. *
  24366. * @interface Highcharts.PointerAxisCoordinateObject
  24367. */ /**
  24368. * Related axis.
  24369. *
  24370. * @name Highcharts.PointerAxisCoordinateObject#axis
  24371. * @type {Highcharts.Axis}
  24372. */ /**
  24373. * Axis value.
  24374. *
  24375. * @name Highcharts.PointerAxisCoordinateObject#value
  24376. * @type {number}
  24377. */
  24378. /**
  24379. * Positions in terms of axis values.
  24380. *
  24381. * @interface Highcharts.PointerAxisCoordinatesObject
  24382. */ /**
  24383. * Positions on the x-axis.
  24384. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  24385. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24386. */ /**
  24387. * Positions on the y-axis.
  24388. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  24389. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24390. */
  24391. /**
  24392. * Pointer coordinates.
  24393. *
  24394. * @interface Highcharts.PointerCoordinatesObject
  24395. */ /**
  24396. * @name Highcharts.PointerCoordinatesObject#chartX
  24397. * @type {number}
  24398. */ /**
  24399. * @name Highcharts.PointerCoordinatesObject#chartY
  24400. * @type {number}
  24401. */
  24402. /**
  24403. * A native browser mouse or touch event, extended with position information
  24404. * relative to the {@link Chart.container}.
  24405. *
  24406. * @interface Highcharts.PointerEventObject
  24407. * @extends global.PointerEvent
  24408. */ /**
  24409. * The X coordinate of the pointer interaction relative to the chart.
  24410. *
  24411. * @name Highcharts.PointerEventObject#chartX
  24412. * @type {number}
  24413. */ /**
  24414. * The Y coordinate of the pointer interaction relative to the chart.
  24415. *
  24416. * @name Highcharts.PointerEventObject#chartY
  24417. * @type {number}
  24418. */
  24419. /**
  24420. * Axis-specific data of a selection.
  24421. *
  24422. * @interface Highcharts.SelectDataObject
  24423. */ /**
  24424. * @name Highcharts.SelectDataObject#axis
  24425. * @type {Highcharts.Axis}
  24426. */ /**
  24427. * @name Highcharts.SelectDataObject#max
  24428. * @type {number}
  24429. */ /**
  24430. * @name Highcharts.SelectDataObject#min
  24431. * @type {number}
  24432. */
  24433. /**
  24434. * Object for select events.
  24435. *
  24436. * @interface Highcharts.SelectEventObject
  24437. */ /**
  24438. * @name Highcharts.SelectEventObject#originalEvent
  24439. * @type {global.Event}
  24440. */ /**
  24441. * @name Highcharts.SelectEventObject#xAxis
  24442. * @type {Array<Highcharts.SelectDataObject>}
  24443. */ /**
  24444. * @name Highcharts.SelectEventObject#yAxis
  24445. * @type {Array<Highcharts.SelectDataObject>}
  24446. */
  24447. /**
  24448. * Chart position and scale.
  24449. *
  24450. * @interface Highcharts.ChartPositionObject
  24451. */ /**
  24452. * @name Highcharts.ChartPositionObject#left
  24453. * @type {number}
  24454. */ /**
  24455. * @name Highcharts.ChartPositionObject#scaleX
  24456. * @type {number}
  24457. */ /**
  24458. * @name Highcharts.ChartPositionObject#scaleY
  24459. * @type {number}
  24460. */ /**
  24461. * @name Highcharts.ChartPositionObject#top
  24462. * @type {number}
  24463. */
  24464. ''; // detach doclets above
  24465. /* eslint-disable no-invalid-this, valid-jsdoc */
  24466. /**
  24467. * The mouse and touch tracker object. Each {@link Chart} item has one
  24468. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  24469. * property.
  24470. *
  24471. * @class
  24472. * @name Highcharts.Pointer
  24473. *
  24474. * @param {Highcharts.Chart} chart
  24475. * The chart instance.
  24476. *
  24477. * @param {Highcharts.Options} options
  24478. * The root options object. The pointer uses options from the chart and
  24479. * tooltip structures.
  24480. */
  24481. var Pointer = /** @class */ (function () {
  24482. /* *
  24483. *
  24484. * Constructors
  24485. *
  24486. * */
  24487. function Pointer(chart, options) {
  24488. this.lastValidTouch = {};
  24489. this.pinchDown = [];
  24490. this.runChartClick = false;
  24491. this.eventsToUnbind = [];
  24492. this.chart = chart;
  24493. this.hasDragged = false;
  24494. this.options = options;
  24495. this.init(chart, options);
  24496. }
  24497. /* *
  24498. *
  24499. * Functions
  24500. *
  24501. * */
  24502. /**
  24503. * Set inactive state to all series that are not currently hovered,
  24504. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  24505. * all points within that series.
  24506. *
  24507. * @private
  24508. * @function Highcharts.Pointer#applyInactiveState
  24509. * @param {Array<Highcharts.Point>} points
  24510. * Currently hovered points
  24511. */
  24512. Pointer.prototype.applyInactiveState = function (points) {
  24513. var activeSeries = [],
  24514. series;
  24515. // Get all active series from the hovered points
  24516. (points || []).forEach(function (item) {
  24517. series = item.series;
  24518. // Include itself
  24519. activeSeries.push(series);
  24520. // Include parent series
  24521. if (series.linkedParent) {
  24522. activeSeries.push(series.linkedParent);
  24523. }
  24524. // Include all child series
  24525. if (series.linkedSeries) {
  24526. activeSeries = activeSeries.concat(series.linkedSeries);
  24527. }
  24528. // Include navigator series
  24529. if (series.navigatorSeries) {
  24530. activeSeries.push(series.navigatorSeries);
  24531. }
  24532. });
  24533. // Now loop over all series, filtering out active series
  24534. this.chart.series.forEach(function (inactiveSeries) {
  24535. if (activeSeries.indexOf(inactiveSeries) === -1) {
  24536. // Inactive series
  24537. inactiveSeries.setState('inactive', true);
  24538. }
  24539. else if (inactiveSeries.options.inactiveOtherPoints) {
  24540. // Active series, but other points should be inactivated
  24541. inactiveSeries.setAllPointsToState('inactive');
  24542. }
  24543. });
  24544. };
  24545. /**
  24546. * Destroys the Pointer object and disconnects DOM events.
  24547. *
  24548. * @function Highcharts.Pointer#destroy
  24549. */
  24550. Pointer.prototype.destroy = function () {
  24551. var pointer = this;
  24552. this.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  24553. this.eventsToUnbind = [];
  24554. if (!H.chartCount) {
  24555. if (H.unbindDocumentMouseUp) {
  24556. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  24557. }
  24558. if (H.unbindDocumentTouchEnd) {
  24559. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  24560. }
  24561. }
  24562. // memory and CPU leak
  24563. clearInterval(pointer.tooltipTimeout);
  24564. objectEach(pointer, function (_val, prop) {
  24565. pointer[prop] = void 0;
  24566. });
  24567. };
  24568. /**
  24569. * Perform a drag operation in response to a mousemove event while the mouse
  24570. * is down.
  24571. *
  24572. * @private
  24573. * @function Highcharts.Pointer#drag
  24574. */
  24575. Pointer.prototype.drag = function (e) {
  24576. var chart = this.chart,
  24577. chartOptions = chart.options.chart,
  24578. chartX = e.chartX,
  24579. chartY = e.chartY,
  24580. zoomHor = this.zoomHor,
  24581. zoomVert = this.zoomVert,
  24582. plotLeft = chart.plotLeft,
  24583. plotTop = chart.plotTop,
  24584. plotWidth = chart.plotWidth,
  24585. plotHeight = chart.plotHeight,
  24586. clickedInside,
  24587. size,
  24588. selectionMarker = this.selectionMarker,
  24589. mouseDownX = (this.mouseDownX || 0),
  24590. mouseDownY = (this.mouseDownY || 0),
  24591. panningEnabled = isObject(chartOptions.panning) ?
  24592. chartOptions.panning && chartOptions.panning.enabled :
  24593. chartOptions.panning,
  24594. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  24595. // If the device supports both touch and mouse (like IE11), and we are
  24596. // touch-dragging inside the plot area, don't handle the mouse event.
  24597. // #4339.
  24598. if (selectionMarker && selectionMarker.touch) {
  24599. return;
  24600. }
  24601. // If the mouse is outside the plot area, adjust to cooordinates
  24602. // inside to prevent the selection marker from going outside
  24603. if (chartX < plotLeft) {
  24604. chartX = plotLeft;
  24605. }
  24606. else if (chartX > plotLeft + plotWidth) {
  24607. chartX = plotLeft + plotWidth;
  24608. }
  24609. if (chartY < plotTop) {
  24610. chartY = plotTop;
  24611. }
  24612. else if (chartY > plotTop + plotHeight) {
  24613. chartY = plotTop + plotHeight;
  24614. }
  24615. // determine if the mouse has moved more than 10px
  24616. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  24617. Math.pow(mouseDownY - chartY, 2));
  24618. if (this.hasDragged > 10) {
  24619. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop, {
  24620. visiblePlotOnly: true
  24621. });
  24622. // make a selection
  24623. if (chart.hasCartesianSeries &&
  24624. (this.zoomX || this.zoomY) &&
  24625. clickedInside &&
  24626. !panKey) {
  24627. if (!selectionMarker) {
  24628. this.selectionMarker = selectionMarker =
  24629. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  24630. .attr({
  24631. 'class': 'highcharts-selection-marker',
  24632. zIndex: 7
  24633. })
  24634. .add();
  24635. if (!chart.styledMode) {
  24636. selectionMarker.attr({
  24637. fill: (chartOptions.selectionMarkerFill ||
  24638. color(palette.highlightColor80)
  24639. .setOpacity(0.25).get())
  24640. });
  24641. }
  24642. }
  24643. }
  24644. // adjust the width of the selection marker
  24645. if (selectionMarker && zoomHor) {
  24646. size = chartX - mouseDownX;
  24647. selectionMarker.attr({
  24648. width: Math.abs(size),
  24649. x: (size > 0 ? 0 : size) + mouseDownX
  24650. });
  24651. }
  24652. // adjust the height of the selection marker
  24653. if (selectionMarker && zoomVert) {
  24654. size = chartY - mouseDownY;
  24655. selectionMarker.attr({
  24656. height: Math.abs(size),
  24657. y: (size > 0 ? 0 : size) + mouseDownY
  24658. });
  24659. }
  24660. // panning
  24661. if (clickedInside &&
  24662. !selectionMarker &&
  24663. panningEnabled) {
  24664. chart.pan(e, chartOptions.panning);
  24665. }
  24666. }
  24667. };
  24668. /**
  24669. * Start a drag operation.
  24670. *
  24671. * @private
  24672. * @function Highcharts.Pointer#dragStart
  24673. */
  24674. Pointer.prototype.dragStart = function (e) {
  24675. var chart = this.chart;
  24676. // Record the start position
  24677. chart.mouseIsDown = e.type;
  24678. chart.cancelClick = false;
  24679. chart.mouseDownX = this.mouseDownX = e.chartX;
  24680. chart.mouseDownY = this.mouseDownY = e.chartY;
  24681. };
  24682. /**
  24683. * On mouse up or touch end across the entire document, drop the selection.
  24684. *
  24685. * @private
  24686. * @function Highcharts.Pointer#drop
  24687. *
  24688. * @param {global.Event} e
  24689. */
  24690. Pointer.prototype.drop = function (e) {
  24691. var pointer = this,
  24692. chart = this.chart,
  24693. hasPinched = this.hasPinched;
  24694. if (this.selectionMarker) {
  24695. var selectionData_1 = {
  24696. originalEvent: e,
  24697. xAxis: [],
  24698. yAxis: []
  24699. },
  24700. selectionBox = this.selectionMarker,
  24701. selectionLeft_1 = selectionBox.attr ?
  24702. selectionBox.attr('x') :
  24703. selectionBox.x,
  24704. selectionTop_1 = selectionBox.attr ?
  24705. selectionBox.attr('y') :
  24706. selectionBox.y,
  24707. selectionWidth_1 = selectionBox.attr ?
  24708. selectionBox.attr('width') :
  24709. selectionBox.width,
  24710. selectionHeight_1 = selectionBox.attr ?
  24711. selectionBox.attr('height') :
  24712. selectionBox.height,
  24713. runZoom_1;
  24714. // a selection has been made
  24715. if (this.hasDragged || hasPinched) {
  24716. // record each axis' min and max
  24717. chart.axes.forEach(function (axis) {
  24718. if (axis.zoomEnabled &&
  24719. defined(axis.min) &&
  24720. (hasPinched ||
  24721. pointer[{
  24722. xAxis: 'zoomX',
  24723. yAxis: 'zoomY'
  24724. }[axis.coll]]) &&
  24725. isNumber(selectionLeft_1) &&
  24726. isNumber(selectionTop_1)) { // #859, #3569
  24727. var horiz = axis.horiz,
  24728. minPixelPadding = e.type === 'touchend' ?
  24729. axis.minPixelPadding :
  24730. 0, // #1207, #3075
  24731. selectionMin = axis.toValue((horiz ? selectionLeft_1 : selectionTop_1) +
  24732. minPixelPadding),
  24733. selectionMax = axis.toValue((horiz ?
  24734. selectionLeft_1 + selectionWidth_1 :
  24735. selectionTop_1 + selectionHeight_1) - minPixelPadding);
  24736. selectionData_1[axis.coll].push({
  24737. axis: axis,
  24738. // Min/max for reversed axes
  24739. min: Math.min(selectionMin, selectionMax),
  24740. max: Math.max(selectionMin, selectionMax)
  24741. });
  24742. runZoom_1 = true;
  24743. }
  24744. });
  24745. if (runZoom_1) {
  24746. fireEvent(chart, 'selection', selectionData_1, function (args) {
  24747. chart.zoom(extend(args, hasPinched ?
  24748. { animation: false } :
  24749. null));
  24750. });
  24751. }
  24752. }
  24753. if (isNumber(chart.index)) {
  24754. this.selectionMarker = this.selectionMarker.destroy();
  24755. }
  24756. // Reset scaling preview
  24757. if (hasPinched) {
  24758. this.scaleGroups();
  24759. }
  24760. }
  24761. // Reset all. Check isNumber because it may be destroyed on mouse up
  24762. // (#877)
  24763. if (chart && isNumber(chart.index)) {
  24764. css(chart.container, { cursor: chart._cursor });
  24765. chart.cancelClick = this.hasDragged > 10; // #370
  24766. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  24767. this.pinchDown = [];
  24768. }
  24769. };
  24770. /**
  24771. * Finds the closest point to a set of coordinates, using the k-d-tree
  24772. * algorithm.
  24773. *
  24774. * @function Highcharts.Pointer#findNearestKDPoint
  24775. *
  24776. * @param {Array<Highcharts.Series>} series
  24777. * All the series to search in.
  24778. *
  24779. * @param {boolean|undefined} shared
  24780. * Whether it is a shared tooltip or not.
  24781. *
  24782. * @param {Highcharts.PointerEventObject} e
  24783. * The pointer event object, containing chart coordinates of the
  24784. * pointer.
  24785. *
  24786. * @return {Highcharts.Point|undefined}
  24787. * The point closest to given coordinates.
  24788. */
  24789. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  24790. var chart = this.chart;
  24791. var hoverPoint = chart.hoverPoint;
  24792. var tooltip = chart.tooltip;
  24793. if (hoverPoint &&
  24794. tooltip &&
  24795. tooltip.isStickyOnContact()) {
  24796. return hoverPoint;
  24797. }
  24798. var closest;
  24799. /** @private */
  24800. function sort(p1, p2) {
  24801. var isCloserX = p1.distX - p2.distX,
  24802. isCloser = p1.dist - p2.dist,
  24803. isAbove = (p2.series.group && p2.series.group.zIndex) -
  24804. (p1.series.group && p1.series.group.zIndex),
  24805. result;
  24806. // We have two points which are not in the same place on xAxis
  24807. // and shared tooltip:
  24808. if (isCloserX !== 0 && shared) { // #5721
  24809. result = isCloserX;
  24810. // Points are not exactly in the same place on x/yAxis:
  24811. }
  24812. else if (isCloser !== 0) {
  24813. result = isCloser;
  24814. // The same xAxis and yAxis position, sort by z-index:
  24815. }
  24816. else if (isAbove !== 0) {
  24817. result = isAbove;
  24818. // The same zIndex, sort by array index:
  24819. }
  24820. else {
  24821. result =
  24822. p1.series.index > p2.series.index ?
  24823. -1 :
  24824. 1;
  24825. }
  24826. return result;
  24827. }
  24828. series.forEach(function (s) {
  24829. var noSharedTooltip = s.noSharedTooltip && shared,
  24830. compareX = (!noSharedTooltip &&
  24831. s.options.findNearestPointBy.indexOf('y') < 0),
  24832. point = s.searchPoint(e,
  24833. compareX);
  24834. if ( // Check that we actually found a point on the series.
  24835. isObject(point, true) && point.series &&
  24836. // Use the new point if it is closer.
  24837. (!isObject(closest, true) ||
  24838. (sort(closest, point) > 0))) {
  24839. closest = point;
  24840. }
  24841. });
  24842. return closest;
  24843. };
  24844. /**
  24845. * @private
  24846. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  24847. * @param {Highcharts.Point} point
  24848. * @param {boolean} [inverted]
  24849. * @return {Highcharts.PointerCoordinatesObject|undefined}
  24850. */
  24851. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  24852. var series = point.series,
  24853. xAxis = series.xAxis,
  24854. yAxis = series.yAxis,
  24855. shapeArgs = point.shapeArgs;
  24856. if (xAxis && yAxis) {
  24857. var x = pick(point.clientX,
  24858. point.plotX);
  24859. var y = point.plotY || 0;
  24860. if (point.isNode &&
  24861. shapeArgs &&
  24862. isNumber(shapeArgs.x) &&
  24863. isNumber(shapeArgs.y)) {
  24864. x = shapeArgs.x;
  24865. y = shapeArgs.y;
  24866. }
  24867. return inverted ? {
  24868. chartX: yAxis.len + yAxis.pos - y,
  24869. chartY: xAxis.len + xAxis.pos - x
  24870. } : {
  24871. chartX: x + xAxis.pos,
  24872. chartY: y + yAxis.pos
  24873. };
  24874. }
  24875. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  24876. // E.g. pies do not have axes
  24877. return {
  24878. chartX: shapeArgs.x,
  24879. chartY: shapeArgs.y
  24880. };
  24881. }
  24882. };
  24883. /**
  24884. * Return the cached chartPosition if it is available on the Pointer,
  24885. * otherwise find it. Running offset is quite expensive, so it should be
  24886. * avoided when we know the chart hasn't moved.
  24887. *
  24888. * @function Highcharts.Pointer#getChartPosition
  24889. *
  24890. * @return {Highcharts.ChartPositionObject}
  24891. * The offset of the chart container within the page
  24892. */
  24893. Pointer.prototype.getChartPosition = function () {
  24894. if (this.chartPosition) {
  24895. return this.chartPosition;
  24896. }
  24897. var container = this.chart.container;
  24898. var pos = offset(container);
  24899. this.chartPosition = {
  24900. left: pos.left,
  24901. top: pos.top,
  24902. scaleX: 1,
  24903. scaleY: 1
  24904. };
  24905. var offsetWidth = container.offsetWidth;
  24906. var offsetHeight = container.offsetHeight;
  24907. // #13342 - tooltip was not visible in Chrome, when chart
  24908. // updates height.
  24909. if (offsetWidth > 2 && // #13342
  24910. offsetHeight > 2 // #13342
  24911. ) {
  24912. this.chartPosition.scaleX = pos.width / offsetWidth;
  24913. this.chartPosition.scaleY = pos.height / offsetHeight;
  24914. }
  24915. return this.chartPosition;
  24916. };
  24917. /**
  24918. * Get the click position in terms of axis values.
  24919. *
  24920. * @function Highcharts.Pointer#getCoordinates
  24921. *
  24922. * @param {Highcharts.PointerEventObject} e
  24923. * Pointer event, extended with `chartX` and `chartY` properties.
  24924. *
  24925. * @return {Highcharts.PointerAxisCoordinatesObject}
  24926. */
  24927. Pointer.prototype.getCoordinates = function (e) {
  24928. var coordinates = {
  24929. xAxis: [],
  24930. yAxis: []
  24931. };
  24932. this.chart.axes.forEach(function (axis) {
  24933. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  24934. axis: axis,
  24935. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  24936. });
  24937. });
  24938. return coordinates;
  24939. };
  24940. /**
  24941. * Calculates what is the current hovered point/points and series.
  24942. *
  24943. * @private
  24944. * @function Highcharts.Pointer#getHoverData
  24945. *
  24946. * @param {Highcharts.Point|undefined} existingHoverPoint
  24947. * The point currrently beeing hovered.
  24948. *
  24949. * @param {Highcharts.Series|undefined} existingHoverSeries
  24950. * The series currently beeing hovered.
  24951. *
  24952. * @param {Array<Highcharts.Series>} series
  24953. * All the series in the chart.
  24954. *
  24955. * @param {boolean} isDirectTouch
  24956. * Is the pointer directly hovering the point.
  24957. *
  24958. * @param {boolean|undefined} shared
  24959. * Whether it is a shared tooltip or not.
  24960. *
  24961. * @param {Highcharts.PointerEventObject} [e]
  24962. * The triggering event, containing chart coordinates of the pointer.
  24963. *
  24964. * @return {object}
  24965. * Object containing resulting hover data: hoverPoint, hoverSeries,
  24966. * and hoverPoints.
  24967. */
  24968. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  24969. var hoverPoint,
  24970. hoverPoints = [],
  24971. hoverSeries = existingHoverSeries,
  24972. useExisting = !!(isDirectTouch && existingHoverPoint),
  24973. notSticky = hoverSeries && !hoverSeries.stickyTracking,
  24974. // Which series to look in for the hover point
  24975. searchSeries,
  24976. // Parameters needed for beforeGetHoverData event.
  24977. eventArgs = {
  24978. chartX: e ? e.chartX : void 0,
  24979. chartY: e ? e.chartY : void 0,
  24980. shared: shared
  24981. },
  24982. filter = function (s) {
  24983. return (s.visible &&
  24984. !(!shared && s.directTouch) && // #3821
  24985. pick(s.options.enableMouseTracking,
  24986. true));
  24987. };
  24988. // Find chart.hoverPane and update filter method in polar.
  24989. fireEvent(this, 'beforeGetHoverData', eventArgs);
  24990. searchSeries = notSticky ?
  24991. // Only search on hovered series if it has stickyTracking false
  24992. [hoverSeries] :
  24993. // Filter what series to look in.
  24994. series.filter(function (s) {
  24995. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  24996. s.stickyTracking;
  24997. });
  24998. // Use existing hovered point or find the one closest to coordinates.
  24999. hoverPoint = useExisting || !e ?
  25000. existingHoverPoint :
  25001. this.findNearestKDPoint(searchSeries, shared, e);
  25002. // Assign hover series
  25003. hoverSeries = hoverPoint && hoverPoint.series;
  25004. // If we have a hoverPoint, assign hoverPoints.
  25005. if (hoverPoint) {
  25006. // When tooltip is shared, it displays more than one point
  25007. if (shared && !hoverSeries.noSharedTooltip) {
  25008. searchSeries = series.filter(function (s) {
  25009. return eventArgs.filter ?
  25010. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  25011. });
  25012. // Get all points with the same x value as the hoverPoint
  25013. searchSeries.forEach(function (s) {
  25014. var point = find(s.points,
  25015. function (p) {
  25016. return p.x === hoverPoint.x && !p.isNull;
  25017. });
  25018. if (isObject(point)) {
  25019. /*
  25020. * Boost returns a minimal point. Convert it to a usable
  25021. * point for tooltip and states.
  25022. */
  25023. if (s.chart.isBoosting) {
  25024. point = s.getPoint(point);
  25025. }
  25026. hoverPoints.push(point);
  25027. }
  25028. });
  25029. }
  25030. else {
  25031. hoverPoints.push(hoverPoint);
  25032. }
  25033. }
  25034. // Check whether the hoverPoint is inside pane we are hovering over.
  25035. eventArgs = { hoverPoint: hoverPoint };
  25036. fireEvent(this, 'afterGetHoverData', eventArgs);
  25037. return {
  25038. hoverPoint: eventArgs.hoverPoint,
  25039. hoverSeries: hoverSeries,
  25040. hoverPoints: hoverPoints
  25041. };
  25042. };
  25043. /**
  25044. * @private
  25045. * @function Highcharts.Pointer#getPointFromEvent
  25046. *
  25047. * @param {global.Event} e
  25048. *
  25049. * @return {Highcharts.Point|undefined}
  25050. */
  25051. Pointer.prototype.getPointFromEvent = function (e) {
  25052. var target = e.target,
  25053. point;
  25054. while (target && !point) {
  25055. point = target.point;
  25056. target = target.parentNode;
  25057. }
  25058. return point;
  25059. };
  25060. /**
  25061. * @private
  25062. * @function Highcharts.Pointer#onTrackerMouseOut
  25063. */
  25064. Pointer.prototype.onTrackerMouseOut = function (e) {
  25065. var chart = this.chart;
  25066. var relatedTarget = e.relatedTarget || e.toElement;
  25067. var series = chart.hoverSeries;
  25068. this.isDirectTouch = false;
  25069. if (series &&
  25070. relatedTarget &&
  25071. !series.stickyTracking &&
  25072. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  25073. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  25074. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  25075. series.onMouseOut();
  25076. }
  25077. };
  25078. /**
  25079. * Utility to detect whether an element has, or has a parent with, a
  25080. * specificclass name. Used on detection of tracker objects and on deciding
  25081. * whether hovering the tooltip should cause the active series to mouse out.
  25082. *
  25083. * @function Highcharts.Pointer#inClass
  25084. *
  25085. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  25086. * The element to investigate.
  25087. *
  25088. * @param {string} className
  25089. * The class name to look for.
  25090. *
  25091. * @return {boolean|undefined}
  25092. * True if either the element or one of its parents has the given
  25093. * class name.
  25094. */
  25095. Pointer.prototype.inClass = function (element, className) {
  25096. var elemClassName;
  25097. while (element) {
  25098. elemClassName = attr(element, 'class');
  25099. if (elemClassName) {
  25100. if (elemClassName.indexOf(className) !== -1) {
  25101. return true;
  25102. }
  25103. if (elemClassName.indexOf('highcharts-container') !== -1) {
  25104. return false;
  25105. }
  25106. }
  25107. element = element.parentNode;
  25108. }
  25109. };
  25110. /**
  25111. * Initialize the Pointer.
  25112. *
  25113. * @private
  25114. * @function Highcharts.Pointer#init
  25115. *
  25116. * @param {Highcharts.Chart} chart
  25117. * The Chart instance.
  25118. *
  25119. * @param {Highcharts.Options} options
  25120. * The root options object. The pointer uses options from the chart
  25121. * and tooltip structures.
  25122. *
  25123. * @return {void}
  25124. */
  25125. Pointer.prototype.init = function (chart, options) {
  25126. // Store references
  25127. this.options = options;
  25128. this.chart = chart;
  25129. // Do we need to handle click on a touch device?
  25130. this.runChartClick = Boolean(options.chart.events && options.chart.events.click);
  25131. this.pinchDown = [];
  25132. this.lastValidTouch = {};
  25133. if (Tooltip) {
  25134. /**
  25135. * Tooltip object for points of series.
  25136. *
  25137. * @name Highcharts.Chart#tooltip
  25138. * @type {Highcharts.Tooltip}
  25139. */
  25140. chart.tooltip = new Tooltip(chart, options.tooltip);
  25141. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  25142. }
  25143. this.setDOMEvents();
  25144. };
  25145. /**
  25146. * Takes a browser event object and extends it with custom Highcharts
  25147. * properties `chartX` and `chartY` in order to work on the internal
  25148. * coordinate system.
  25149. *
  25150. * @function Highcharts.Pointer#normalize
  25151. *
  25152. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  25153. * Event object in standard browsers.
  25154. *
  25155. * @param {Highcharts.OffsetObject} [chartPosition]
  25156. * Additional chart offset.
  25157. *
  25158. * @return {Highcharts.PointerEventObject}
  25159. * A browser event with extended properties `chartX` and `chartY`.
  25160. */
  25161. Pointer.prototype.normalize = function (e, chartPosition) {
  25162. var touches = e.touches;
  25163. // iOS (#2757)
  25164. var ePos = (touches ?
  25165. touches.length ?
  25166. touches.item(0) :
  25167. (pick(// #13534
  25168. touches.changedTouches,
  25169. e.changedTouches))[0] :
  25170. e);
  25171. // Get mouse position
  25172. if (!chartPosition) {
  25173. chartPosition = this.getChartPosition();
  25174. }
  25175. var chartX = ePos.pageX - chartPosition.left,
  25176. chartY = ePos.pageY - chartPosition.top;
  25177. // #11329 - when there is scaling on a parent element, we need to take
  25178. // this into account
  25179. chartX /= chartPosition.scaleX;
  25180. chartY /= chartPosition.scaleY;
  25181. return extend(e, {
  25182. chartX: Math.round(chartX),
  25183. chartY: Math.round(chartY)
  25184. });
  25185. };
  25186. /**
  25187. * @private
  25188. * @function Highcharts.Pointer#onContainerClick
  25189. */
  25190. Pointer.prototype.onContainerClick = function (e) {
  25191. var chart = this.chart;
  25192. var hoverPoint = chart.hoverPoint;
  25193. var pEvt = this.normalize(e);
  25194. var plotLeft = chart.plotLeft;
  25195. var plotTop = chart.plotTop;
  25196. if (!chart.cancelClick) {
  25197. // On tracker click, fire the series and point events. #783, #1583
  25198. if (hoverPoint &&
  25199. this.inClass(pEvt.target, 'highcharts-tracker')) {
  25200. // the series click event
  25201. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  25202. point: hoverPoint
  25203. }));
  25204. // the point click event
  25205. if (chart.hoverPoint) { // it may be destroyed (#1844)
  25206. hoverPoint.firePointEvent('click', pEvt);
  25207. }
  25208. // When clicking outside a tracker, fire a chart event
  25209. }
  25210. else {
  25211. extend(pEvt, this.getCoordinates(pEvt));
  25212. // fire a click event in the chart
  25213. if (chart.isInsidePlot(pEvt.chartX - plotLeft, pEvt.chartY - plotTop, {
  25214. visiblePlotOnly: true
  25215. })) {
  25216. fireEvent(chart, 'click', pEvt);
  25217. }
  25218. }
  25219. }
  25220. };
  25221. /**
  25222. * @private
  25223. * @function Highcharts.Pointer#onContainerMouseDown
  25224. *
  25225. * @param {global.MouseEvent} e
  25226. */
  25227. Pointer.prototype.onContainerMouseDown = function (e) {
  25228. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  25229. // Normalize before the 'if' for the legacy IE (#7850)
  25230. e = this.normalize(e);
  25231. // #11635, Firefox does not reliable fire move event after click scroll
  25232. if (H.isFirefox &&
  25233. e.button !== 0) {
  25234. this.onContainerMouseMove(e);
  25235. }
  25236. // #11635, limiting to primary button (incl. IE 8 support)
  25237. if (typeof e.button === 'undefined' ||
  25238. isPrimaryButton) {
  25239. this.zoomOption(e);
  25240. // #295, #13737 solve conflict between container drag and chart zoom
  25241. if (isPrimaryButton &&
  25242. e.preventDefault) {
  25243. e.preventDefault();
  25244. }
  25245. this.dragStart(e);
  25246. }
  25247. };
  25248. /**
  25249. * When mouse leaves the container, hide the tooltip.
  25250. *
  25251. * @private
  25252. * @function Highcharts.Pointer#onContainerMouseLeave
  25253. *
  25254. * @param {global.MouseEvent} e
  25255. *
  25256. * @return {void}
  25257. */
  25258. Pointer.prototype.onContainerMouseLeave = function (e) {
  25259. var chart = charts[pick(H.hoverChartIndex, -1)];
  25260. var tooltip = this.chart.tooltip;
  25261. e = this.normalize(e);
  25262. // #4886, MS Touch end fires mouseleave but with no related target
  25263. if (chart &&
  25264. (e.relatedTarget || e.toElement)) {
  25265. chart.pointer.reset();
  25266. // Also reset the chart position, used in #149 fix
  25267. chart.pointer.chartPosition = void 0;
  25268. }
  25269. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  25270. tooltip &&
  25271. !tooltip.isHidden) {
  25272. this.reset();
  25273. }
  25274. };
  25275. /**
  25276. * When mouse enters the container, delete pointer's chartPosition.
  25277. *
  25278. * @private
  25279. * @function Highcharts.Pointer#onContainerMouseEnter
  25280. *
  25281. * @param {global.MouseEvent} e
  25282. *
  25283. * @return {void}
  25284. */
  25285. Pointer.prototype.onContainerMouseEnter = function (e) {
  25286. delete this.chartPosition;
  25287. };
  25288. /**
  25289. * The mousemove, touchmove and touchstart event handler
  25290. *
  25291. * @private
  25292. * @function Highcharts.Pointer#onContainerMouseMove
  25293. *
  25294. * @param {global.MouseEvent} e
  25295. *
  25296. * @return {void}
  25297. */
  25298. Pointer.prototype.onContainerMouseMove = function (e) {
  25299. var chart = this.chart;
  25300. var pEvt = this.normalize(e);
  25301. this.setHoverChartIndex();
  25302. // In IE8 we apparently need this returnValue set to false in order to
  25303. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  25304. // plus we don't need to run e.preventDefault to prevent selected text
  25305. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  25306. // no longer needed. #2251, #3224.
  25307. if (!pEvt.preventDefault) {
  25308. pEvt.returnValue = false;
  25309. }
  25310. if (chart.mouseIsDown === 'mousedown' || this.touchSelect(pEvt)) {
  25311. this.drag(pEvt);
  25312. }
  25313. // Show the tooltip and run mouse over events (#977)
  25314. if (!chart.openMenu &&
  25315. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  25316. chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25317. visiblePlotOnly: true
  25318. }))) {
  25319. this.runPointActions(pEvt);
  25320. }
  25321. };
  25322. /**
  25323. * @private
  25324. * @function Highcharts.Pointer#onDocumentTouchEnd
  25325. *
  25326. * @param {Highcharts.PointerEventObject} e
  25327. *
  25328. * @return {void}
  25329. */
  25330. Pointer.prototype.onDocumentTouchEnd = function (e) {
  25331. if (charts[H.hoverChartIndex]) {
  25332. charts[H.hoverChartIndex].pointer.drop(e);
  25333. }
  25334. };
  25335. /**
  25336. * @private
  25337. * @function Highcharts.Pointer#onContainerTouchMove
  25338. *
  25339. * @param {Highcharts.PointerEventObject} e
  25340. *
  25341. * @return {void}
  25342. */
  25343. Pointer.prototype.onContainerTouchMove = function (e) {
  25344. if (this.touchSelect(e)) {
  25345. this.onContainerMouseMove(e);
  25346. }
  25347. else {
  25348. this.touch(e);
  25349. }
  25350. };
  25351. /**
  25352. * @private
  25353. * @function Highcharts.Pointer#onContainerTouchStart
  25354. *
  25355. * @param {Highcharts.PointerEventObject} e
  25356. *
  25357. * @return {void}
  25358. */
  25359. Pointer.prototype.onContainerTouchStart = function (e) {
  25360. if (this.touchSelect(e)) {
  25361. this.onContainerMouseDown(e);
  25362. }
  25363. else {
  25364. this.zoomOption(e);
  25365. this.touch(e, true);
  25366. }
  25367. };
  25368. /**
  25369. * Special handler for mouse move that will hide the tooltip when the mouse
  25370. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  25371. * always fire.
  25372. *
  25373. * @private
  25374. * @function Highcharts.Pointer#onDocumentMouseMove
  25375. *
  25376. * @param {global.MouseEvent} e
  25377. *
  25378. * @return {void}
  25379. */
  25380. Pointer.prototype.onDocumentMouseMove = function (e) {
  25381. var chart = this.chart;
  25382. var chartPosition = this.chartPosition;
  25383. var pEvt = this.normalize(e,
  25384. chartPosition);
  25385. var tooltip = chart.tooltip;
  25386. // If we're outside, hide the tooltip
  25387. if (chartPosition &&
  25388. (!tooltip ||
  25389. !tooltip.isStickyOnContact()) &&
  25390. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25391. visiblePlotOnly: true
  25392. }) &&
  25393. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  25394. this.reset();
  25395. }
  25396. };
  25397. /**
  25398. * @private
  25399. * @function Highcharts.Pointer#onDocumentMouseUp
  25400. *
  25401. * @param {global.MouseEvent} e
  25402. *
  25403. * @return {void}
  25404. */
  25405. Pointer.prototype.onDocumentMouseUp = function (e) {
  25406. var chart = charts[pick(H.hoverChartIndex, -1)];
  25407. if (chart) {
  25408. chart.pointer.drop(e);
  25409. }
  25410. };
  25411. /**
  25412. * Handle touch events with two touches
  25413. *
  25414. * @private
  25415. * @function Highcharts.Pointer#pinch
  25416. *
  25417. * @param {Highcharts.PointerEventObject} e
  25418. *
  25419. * @return {void}
  25420. */
  25421. Pointer.prototype.pinch = function (e) {
  25422. var self = this,
  25423. chart = self.chart,
  25424. pinchDown = self.pinchDown,
  25425. touches = (e.touches || []),
  25426. touchesLength = touches.length,
  25427. lastValidTouch = self.lastValidTouch,
  25428. hasZoom = self.hasZoom,
  25429. selectionMarker = self.selectionMarker,
  25430. transform = {},
  25431. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  25432. chart.runTrackerClick) ||
  25433. self.runChartClick),
  25434. clip = {};
  25435. // Don't initiate panning until the user has pinched. This prevents us
  25436. // from blocking page scrolling as users scroll down a long page
  25437. // (#4210).
  25438. if (touchesLength > 1) {
  25439. self.initiated = true;
  25440. }
  25441. // On touch devices, only proceed to trigger click if a handler is
  25442. // defined
  25443. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  25444. e.preventDefault();
  25445. }
  25446. // Normalize each touch
  25447. [].map.call(touches, function (e) {
  25448. return self.normalize(e);
  25449. });
  25450. // Register the touch start position
  25451. if (e.type === 'touchstart') {
  25452. [].forEach.call(touches, function (e, i) {
  25453. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  25454. });
  25455. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  25456. pinchDown[1].chartX];
  25457. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  25458. pinchDown[1].chartY];
  25459. // Identify the data bounds in pixels
  25460. chart.axes.forEach(function (axis) {
  25461. if (axis.zoomEnabled) {
  25462. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  25463. minPixelPadding = axis.minPixelPadding,
  25464. min = axis.toPixels(Math.min(pick(axis.options.min,
  25465. axis.dataMin),
  25466. axis.dataMin)),
  25467. max = axis.toPixels(Math.max(pick(axis.options.max,
  25468. axis.dataMax),
  25469. axis.dataMax)),
  25470. absMin = Math.min(min,
  25471. max),
  25472. absMax = Math.max(min,
  25473. max);
  25474. // Store the bounds for use in the touchmove handler
  25475. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  25476. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  25477. }
  25478. });
  25479. self.res = true; // reset on next move
  25480. // Optionally move the tooltip on touchmove
  25481. }
  25482. else if (self.followTouchMove && touchesLength === 1) {
  25483. this.runPointActions(self.normalize(e));
  25484. // Event type is touchmove, handle panning and pinching
  25485. }
  25486. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  25487. // fires first
  25488. // Set the marker
  25489. if (!selectionMarker) {
  25490. // @todo It's a mock object, so maybe we need a separate
  25491. // interface
  25492. self.selectionMarker = selectionMarker = extend({
  25493. destroy: noop,
  25494. touch: true
  25495. }, chart.plotBox);
  25496. }
  25497. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25498. self.hasPinched = hasZoom;
  25499. // Scale and translate the groups to provide visual feedback during
  25500. // pinching
  25501. self.scaleGroups(transform, clip);
  25502. if (self.res) {
  25503. self.res = false;
  25504. this.reset(false, 0);
  25505. }
  25506. }
  25507. };
  25508. /**
  25509. * Run translation operations
  25510. *
  25511. * @private
  25512. * @function Highcharts.Pointer#pinchTranslate
  25513. *
  25514. * @param {Array<*>} pinchDown
  25515. *
  25516. * @param {Array<Highcharts.PointerEventObject>} touches
  25517. *
  25518. * @param {*} transform
  25519. *
  25520. * @param {*} selectionMarker
  25521. *
  25522. * @param {*} clip
  25523. *
  25524. * @param {*} lastValidTouch
  25525. *
  25526. * @return {void}
  25527. */
  25528. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  25529. if (this.zoomHor) {
  25530. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25531. }
  25532. if (this.zoomVert) {
  25533. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25534. }
  25535. };
  25536. /**
  25537. * Run translation operations for each direction (horizontal and vertical)
  25538. * independently.
  25539. *
  25540. * @private
  25541. * @function Highcharts.Pointer#pinchTranslateDirection
  25542. *
  25543. * @param {boolean} horiz
  25544. *
  25545. * @param {Array<*>} pinchDown
  25546. *
  25547. * @param {Array<Highcharts.PointerEventObject>} touches
  25548. *
  25549. * @param {*} transform
  25550. *
  25551. * @param {*} selectionMarker
  25552. *
  25553. * @param {*} clip
  25554. *
  25555. * @param {*} lastValidTouch
  25556. *
  25557. * @param {number|undefined} [forcedScale=1]
  25558. *
  25559. * @return {void}
  25560. */
  25561. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  25562. var chart = this.chart, xy = horiz ? 'x' : 'y', XY = horiz ? 'X' : 'Y', sChartXY = ('chart' + XY), wh = horiz ? 'width' : 'height', plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')], selectionWH, selectionXY, clipXY, scale = forcedScale || 1, inverted = chart.inverted, bounds = chart.bounds[horiz ? 'h' : 'v'], singleTouch = pinchDown.length === 1, touch0Start = pinchDown[0][sChartXY], touch0Now = touches[0][sChartXY], touch1Start = !singleTouch && pinchDown[1][sChartXY], touch1Now = !singleTouch && touches[1][sChartXY], outOfBounds, transformScale, scaleKey, setScale = function () {
  25563. // Don't zoom if fingers are too close on this axis
  25564. if (typeof touch1Now === 'number' &&
  25565. Math.abs(touch0Start - touch1Start) > 20) {
  25566. scale = forcedScale ||
  25567. Math.abs(touch0Now - touch1Now) /
  25568. Math.abs(touch0Start - touch1Start);
  25569. }
  25570. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  25571. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  25572. };
  25573. // Set the scale, first pass
  25574. setScale();
  25575. // The clip position (x or y) is altered if out of bounds, the selection
  25576. // position is not
  25577. selectionXY = clipXY;
  25578. // Out of bounds
  25579. if (selectionXY < bounds.min) {
  25580. selectionXY = bounds.min;
  25581. outOfBounds = true;
  25582. }
  25583. else if (selectionXY + selectionWH > bounds.max) {
  25584. selectionXY = bounds.max - selectionWH;
  25585. outOfBounds = true;
  25586. }
  25587. // Is the chart dragged off its bounds, determined by dataMin and
  25588. // dataMax?
  25589. if (outOfBounds) {
  25590. // Modify the touchNow position in order to create an elastic drag
  25591. // movement. This indicates to the user that the chart is responsive
  25592. // but can't be dragged further.
  25593. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  25594. if (typeof touch1Now === 'number') {
  25595. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  25596. }
  25597. // Set the scale, second pass to adapt to the modified touchNow
  25598. // positions
  25599. setScale();
  25600. }
  25601. else {
  25602. lastValidTouch[xy] = [touch0Now, touch1Now];
  25603. }
  25604. // Set geometry for clipping, selection and transformation
  25605. if (!inverted) {
  25606. clip[xy] = clipXY - plotLeftTop;
  25607. clip[wh] = selectionWH;
  25608. }
  25609. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  25610. transformScale = inverted ? 1 / scale : scale;
  25611. selectionMarker[wh] = selectionWH;
  25612. selectionMarker[xy] = selectionXY;
  25613. transform[scaleKey] = scale;
  25614. transform['translate' + XY] = (transformScale * plotLeftTop) +
  25615. (touch0Now - (transformScale * touch0Start));
  25616. };
  25617. /**
  25618. * Reset the tracking by hiding the tooltip, the hover series state and the
  25619. * hover point
  25620. *
  25621. * @function Highcharts.Pointer#reset
  25622. *
  25623. * @param {boolean} [allowMove]
  25624. * Instead of destroying the tooltip altogether, allow moving it if
  25625. * possible.
  25626. *
  25627. * @param {number} [delay]
  25628. *
  25629. * @return {void}
  25630. */
  25631. Pointer.prototype.reset = function (allowMove, delay) {
  25632. var pointer = this,
  25633. chart = pointer.chart,
  25634. hoverSeries = chart.hoverSeries,
  25635. hoverPoint = chart.hoverPoint,
  25636. hoverPoints = chart.hoverPoints,
  25637. tooltip = chart.tooltip,
  25638. tooltipPoints = tooltip && tooltip.shared ?
  25639. hoverPoints :
  25640. hoverPoint;
  25641. // Check if the points have moved outside the plot area (#1003, #4736,
  25642. // #5101)
  25643. if (allowMove && tooltipPoints) {
  25644. splat(tooltipPoints).forEach(function (point) {
  25645. if (point.series.isCartesian &&
  25646. typeof point.plotX === 'undefined') {
  25647. allowMove = false;
  25648. }
  25649. });
  25650. }
  25651. // Just move the tooltip, #349
  25652. if (allowMove) {
  25653. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  25654. tooltip.refresh(tooltipPoints);
  25655. if (tooltip.shared && hoverPoints) { // #8284
  25656. hoverPoints.forEach(function (point) {
  25657. point.setState(point.state, true);
  25658. if (point.series.isCartesian) {
  25659. if (point.series.xAxis.crosshair) {
  25660. point.series.xAxis
  25661. .drawCrosshair(null, point);
  25662. }
  25663. if (point.series.yAxis.crosshair) {
  25664. point.series.yAxis
  25665. .drawCrosshair(null, point);
  25666. }
  25667. }
  25668. });
  25669. }
  25670. else if (hoverPoint) { // #2500
  25671. hoverPoint.setState(hoverPoint.state, true);
  25672. chart.axes.forEach(function (axis) {
  25673. if (axis.crosshair &&
  25674. hoverPoint.series[axis.coll] === axis) {
  25675. axis.drawCrosshair(null, hoverPoint);
  25676. }
  25677. });
  25678. }
  25679. }
  25680. // Full reset
  25681. }
  25682. else {
  25683. if (hoverPoint) {
  25684. hoverPoint.onMouseOut();
  25685. }
  25686. if (hoverPoints) {
  25687. hoverPoints.forEach(function (point) {
  25688. point.setState();
  25689. });
  25690. }
  25691. if (hoverSeries) {
  25692. hoverSeries.onMouseOut();
  25693. }
  25694. if (tooltip) {
  25695. tooltip.hide(delay);
  25696. }
  25697. if (pointer.unDocMouseMove) {
  25698. pointer.unDocMouseMove = pointer.unDocMouseMove();
  25699. }
  25700. // Remove crosshairs
  25701. chart.axes.forEach(function (axis) {
  25702. axis.hideCrosshair();
  25703. });
  25704. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  25705. }
  25706. };
  25707. /**
  25708. * With line type charts with a single tracker, get the point closest to the
  25709. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  25710. *
  25711. * @private
  25712. * @function Highcharts.Pointer#runPointActions
  25713. *
  25714. * @fires Highcharts.Point#event:mouseOut
  25715. * @fires Highcharts.Point#event:mouseOver
  25716. */
  25717. Pointer.prototype.runPointActions = function (e, p) {
  25718. var pointer = this,
  25719. chart = pointer.chart,
  25720. series = chart.series,
  25721. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  25722. chart.tooltip :
  25723. void 0),
  25724. shared = (tooltip ?
  25725. tooltip.shared :
  25726. false),
  25727. hoverPoint = p || chart.hoverPoint,
  25728. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  25729. // onMouseOver or already hovering a series with directTouch
  25730. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  25731. pointer.isDirectTouch)),
  25732. hoverData = this.getHoverData(hoverPoint,
  25733. hoverSeries,
  25734. series,
  25735. isDirectTouch,
  25736. shared,
  25737. e),
  25738. useSharedTooltip,
  25739. followPointer,
  25740. points;
  25741. // Update variables from hoverData.
  25742. hoverPoint = hoverData.hoverPoint;
  25743. points = hoverData.hoverPoints;
  25744. hoverSeries = hoverData.hoverSeries;
  25745. followPointer = hoverSeries &&
  25746. hoverSeries.tooltipOptions.followPointer &&
  25747. !hoverSeries.tooltipOptions.split;
  25748. useSharedTooltip = (shared &&
  25749. hoverSeries &&
  25750. !hoverSeries.noSharedTooltip);
  25751. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  25752. // #3926, #4200
  25753. if (hoverPoint &&
  25754. // !(hoverSeries && hoverSeries.directTouch) &&
  25755. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  25756. (chart.hoverPoints || []).forEach(function (p) {
  25757. if (points.indexOf(p) === -1) {
  25758. p.setState();
  25759. }
  25760. });
  25761. // Set normal state to previous series
  25762. if (chart.hoverSeries !== hoverSeries) {
  25763. hoverSeries.onMouseOver();
  25764. }
  25765. pointer.applyInactiveState(points);
  25766. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  25767. (points || []).forEach(function (p) {
  25768. p.setState('hover');
  25769. });
  25770. // If tracking is on series in stead of on each point,
  25771. // fire mouseOver on hover point. // #4448
  25772. if (chart.hoverPoint) {
  25773. chart.hoverPoint.firePointEvent('mouseOut');
  25774. }
  25775. // Hover point may have been destroyed in the event handlers (#7127)
  25776. if (!hoverPoint.series) {
  25777. return;
  25778. }
  25779. /**
  25780. * Contains all hovered points.
  25781. *
  25782. * @name Highcharts.Chart#hoverPoints
  25783. * @type {Array<Highcharts.Point>|null}
  25784. */
  25785. chart.hoverPoints = points;
  25786. /**
  25787. * Contains the original hovered point.
  25788. *
  25789. * @name Highcharts.Chart#hoverPoint
  25790. * @type {Highcharts.Point|null}
  25791. */
  25792. chart.hoverPoint = hoverPoint;
  25793. /**
  25794. * Hover state should not be lost when axis is updated (#12569)
  25795. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  25796. * to apply state which does not exist in hoverPoint yet.
  25797. * The mouseOver event should be triggered when hoverPoint
  25798. * is correct.
  25799. */
  25800. hoverPoint.firePointEvent('mouseOver');
  25801. // Draw tooltip if necessary
  25802. if (tooltip) {
  25803. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  25804. }
  25805. // Update positions (regardless of kdpoint or hoverPoint)
  25806. }
  25807. else if (followPointer && tooltip && !tooltip.isHidden) {
  25808. var anchor = tooltip.getAnchor([{}],
  25809. e);
  25810. if (chart.isInsidePlot(anchor[0], anchor[1], {
  25811. visiblePlotOnly: true
  25812. })) {
  25813. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  25814. }
  25815. }
  25816. // Start the event listener to pick up the tooltip and crosshairs
  25817. if (!pointer.unDocMouseMove) {
  25818. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  25819. var chart = charts[H.hoverChartIndex];
  25820. if (chart) {
  25821. chart.pointer.onDocumentMouseMove(e);
  25822. }
  25823. });
  25824. pointer.eventsToUnbind.push(pointer.unDocMouseMove);
  25825. }
  25826. // Issues related to crosshair #4927, #5269 #5066, #5658
  25827. chart.axes.forEach(function drawAxisCrosshair(axis) {
  25828. var snap = pick((axis.crosshair || {}).snap,
  25829. true);
  25830. var point;
  25831. if (snap) {
  25832. point = chart.hoverPoint; // #13002
  25833. if (!point || point.series[axis.coll] !== axis) {
  25834. point = find(points, function (p) {
  25835. return p.series[axis.coll] === axis;
  25836. });
  25837. }
  25838. }
  25839. // Axis has snapping crosshairs, and one of the hover points belongs
  25840. // to axis. Always call drawCrosshair when it is not snap.
  25841. if (point || !snap) {
  25842. axis.drawCrosshair(e, point);
  25843. // Axis has snapping crosshairs, but no hover point belongs to axis
  25844. }
  25845. else {
  25846. axis.hideCrosshair();
  25847. }
  25848. });
  25849. };
  25850. /**
  25851. * Scale series groups to a certain scale and translation.
  25852. *
  25853. * @private
  25854. * @function Highcharts.Pointer#scaleGroups
  25855. */
  25856. Pointer.prototype.scaleGroups = function (attribs, clip) {
  25857. var chart = this.chart,
  25858. seriesAttribs;
  25859. // Scale each series
  25860. chart.series.forEach(function (series) {
  25861. seriesAttribs = attribs || series.getPlotBox(); // #1701
  25862. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  25863. series.group.attr(seriesAttribs);
  25864. if (series.markerGroup) {
  25865. series.markerGroup.attr(seriesAttribs);
  25866. series.markerGroup.clip(clip ? chart.clipRect : null);
  25867. }
  25868. if (series.dataLabelsGroup) {
  25869. series.dataLabelsGroup.attr(seriesAttribs);
  25870. }
  25871. }
  25872. });
  25873. // Clip
  25874. chart.clipRect.attr(clip || chart.clipBox);
  25875. };
  25876. /**
  25877. * Set the JS DOM events on the container and document. This method should
  25878. * contain a one-to-one assignment between methods and their handlers. Any
  25879. * advanced logic should be moved to the handler reflecting the event's
  25880. * name.
  25881. *
  25882. * @private
  25883. * @function Highcharts.Pointer#setDOMEvents
  25884. */
  25885. Pointer.prototype.setDOMEvents = function () {
  25886. var _this = this;
  25887. var container = this.chart.container,
  25888. ownerDoc = container.ownerDocument;
  25889. container.onmousedown = this.onContainerMouseDown.bind(this);
  25890. container.onmousemove = this.onContainerMouseMove.bind(this);
  25891. container.onclick = this.onContainerClick.bind(this);
  25892. this.eventsToUnbind.push(addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this)));
  25893. this.eventsToUnbind.push(addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this)));
  25894. if (!H.unbindDocumentMouseUp) {
  25895. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  25896. }
  25897. // In case we are dealing with overflow, reset the chart position when
  25898. // scrolling parent elements
  25899. var parent = this.chart.renderTo.parentElement;
  25900. while (parent && parent.tagName !== 'BODY') {
  25901. this.eventsToUnbind.push(addEvent(parent, 'scroll', function () {
  25902. delete _this.chartPosition;
  25903. }));
  25904. parent = parent.parentElement;
  25905. }
  25906. if (H.hasTouch) {
  25907. this.eventsToUnbind.push(addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this), { passive: false }));
  25908. this.eventsToUnbind.push(addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this), { passive: false }));
  25909. if (!H.unbindDocumentTouchEnd) {
  25910. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this), { passive: false });
  25911. }
  25912. }
  25913. };
  25914. /**
  25915. * Sets the index of the hovered chart and leaves the previous hovered
  25916. * chart, to reset states like tooltip.
  25917. *
  25918. * @private
  25919. * @function Highcharts.Pointer#setHoverChartIndex
  25920. */
  25921. Pointer.prototype.setHoverChartIndex = function () {
  25922. var chart = this.chart;
  25923. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  25924. if (hoverChart &&
  25925. hoverChart !== chart) {
  25926. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  25927. }
  25928. if (!hoverChart ||
  25929. !hoverChart.mouseIsDown) {
  25930. H.hoverChartIndex = chart.index;
  25931. }
  25932. };
  25933. /**
  25934. * General touch handler shared by touchstart and touchmove.
  25935. *
  25936. * @private
  25937. * @function Highcharts.Pointer#touch
  25938. */
  25939. Pointer.prototype.touch = function (e, start) {
  25940. var chart = this.chart,
  25941. hasMoved,
  25942. pinchDown,
  25943. isInside;
  25944. this.setHoverChartIndex();
  25945. if (e.touches.length === 1) {
  25946. e = this.normalize(e);
  25947. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop, {
  25948. visiblePlotOnly: true
  25949. });
  25950. if (isInside && !chart.openMenu) {
  25951. // Run mouse events and display tooltip etc
  25952. if (start) {
  25953. this.runPointActions(e);
  25954. }
  25955. // Android fires touchmove events after the touchstart even if
  25956. // the finger hasn't moved, or moved only a pixel or two. In iOS
  25957. // however, the touchmove doesn't fire unless the finger moves
  25958. // more than ~4px. So we emulate this behaviour in Android by
  25959. // checking how much it moved, and cancelling on small
  25960. // distances. #3450.
  25961. if (e.type === 'touchmove') {
  25962. pinchDown = this.pinchDown;
  25963. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  25964. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  25965. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  25966. }
  25967. if (pick(hasMoved, true)) {
  25968. this.pinch(e);
  25969. }
  25970. }
  25971. else if (start) {
  25972. // Hide the tooltip on touching outside the plot area (#1203)
  25973. this.reset();
  25974. }
  25975. }
  25976. else if (e.touches.length === 2) {
  25977. this.pinch(e);
  25978. }
  25979. };
  25980. /**
  25981. * Returns true if the chart is set up for zooming by single touch and the
  25982. * event is capable
  25983. * @param {PointEvent} e
  25984. * Event object
  25985. */
  25986. Pointer.prototype.touchSelect = function (e) {
  25987. return Boolean(this.chart.options.chart.zoomBySingleTouch &&
  25988. e.touches &&
  25989. e.touches.length === 1);
  25990. };
  25991. /**
  25992. * Resolve the zoomType option, this is reset on all touch start and mouse
  25993. * down events.
  25994. *
  25995. * @private
  25996. * @function Highcharts.Pointer#zoomOption
  25997. *
  25998. * @param {global.Event} e
  25999. * Event object.
  26000. *
  26001. * @param {void}
  26002. */
  26003. Pointer.prototype.zoomOption = function (e) {
  26004. var chart = this.chart,
  26005. options = chart.options.chart,
  26006. zoomType = options.zoomType || '',
  26007. inverted = chart.inverted,
  26008. zoomX,
  26009. zoomY;
  26010. // Look for the pinchType option
  26011. if (/touch/.test(e.type)) {
  26012. zoomType = pick(options.pinchType, zoomType);
  26013. }
  26014. this.zoomX = zoomX = /x/.test(zoomType);
  26015. this.zoomY = zoomY = /y/.test(zoomType);
  26016. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  26017. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  26018. this.hasZoom = zoomX || zoomY;
  26019. };
  26020. return Pointer;
  26021. }());
  26022. H.Pointer = Pointer;
  26023. return Pointer;
  26024. });
  26025. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  26026. /* *
  26027. *
  26028. * (c) 2010-2021 Torstein Honsi
  26029. *
  26030. * License: www.highcharts.com/license
  26031. *
  26032. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26033. *
  26034. * */
  26035. var __extends = (this && this.__extends) || (function () {
  26036. var extendStatics = function (d,
  26037. b) {
  26038. extendStatics = Object.setPrototypeOf ||
  26039. ({ __proto__: [] } instanceof Array && function (d,
  26040. b) { d.__proto__ = b; }) ||
  26041. function (d,
  26042. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26043. return extendStatics(d, b);
  26044. };
  26045. return function (d, b) {
  26046. extendStatics(d, b);
  26047. function __() { this.constructor = d; }
  26048. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26049. };
  26050. })();
  26051. var charts = H.charts,
  26052. doc = H.doc,
  26053. noop = H.noop,
  26054. win = H.win;
  26055. var addEvent = U.addEvent,
  26056. css = U.css,
  26057. objectEach = U.objectEach,
  26058. removeEvent = U.removeEvent;
  26059. /* globals MSPointerEvent, PointerEvent */
  26060. // The touches object keeps track of the points being touched at all times
  26061. var touches = {};
  26062. var hasPointerEvent = !!win.PointerEvent;
  26063. /* eslint-disable valid-jsdoc */
  26064. /** @private */
  26065. function getWebkitTouches() {
  26066. var fake = [];
  26067. fake.item = function (i) {
  26068. return this[i];
  26069. };
  26070. objectEach(touches, function (touch) {
  26071. fake.push({
  26072. pageX: touch.pageX,
  26073. pageY: touch.pageY,
  26074. target: touch.target
  26075. });
  26076. });
  26077. return fake;
  26078. }
  26079. /** @private */
  26080. function translateMSPointer(e, method, wktype, func) {
  26081. var p;
  26082. if ((e.pointerType === 'touch' ||
  26083. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  26084. func(e);
  26085. p = charts[H.hoverChartIndex].pointer;
  26086. p[method]({
  26087. type: wktype,
  26088. target: e.currentTarget,
  26089. preventDefault: noop,
  26090. touches: getWebkitTouches()
  26091. });
  26092. }
  26093. }
  26094. /** @private */
  26095. var MSPointer = /** @class */ (function (_super) {
  26096. __extends(MSPointer, _super);
  26097. function MSPointer() {
  26098. return _super !== null && _super.apply(this, arguments) || this;
  26099. }
  26100. /* *
  26101. *
  26102. * Functions
  26103. *
  26104. * */
  26105. /**
  26106. * Add or remove the MS Pointer specific events
  26107. *
  26108. * @private
  26109. * @function Highcharts.Pointer#batchMSEvents
  26110. *
  26111. * @param {Function} fn
  26112. *
  26113. * @return {void}
  26114. */
  26115. MSPointer.prototype.batchMSEvents = function (fn) {
  26116. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  26117. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  26118. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  26119. };
  26120. // Destroy MS events also
  26121. MSPointer.prototype.destroy = function () {
  26122. this.batchMSEvents(removeEvent);
  26123. _super.prototype.destroy.call(this);
  26124. };
  26125. // Disable default IE actions for pinch and such on chart element
  26126. MSPointer.prototype.init = function (chart, options) {
  26127. _super.prototype.init.call(this, chart, options);
  26128. if (this.hasZoom) { // #4014
  26129. css(chart.container, {
  26130. '-ms-touch-action': 'none',
  26131. 'touch-action': 'none'
  26132. });
  26133. }
  26134. };
  26135. /**
  26136. * @private
  26137. * @function Highcharts.Pointer#onContainerPointerDown
  26138. *
  26139. * @param {Highcharts.PointerEventObject} e
  26140. *
  26141. * @return {void}
  26142. */
  26143. MSPointer.prototype.onContainerPointerDown = function (e) {
  26144. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  26145. touches[e.pointerId] = {
  26146. pageX: e.pageX,
  26147. pageY: e.pageY,
  26148. target: e.currentTarget
  26149. };
  26150. });
  26151. };
  26152. /**
  26153. * @private
  26154. * @function Highcharts.Pointer#onContainerPointerMove
  26155. *
  26156. * @param {Highcharts.PointerEventObject} e
  26157. *
  26158. * @return {void}
  26159. */
  26160. MSPointer.prototype.onContainerPointerMove = function (e) {
  26161. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  26162. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  26163. if (!touches[e.pointerId].target) {
  26164. touches[e.pointerId].target = e.currentTarget;
  26165. }
  26166. });
  26167. };
  26168. /**
  26169. * @private
  26170. * @function Highcharts.Pointer#onDocumentPointerUp
  26171. *
  26172. * @param {Highcharts.PointerEventObject} e
  26173. *
  26174. * @return {void}
  26175. */
  26176. MSPointer.prototype.onDocumentPointerUp = function (e) {
  26177. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  26178. delete touches[e.pointerId];
  26179. });
  26180. };
  26181. // Add IE specific touch events to chart
  26182. MSPointer.prototype.setDOMEvents = function () {
  26183. _super.prototype.setDOMEvents.call(this);
  26184. if (this.hasZoom || this.followTouchMove) {
  26185. this.batchMSEvents(addEvent);
  26186. }
  26187. };
  26188. return MSPointer;
  26189. }(Pointer));
  26190. return MSPointer;
  26191. });
  26192. _registerModule(_modules, 'Core/Series/Point.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js']], function (AST, A, F, H, O, U) {
  26193. /* *
  26194. *
  26195. * (c) 2010-2021 Torstein Honsi
  26196. *
  26197. * License: www.highcharts.com/license
  26198. *
  26199. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26200. *
  26201. * */
  26202. var animObject = A.animObject;
  26203. var format = F.format;
  26204. var defaultOptions = O.defaultOptions;
  26205. var addEvent = U.addEvent,
  26206. defined = U.defined,
  26207. erase = U.erase,
  26208. extend = U.extend,
  26209. fireEvent = U.fireEvent,
  26210. getNestedProperty = U.getNestedProperty,
  26211. isArray = U.isArray,
  26212. isFunction = U.isFunction,
  26213. isNumber = U.isNumber,
  26214. isObject = U.isObject,
  26215. merge = U.merge,
  26216. objectEach = U.objectEach,
  26217. pick = U.pick,
  26218. syncTimeout = U.syncTimeout,
  26219. removeEvent = U.removeEvent,
  26220. uniqueKey = U.uniqueKey;
  26221. /**
  26222. * Function callback when a series point is clicked. Return false to cancel the
  26223. * action.
  26224. *
  26225. * @callback Highcharts.PointClickCallbackFunction
  26226. *
  26227. * @param {Highcharts.Point} this
  26228. * The point where the event occured.
  26229. *
  26230. * @param {Highcharts.PointClickEventObject} event
  26231. * Event arguments.
  26232. */
  26233. /**
  26234. * Common information for a click event on a series point.
  26235. *
  26236. * @interface Highcharts.PointClickEventObject
  26237. * @extends Highcharts.PointerEventObject
  26238. */ /**
  26239. * Clicked point.
  26240. * @name Highcharts.PointClickEventObject#point
  26241. * @type {Highcharts.Point}
  26242. */
  26243. /**
  26244. * Configuration hash for the data label and tooltip formatters.
  26245. *
  26246. * @interface Highcharts.PointLabelObject
  26247. */ /**
  26248. * The point's current color.
  26249. * @name Highcharts.PointLabelObject#color
  26250. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26251. */ /**
  26252. * The point's current color index, used in styled mode instead of `color`. The
  26253. * color index is inserted in class names used for styling.
  26254. * @name Highcharts.PointLabelObject#colorIndex
  26255. * @type {number}
  26256. */ /**
  26257. * The name of the related point.
  26258. * @name Highcharts.PointLabelObject#key
  26259. * @type {string|undefined}
  26260. */ /**
  26261. * The percentage for related points in a stacked series or pies.
  26262. * @name Highcharts.PointLabelObject#percentage
  26263. * @type {number}
  26264. */ /**
  26265. * The related point. The point name, if defined, is available through
  26266. * `this.point.name`.
  26267. * @name Highcharts.PointLabelObject#point
  26268. * @type {Highcharts.Point}
  26269. */ /**
  26270. * The related series. The series name is available through `this.series.name`.
  26271. * @name Highcharts.PointLabelObject#series
  26272. * @type {Highcharts.Series}
  26273. */ /**
  26274. * The total of values in either a stack for stacked series, or a pie in a pie
  26275. * series.
  26276. * @name Highcharts.PointLabelObject#total
  26277. * @type {number|undefined}
  26278. */ /**
  26279. * For categorized axes this property holds the category name for the point. For
  26280. * other axes it holds the X value.
  26281. * @name Highcharts.PointLabelObject#x
  26282. * @type {number|string|undefined}
  26283. */ /**
  26284. * The y value of the point.
  26285. * @name Highcharts.PointLabelObject#y
  26286. * @type {number|undefined}
  26287. */
  26288. /**
  26289. * Gets fired when the mouse leaves the area close to the point.
  26290. *
  26291. * @callback Highcharts.PointMouseOutCallbackFunction
  26292. *
  26293. * @param {Highcharts.Point} this
  26294. * Point where the event occured.
  26295. *
  26296. * @param {global.PointerEvent} event
  26297. * Event that occured.
  26298. */
  26299. /**
  26300. * Gets fired when the mouse enters the area close to the point.
  26301. *
  26302. * @callback Highcharts.PointMouseOverCallbackFunction
  26303. *
  26304. * @param {Highcharts.Point} this
  26305. * Point where the event occured.
  26306. *
  26307. * @param {global.Event} event
  26308. * Event that occured.
  26309. */
  26310. /**
  26311. * The generic point options for all series.
  26312. *
  26313. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26314. * declaration to allow custom data options:
  26315. *
  26316. * ```
  26317. * declare interface PointOptionsObject {
  26318. * customProperty: string;
  26319. * }
  26320. * ```
  26321. *
  26322. * @interface Highcharts.PointOptionsObject
  26323. */
  26324. /**
  26325. * Possible option types for a data point. Use `null` to indicate a gap.
  26326. *
  26327. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26328. */
  26329. /**
  26330. * Gets fired when the point is removed using the `.remove()` method.
  26331. *
  26332. * @callback Highcharts.PointRemoveCallbackFunction
  26333. *
  26334. * @param {Highcharts.Point} this
  26335. * Point where the event occured.
  26336. *
  26337. * @param {global.Event} event
  26338. * Event that occured.
  26339. */
  26340. /**
  26341. * Possible key values for the point state options.
  26342. *
  26343. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26344. */
  26345. /**
  26346. * Gets fired when the point is updated programmatically through the `.update()`
  26347. * method.
  26348. *
  26349. * @callback Highcharts.PointUpdateCallbackFunction
  26350. *
  26351. * @param {Highcharts.Point} this
  26352. * Point where the event occured.
  26353. *
  26354. * @param {Highcharts.PointUpdateEventObject} event
  26355. * Event that occured.
  26356. */
  26357. /**
  26358. * Information about the update event.
  26359. *
  26360. * @interface Highcharts.PointUpdateEventObject
  26361. * @extends global.Event
  26362. */ /**
  26363. * Options data of the update event.
  26364. * @name Highcharts.PointUpdateEventObject#options
  26365. * @type {Highcharts.PointOptionsType}
  26366. */
  26367. /**
  26368. * @interface Highcharts.PointEventsOptionsObject
  26369. */ /**
  26370. * Fires when the point is selected either programmatically or following a click
  26371. * on the point. One parameter, `event`, is passed to the function. Returning
  26372. * `false` cancels the operation.
  26373. * @name Highcharts.PointEventsOptionsObject#select
  26374. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  26375. */ /**
  26376. * Fires when the point is unselected either programmatically or following a
  26377. * click on the point. One parameter, `event`, is passed to the function.
  26378. * Returning `false` cancels the operation.
  26379. * @name Highcharts.PointEventsOptionsObject#unselect
  26380. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  26381. */
  26382. /**
  26383. * Information about the select/unselect event.
  26384. *
  26385. * @interface Highcharts.PointInteractionEventObject
  26386. * @extends global.Event
  26387. */ /**
  26388. * @name Highcharts.PointInteractionEventObject#accumulate
  26389. * @type {boolean}
  26390. */
  26391. /**
  26392. * Gets fired when the point is selected either programmatically or following a
  26393. * click on the point.
  26394. *
  26395. * @callback Highcharts.PointSelectCallbackFunction
  26396. *
  26397. * @param {Highcharts.Point} this
  26398. * Point where the event occured.
  26399. *
  26400. * @param {Highcharts.PointInteractionEventObject} event
  26401. * Event that occured.
  26402. */
  26403. /**
  26404. * Fires when the point is unselected either programmatically or following a
  26405. * click on the point.
  26406. *
  26407. * @callback Highcharts.PointUnselectCallbackFunction
  26408. *
  26409. * @param {Highcharts.Point} this
  26410. * Point where the event occured.
  26411. *
  26412. * @param {Highcharts.PointInteractionEventObject} event
  26413. * Event that occured.
  26414. */
  26415. ''; // detach doclet above
  26416. /* eslint-disable no-invalid-this, valid-jsdoc */
  26417. /**
  26418. * The Point object. The point objects are generated from the `series.data`
  26419. * configuration objects or raw numbers. They can be accessed from the
  26420. * `Series.points` array. Other ways to instantiate points are through {@link
  26421. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26422. *
  26423. * @class
  26424. * @name Highcharts.Point
  26425. */
  26426. var Point = /** @class */ (function () {
  26427. function Point() {
  26428. /* *
  26429. *
  26430. * Properties
  26431. *
  26432. * */
  26433. /**
  26434. * For categorized axes this property holds the category name for the
  26435. * point. For other axes it holds the X value.
  26436. *
  26437. * @name Highcharts.Point#category
  26438. * @type {string}
  26439. */
  26440. this.category = void 0;
  26441. /**
  26442. * The point's current color index, used in styled mode instead of
  26443. * `color`. The color index is inserted in class names used for styling.
  26444. *
  26445. * @name Highcharts.Point#colorIndex
  26446. * @type {number}
  26447. */
  26448. this.colorIndex = void 0;
  26449. this.formatPrefix = 'point';
  26450. this.id = void 0;
  26451. this.isNull = false;
  26452. /**
  26453. * The name of the point. The name can be given as the first position of the
  26454. * point configuration array, or as a `name` property in the configuration:
  26455. *
  26456. * @example
  26457. * // Array config
  26458. * data: [
  26459. * ['John', 1],
  26460. * ['Jane', 2]
  26461. * ]
  26462. *
  26463. * // Object config
  26464. * data: [{
  26465. * name: 'John',
  26466. * y: 1
  26467. * }, {
  26468. * name: 'Jane',
  26469. * y: 2
  26470. * }]
  26471. *
  26472. * @name Highcharts.Point#name
  26473. * @type {string}
  26474. */
  26475. this.name = void 0;
  26476. /**
  26477. * The point's options as applied in the initial configuration, or
  26478. * extended through `Point.update`.
  26479. *
  26480. * In TypeScript you have to extend `PointOptionsObject` via an
  26481. * additional interface to allow custom data options:
  26482. *
  26483. * ```
  26484. * declare interface PointOptionsObject {
  26485. * customProperty: string;
  26486. * }
  26487. * ```
  26488. *
  26489. * @name Highcharts.Point#options
  26490. * @type {Highcharts.PointOptionsObject}
  26491. */
  26492. this.options = void 0;
  26493. /**
  26494. * The percentage for points in a stacked series or pies.
  26495. *
  26496. * @name Highcharts.Point#percentage
  26497. * @type {number|undefined}
  26498. */
  26499. this.percentage = void 0;
  26500. this.selected = false;
  26501. /**
  26502. * The series object associated with the point.
  26503. *
  26504. * @name Highcharts.Point#series
  26505. * @type {Highcharts.Series}
  26506. */
  26507. this.series = void 0;
  26508. /**
  26509. * The total of values in either a stack for stacked series, or a pie in a
  26510. * pie series.
  26511. *
  26512. * @name Highcharts.Point#total
  26513. * @type {number|undefined}
  26514. */
  26515. this.total = void 0;
  26516. /**
  26517. * For certain series types, like pie charts, where individual points can
  26518. * be shown or hidden.
  26519. *
  26520. * @name Highcharts.Point#visible
  26521. * @type {boolean}
  26522. * @default true
  26523. */
  26524. this.visible = true;
  26525. this.x = void 0;
  26526. }
  26527. /* *
  26528. *
  26529. * Functions
  26530. *
  26531. * */
  26532. /**
  26533. * Animate SVG elements associated with the point.
  26534. *
  26535. * @private
  26536. * @function Highcharts.Point#animateBeforeDestroy
  26537. */
  26538. Point.prototype.animateBeforeDestroy = function () {
  26539. var point = this,
  26540. animateParams = { x: point.startXPos,
  26541. opacity: 0 },
  26542. isDataLabel,
  26543. graphicalProps = point.getGraphicalProps();
  26544. graphicalProps.singular.forEach(function (prop) {
  26545. isDataLabel = prop === 'dataLabel';
  26546. point[prop] = point[prop].animate(isDataLabel ? {
  26547. x: point[prop].startXPos,
  26548. y: point[prop].startYPos,
  26549. opacity: 0
  26550. } : animateParams);
  26551. });
  26552. graphicalProps.plural.forEach(function (plural) {
  26553. point[plural].forEach(function (item) {
  26554. if (item.element) {
  26555. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26556. x: item.startXPos,
  26557. y: item.startYPos
  26558. } : {})));
  26559. }
  26560. });
  26561. });
  26562. };
  26563. /**
  26564. * Apply the options containing the x and y data and possible some extra
  26565. * properties. Called on point init or from point.update.
  26566. *
  26567. * @private
  26568. * @function Highcharts.Point#applyOptions
  26569. *
  26570. * @param {Highcharts.PointOptionsType} options
  26571. * The point options as defined in series.data.
  26572. *
  26573. * @param {number} [x]
  26574. * Optionally, the x value.
  26575. *
  26576. * @return {Highcharts.Point}
  26577. * The Point instance.
  26578. */
  26579. Point.prototype.applyOptions = function (options, x) {
  26580. var point = this,
  26581. series = point.series,
  26582. pointValKey = series.options.pointValKey || series.pointValKey;
  26583. options = Point.prototype.optionsToObject.call(this, options);
  26584. // copy options directly to point
  26585. extend(point, options);
  26586. point.options = point.options ? extend(point.options, options) : options;
  26587. // Since options are copied into the Point instance, some accidental
  26588. // options must be shielded (#5681)
  26589. if (options.group) {
  26590. delete point.group;
  26591. }
  26592. if (options.dataLabels) {
  26593. delete point.dataLabels;
  26594. }
  26595. /**
  26596. * The y value of the point.
  26597. * @name Highcharts.Point#y
  26598. * @type {number|undefined}
  26599. */
  26600. // For higher dimension series types. For instance, for ranges, point.y
  26601. // is mapped to point.low.
  26602. if (pointValKey) {
  26603. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26604. }
  26605. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26606. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26607. // The point is initially selected by options (#5777)
  26608. if (point.selected) {
  26609. point.state = 'select';
  26610. }
  26611. /**
  26612. * The x value of the point.
  26613. * @name Highcharts.Point#x
  26614. * @type {number}
  26615. */
  26616. // If no x is set by now, get auto incremented value. All points must
  26617. // have an x value, however the y value can be null to create a gap in
  26618. // the series
  26619. if ('name' in point &&
  26620. typeof x === 'undefined' &&
  26621. series.xAxis &&
  26622. series.xAxis.hasNames) {
  26623. point.x = series.xAxis.nameToX(point);
  26624. }
  26625. if (typeof point.x === 'undefined' && series) {
  26626. if (typeof x === 'undefined') {
  26627. point.x = series.autoIncrement(point);
  26628. }
  26629. else {
  26630. point.x = x;
  26631. }
  26632. }
  26633. return point;
  26634. };
  26635. /**
  26636. * Destroy a point to clear memory. Its reference still stays in
  26637. * `series.data`.
  26638. *
  26639. * @private
  26640. * @function Highcharts.Point#destroy
  26641. */
  26642. Point.prototype.destroy = function () {
  26643. var point = this,
  26644. series = point.series,
  26645. chart = series.chart,
  26646. dataSorting = series.options.dataSorting,
  26647. hoverPoints = chart.hoverPoints,
  26648. globalAnimation = point.series.chart.renderer.globalAnimation,
  26649. animation = animObject(globalAnimation),
  26650. prop;
  26651. /**
  26652. * Allow to call after animation.
  26653. * @private
  26654. */
  26655. function destroyPoint() {
  26656. // Remove all events and elements
  26657. if (point.graphic || point.dataLabel || point.dataLabels) {
  26658. removeEvent(point);
  26659. point.destroyElements();
  26660. }
  26661. for (prop in point) { // eslint-disable-line guard-for-in
  26662. point[prop] = null;
  26663. }
  26664. }
  26665. if (point.legendItem) { // pies have legend items
  26666. chart.legend.destroyItem(point);
  26667. }
  26668. if (hoverPoints) {
  26669. point.setState();
  26670. erase(hoverPoints, point);
  26671. if (!hoverPoints.length) {
  26672. chart.hoverPoints = null;
  26673. }
  26674. }
  26675. if (point === chart.hoverPoint) {
  26676. point.onMouseOut();
  26677. }
  26678. // Remove properties after animation
  26679. if (!dataSorting || !dataSorting.enabled) {
  26680. destroyPoint();
  26681. }
  26682. else {
  26683. this.animateBeforeDestroy();
  26684. syncTimeout(destroyPoint, animation.duration);
  26685. }
  26686. chart.pointCount--;
  26687. };
  26688. /**
  26689. * Destroy SVG elements associated with the point.
  26690. *
  26691. * @private
  26692. * @function Highcharts.Point#destroyElements
  26693. * @param {Highcharts.Dictionary<number>} [kinds]
  26694. */
  26695. Point.prototype.destroyElements = function (kinds) {
  26696. var point = this,
  26697. props = point.getGraphicalProps(kinds);
  26698. props.singular.forEach(function (prop) {
  26699. point[prop] = point[prop].destroy();
  26700. });
  26701. props.plural.forEach(function (plural) {
  26702. point[plural].forEach(function (item) {
  26703. if (item.element) {
  26704. item.destroy();
  26705. }
  26706. });
  26707. delete point[plural];
  26708. });
  26709. };
  26710. /**
  26711. * Fire an event on the Point object.
  26712. *
  26713. * @private
  26714. * @function Highcharts.Point#firePointEvent
  26715. *
  26716. * @param {string} eventType
  26717. * Type of the event.
  26718. *
  26719. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  26720. * Additional event arguments.
  26721. *
  26722. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  26723. * Default event handler.
  26724. *
  26725. * @fires Highcharts.Point#event:*
  26726. */
  26727. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  26728. var point = this,
  26729. series = this.series,
  26730. seriesOptions = series.options;
  26731. // load event handlers on demand to save time on mouseover/out
  26732. if (seriesOptions.point.events[eventType] ||
  26733. (point.options &&
  26734. point.options.events &&
  26735. point.options.events[eventType])) {
  26736. point.importEvents();
  26737. }
  26738. // add default handler if in selection mode
  26739. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  26740. defaultFunction = function (event) {
  26741. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  26742. // for Opera.
  26743. if (point.select) { // #2911
  26744. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  26745. }
  26746. };
  26747. }
  26748. fireEvent(point, eventType, eventArgs, defaultFunction);
  26749. };
  26750. /**
  26751. * Get the CSS class names for individual points. Used internally where the
  26752. * returned value is set on every point.
  26753. *
  26754. * @function Highcharts.Point#getClassName
  26755. *
  26756. * @return {string}
  26757. * The class names.
  26758. */
  26759. Point.prototype.getClassName = function () {
  26760. var point = this;
  26761. return 'highcharts-point' +
  26762. (point.selected ? ' highcharts-point-select' : '') +
  26763. (point.negative ? ' highcharts-negative' : '') +
  26764. (point.isNull ? ' highcharts-null-point' : '') +
  26765. (typeof point.colorIndex !== 'undefined' ?
  26766. ' highcharts-color-' + point.colorIndex : '') +
  26767. (point.options.className ? ' ' + point.options.className : '') +
  26768. (point.zone && point.zone.className ? ' ' +
  26769. point.zone.className.replace('highcharts-negative', '') : '');
  26770. };
  26771. /**
  26772. * Get props of all existing graphical point elements.
  26773. *
  26774. * @private
  26775. * @function Highcharts.Point#getGraphicalProps
  26776. * @param {Highcharts.Dictionary<number>} [kinds]
  26777. * @return {Highcharts.PointGraphicalProps}
  26778. */
  26779. Point.prototype.getGraphicalProps = function (kinds) {
  26780. var point = this,
  26781. props = [],
  26782. prop,
  26783. i,
  26784. graphicalProps = { singular: [],
  26785. plural: [] };
  26786. kinds = kinds || { graphic: 1, dataLabel: 1 };
  26787. if (kinds.graphic) {
  26788. props.push('graphic', 'upperGraphic', 'shadowGroup');
  26789. }
  26790. if (kinds.dataLabel) {
  26791. props.push('dataLabel', 'dataLabelUpper', 'connector');
  26792. }
  26793. i = props.length;
  26794. while (i--) {
  26795. prop = props[i];
  26796. if (point[prop]) {
  26797. graphicalProps.singular.push(prop);
  26798. }
  26799. }
  26800. ['dataLabel', 'connector'].forEach(function (prop) {
  26801. var plural = prop + 's';
  26802. if (kinds[prop] && point[plural]) {
  26803. graphicalProps.plural.push(plural);
  26804. }
  26805. });
  26806. return graphicalProps;
  26807. };
  26808. /**
  26809. * Return the configuration hash needed for the data label and tooltip
  26810. * formatters.
  26811. *
  26812. * @function Highcharts.Point#getLabelConfig
  26813. *
  26814. * @return {Highcharts.PointLabelObject}
  26815. * Abstract object used in formatters and formats.
  26816. */
  26817. Point.prototype.getLabelConfig = function () {
  26818. return {
  26819. x: this.category,
  26820. y: this.y,
  26821. color: this.color,
  26822. colorIndex: this.colorIndex,
  26823. key: this.name || this.category,
  26824. series: this.series,
  26825. point: this,
  26826. percentage: this.percentage,
  26827. total: this.total || this.stackTotal
  26828. };
  26829. };
  26830. /**
  26831. * Returns the value of the point property for a given value.
  26832. * @private
  26833. */
  26834. Point.prototype.getNestedProperty = function (key) {
  26835. if (!key) {
  26836. return;
  26837. }
  26838. if (key.indexOf('custom.') === 0) {
  26839. return getNestedProperty(key, this.options);
  26840. }
  26841. return this[key];
  26842. };
  26843. /**
  26844. * In a series with `zones`, return the zone that the point belongs to.
  26845. *
  26846. * @function Highcharts.Point#getZone
  26847. *
  26848. * @return {Highcharts.SeriesZonesOptionsObject}
  26849. * The zone item.
  26850. */
  26851. Point.prototype.getZone = function () {
  26852. var series = this.series,
  26853. zones = series.zones,
  26854. zoneAxis = series.zoneAxis || 'y',
  26855. i = 0,
  26856. zone;
  26857. zone = zones[i];
  26858. while (this[zoneAxis] >= zone.value) {
  26859. zone = zones[++i];
  26860. }
  26861. // For resetting or reusing the point (#8100)
  26862. if (!this.nonZonedColor) {
  26863. this.nonZonedColor = this.color;
  26864. }
  26865. if (zone && zone.color && !this.options.color) {
  26866. this.color = zone.color;
  26867. }
  26868. else {
  26869. this.color = this.nonZonedColor;
  26870. }
  26871. return zone;
  26872. };
  26873. /**
  26874. * Utility to check if point has new shape type. Used in column series and
  26875. * all others that are based on column series.
  26876. *
  26877. * @return boolean|undefined
  26878. */
  26879. Point.prototype.hasNewShapeType = function () {
  26880. var point = this;
  26881. var oldShapeType = point.graphic &&
  26882. (point.graphic.symbolName || point.graphic.element.nodeName);
  26883. return oldShapeType !== this.shapeType;
  26884. };
  26885. /**
  26886. * Initialize the point. Called internally based on the `series.data`
  26887. * option.
  26888. *
  26889. * @function Highcharts.Point#init
  26890. *
  26891. * @param {Highcharts.Series} series
  26892. * The series object containing this point.
  26893. *
  26894. * @param {Highcharts.PointOptionsType} options
  26895. * The data in either number, array or object format.
  26896. *
  26897. * @param {number} [x]
  26898. * Optionally, the X value of the point.
  26899. *
  26900. * @return {Highcharts.Point}
  26901. * The Point instance.
  26902. *
  26903. * @fires Highcharts.Point#event:afterInit
  26904. */
  26905. Point.prototype.init = function (series, options, x) {
  26906. this.series = series;
  26907. this.applyOptions(options, x);
  26908. // Add a unique ID to the point if none is assigned
  26909. this.id = defined(this.id) ? this.id : uniqueKey();
  26910. this.resolveColor();
  26911. series.chart.pointCount++;
  26912. fireEvent(this, 'afterInit');
  26913. return this;
  26914. };
  26915. /**
  26916. * Transform number or array configs into objects. Also called for object
  26917. * configs. Used internally to unify the different configuration formats for
  26918. * points. For example, a simple number `10` in a line series will be
  26919. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  26920. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  26921. *
  26922. * @function Highcharts.Point#optionsToObject
  26923. *
  26924. * @param {Highcharts.PointOptionsType} options
  26925. * The input option.
  26926. *
  26927. * @return {Highcharts.Dictionary<*>}
  26928. * Transformed options.
  26929. */
  26930. Point.prototype.optionsToObject = function (options) {
  26931. var ret = {},
  26932. series = this.series,
  26933. keys = series.options.keys,
  26934. pointArrayMap = keys || series.pointArrayMap || ['y'],
  26935. valueCount = pointArrayMap.length,
  26936. firstItemType,
  26937. i = 0,
  26938. j = 0;
  26939. if (isNumber(options) || options === null) {
  26940. ret[pointArrayMap[0]] = options;
  26941. }
  26942. else if (isArray(options)) {
  26943. // with leading x value
  26944. if (!keys && options.length > valueCount) {
  26945. firstItemType = typeof options[0];
  26946. if (firstItemType === 'string') {
  26947. ret.name = options[0];
  26948. }
  26949. else if (firstItemType === 'number') {
  26950. ret.x = options[0];
  26951. }
  26952. i++;
  26953. }
  26954. while (j < valueCount) {
  26955. // Skip undefined positions for keys
  26956. if (!keys || typeof options[i] !== 'undefined') {
  26957. if (pointArrayMap[j].indexOf('.') > 0) {
  26958. // Handle nested keys, e.g. ['color.pattern.image']
  26959. // Avoid function call unless necessary.
  26960. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  26961. }
  26962. else {
  26963. ret[pointArrayMap[j]] = options[i];
  26964. }
  26965. }
  26966. i++;
  26967. j++;
  26968. }
  26969. }
  26970. else if (typeof options === 'object') {
  26971. ret = options;
  26972. // This is the fastest way to detect if there are individual point
  26973. // dataLabels that need to be considered in drawDataLabels. These
  26974. // can only occur in object configs.
  26975. if (options.dataLabels) {
  26976. series._hasPointLabels = true;
  26977. }
  26978. // Same approach as above for markers
  26979. if (options.marker) {
  26980. series._hasPointMarkers = true;
  26981. }
  26982. }
  26983. return ret;
  26984. };
  26985. /**
  26986. * @private
  26987. * @function Highcharts.Point#resolveColor
  26988. * @return {void}
  26989. */
  26990. Point.prototype.resolveColor = function () {
  26991. var series = this.series,
  26992. colors,
  26993. optionsChart = series.chart.options.chart,
  26994. colorCount = optionsChart.colorCount,
  26995. styledMode = series.chart.styledMode,
  26996. colorIndex,
  26997. color;
  26998. // remove points nonZonedColor for later recalculation
  26999. delete this.nonZonedColor;
  27000. if (series.options.colorByPoint) {
  27001. if (!styledMode) {
  27002. colors = series.options.colors || series.chart.options.colors;
  27003. color = colors[series.colorCounter];
  27004. colorCount = colors.length;
  27005. }
  27006. colorIndex = series.colorCounter;
  27007. series.colorCounter++;
  27008. // loop back to zero
  27009. if (series.colorCounter === colorCount) {
  27010. series.colorCounter = 0;
  27011. }
  27012. }
  27013. else {
  27014. if (!styledMode) {
  27015. color = series.color;
  27016. }
  27017. colorIndex = series.colorIndex;
  27018. }
  27019. this.colorIndex = pick(this.options.colorIndex, colorIndex);
  27020. /**
  27021. * The point's current color.
  27022. *
  27023. * @name Highcharts.Point#color
  27024. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27025. */
  27026. this.color = pick(this.options.color, color);
  27027. };
  27028. /**
  27029. * Set a value in an object, on the property defined by key. The key
  27030. * supports nested properties using dot notation. The function modifies the
  27031. * input object and does not make a copy.
  27032. *
  27033. * @function Highcharts.Point#setNestedProperty<T>
  27034. *
  27035. * @param {T} object
  27036. * The object to set the value on.
  27037. *
  27038. * @param {*} value
  27039. * The value to set.
  27040. *
  27041. * @param {string} key
  27042. * Key to the property to set.
  27043. *
  27044. * @return {T}
  27045. * The modified object.
  27046. */
  27047. Point.prototype.setNestedProperty = function (object, value, key) {
  27048. var nestedKeys = key.split('.');
  27049. nestedKeys.reduce(function (result, key, i, arr) {
  27050. var isLastKey = arr.length - 1 === i;
  27051. result[key] = (isLastKey ?
  27052. value :
  27053. isObject(result[key], true) ?
  27054. result[key] :
  27055. {});
  27056. return result[key];
  27057. }, object);
  27058. return object;
  27059. };
  27060. /**
  27061. * Extendable method for formatting each point's tooltip line.
  27062. *
  27063. * @function Highcharts.Point#tooltipFormatter
  27064. *
  27065. * @param {string} pointFormat
  27066. * The point format.
  27067. *
  27068. * @return {string}
  27069. * A string to be concatenated in to the common tooltip text.
  27070. */
  27071. Point.prototype.tooltipFormatter = function (pointFormat) {
  27072. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27073. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27074. // Replace default point style with class name
  27075. if (series.chart.styledMode) {
  27076. pointFormat =
  27077. series.chart.tooltip.styledModeFormat(pointFormat);
  27078. }
  27079. // Loop over the point array map and replace unformatted values with
  27080. // sprintf formatting markup
  27081. (series.pointArrayMap || ['y']).forEach(function (key) {
  27082. key = '{point.' + key; // without the closing bracket
  27083. if (valuePrefix || valueSuffix) {
  27084. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27085. }
  27086. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27087. });
  27088. return format(pointFormat, {
  27089. point: this,
  27090. series: this.series
  27091. }, series.chart);
  27092. };
  27093. /**
  27094. * Update point with new options (typically x/y data) and optionally redraw
  27095. * the series.
  27096. *
  27097. * @sample highcharts/members/point-update-column/
  27098. * Update column value
  27099. * @sample highcharts/members/point-update-pie/
  27100. * Update pie slice
  27101. * @sample maps/members/point-update/
  27102. * Update map area value in Highmaps
  27103. *
  27104. * @function Highcharts.Point#update
  27105. *
  27106. * @param {Highcharts.PointOptionsType} options
  27107. * The point options. Point options are handled as described under
  27108. * the `series.type.data` item for each series type. For example
  27109. * for a line series, if options is a single number, the point will
  27110. * be given that number as the marin y value. If it is an array, it
  27111. * will be interpreted as x and y values respectively. If it is an
  27112. * object, advanced options are applied.
  27113. *
  27114. * @param {boolean} [redraw=true]
  27115. * Whether to redraw the chart after the point is updated. If doing
  27116. * more operations on the chart, it is best practice to set
  27117. * `redraw` to false and call `chart.redraw()` after.
  27118. *
  27119. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27120. * Whether to apply animation, and optionally animation
  27121. * configuration.
  27122. *
  27123. * @fires Highcharts.Point#event:update
  27124. */
  27125. Point.prototype.update = function (options, redraw, animation, runEvent) {
  27126. var point = this,
  27127. series = point.series,
  27128. graphic = point.graphic,
  27129. i,
  27130. chart = series.chart,
  27131. seriesOptions = series.options;
  27132. redraw = pick(redraw, true);
  27133. /**
  27134. * @private
  27135. */
  27136. function update() {
  27137. point.applyOptions(options);
  27138. // Update visuals, #4146
  27139. // Handle dummy graphic elements for a11y, #12718
  27140. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  27141. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  27142. if (graphic && shouldDestroyGraphic) {
  27143. point.graphic = graphic.destroy();
  27144. delete point.hasDummyGraphic;
  27145. }
  27146. if (isObject(options, true)) {
  27147. // Destroy so we can get new elements
  27148. if (graphic && graphic.element) {
  27149. // "null" is also a valid symbol
  27150. if (options &&
  27151. options.marker &&
  27152. typeof options.marker.symbol !== 'undefined') {
  27153. point.graphic = graphic.destroy();
  27154. }
  27155. }
  27156. if (options && options.dataLabels && point.dataLabel) {
  27157. point.dataLabel = point.dataLabel.destroy(); // #2468
  27158. }
  27159. if (point.connector) {
  27160. point.connector = point.connector.destroy(); // #7243
  27161. }
  27162. }
  27163. // record changes in the parallel arrays
  27164. i = point.index;
  27165. series.updateParallelArrays(point, i);
  27166. // Record the options to options.data. If the old or the new config
  27167. // is an object, use point options, otherwise use raw options
  27168. // (#4701, #4916).
  27169. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  27170. isObject(options, true)) ?
  27171. point.options :
  27172. pick(options, seriesOptions.data[i]);
  27173. // redraw
  27174. series.isDirty = series.isDirtyData = true;
  27175. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  27176. chart.isDirtyBox = true;
  27177. }
  27178. if (seriesOptions.legendType === 'point') { // #1831, #1885
  27179. chart.isDirtyLegend = true;
  27180. }
  27181. if (redraw) {
  27182. chart.redraw(animation);
  27183. }
  27184. }
  27185. // Fire the event with a default handler of doing the update
  27186. if (runEvent === false) { // When called from setData
  27187. update();
  27188. }
  27189. else {
  27190. point.firePointEvent('update', { options: options }, update);
  27191. }
  27192. };
  27193. /**
  27194. * Remove a point and optionally redraw the series and if necessary the axes
  27195. *
  27196. * @sample highcharts/plotoptions/series-point-events-remove/
  27197. * Remove point and confirm
  27198. * @sample highcharts/members/point-remove/
  27199. * Remove pie slice
  27200. * @sample maps/members/point-remove/
  27201. * Remove selected points in Highmaps
  27202. *
  27203. * @function Highcharts.Point#remove
  27204. *
  27205. * @param {boolean} [redraw=true]
  27206. * Whether to redraw the chart or wait for an explicit call. When
  27207. * doing more operations on the chart, for example running
  27208. * `point.remove()` in a loop, it is best practice to set `redraw`
  27209. * to false and call `chart.redraw()` after.
  27210. *
  27211. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  27212. * Whether to apply animation, and optionally animation
  27213. * configuration.
  27214. */
  27215. Point.prototype.remove = function (redraw, animation) {
  27216. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  27217. };
  27218. /**
  27219. * Toggle the selection status of a point.
  27220. *
  27221. * @see Highcharts.Chart#getSelectedPoints
  27222. *
  27223. * @sample highcharts/members/point-select/
  27224. * Select a point from a button
  27225. * @sample highcharts/chart/events-selection-points/
  27226. * Select a range of points through a drag selection
  27227. * @sample maps/series/data-id/
  27228. * Select a point in Highmaps
  27229. *
  27230. * @function Highcharts.Point#select
  27231. *
  27232. * @param {boolean} [selected]
  27233. * When `true`, the point is selected. When `false`, the point is
  27234. * unselected. When `null` or `undefined`, the selection state is toggled.
  27235. *
  27236. * @param {boolean} [accumulate=false]
  27237. * When `true`, the selection is added to other selected points.
  27238. * When `false`, other selected points are deselected. Internally in
  27239. * Highcharts, when
  27240. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  27241. * is `true`, selected points are accumulated on Control, Shift or Cmd
  27242. * clicking the point.
  27243. *
  27244. * @fires Highcharts.Point#event:select
  27245. * @fires Highcharts.Point#event:unselect
  27246. */
  27247. Point.prototype.select = function (selected, accumulate) {
  27248. var point = this,
  27249. series = point.series,
  27250. chart = series.chart;
  27251. selected = pick(selected, !point.selected);
  27252. this.selectedStaging = selected;
  27253. // fire the event with the default handler
  27254. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  27255. /**
  27256. * Whether the point is selected or not.
  27257. *
  27258. * @see Point#select
  27259. * @see Chart#getSelectedPoints
  27260. *
  27261. * @name Highcharts.Point#selected
  27262. * @type {boolean}
  27263. */
  27264. point.selected = point.options.selected = selected;
  27265. series.options.data[series.data.indexOf(point)] =
  27266. point.options;
  27267. point.setState(selected && 'select');
  27268. // unselect all other points unless Ctrl or Cmd + click
  27269. if (!accumulate) {
  27270. chart.getSelectedPoints().forEach(function (loopPoint) {
  27271. var loopSeries = loopPoint.series;
  27272. if (loopPoint.selected && loopPoint !== point) {
  27273. loopPoint.selected = loopPoint.options.selected =
  27274. false;
  27275. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  27276. // Programatically selecting a point should restore
  27277. // normal state, but when click happened on other
  27278. // point, set inactive state to match other points
  27279. loopPoint.setState(chart.hoverPoints &&
  27280. loopSeries.options.inactiveOtherPoints ?
  27281. 'inactive' : '');
  27282. loopPoint.firePointEvent('unselect');
  27283. }
  27284. });
  27285. }
  27286. });
  27287. delete this.selectedStaging;
  27288. };
  27289. /**
  27290. * Runs on mouse over the point. Called internally from mouse and touch
  27291. * events.
  27292. *
  27293. * @function Highcharts.Point#onMouseOver
  27294. *
  27295. * @param {Highcharts.PointerEventObject} [e]
  27296. * The event arguments.
  27297. */
  27298. Point.prototype.onMouseOver = function (e) {
  27299. var point = this,
  27300. series = point.series,
  27301. chart = series.chart,
  27302. pointer = chart.pointer;
  27303. e = e ?
  27304. pointer.normalize(e) :
  27305. // In cases where onMouseOver is called directly without an event
  27306. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  27307. pointer.runPointActions(e, point);
  27308. };
  27309. /**
  27310. * Runs on mouse out from the point. Called internally from mouse and touch
  27311. * events.
  27312. *
  27313. * @function Highcharts.Point#onMouseOut
  27314. * @fires Highcharts.Point#event:mouseOut
  27315. */
  27316. Point.prototype.onMouseOut = function () {
  27317. var point = this,
  27318. chart = point.series.chart;
  27319. point.firePointEvent('mouseOut');
  27320. if (!point.series.options.inactiveOtherPoints) {
  27321. (chart.hoverPoints || []).forEach(function (p) {
  27322. p.setState();
  27323. });
  27324. }
  27325. chart.hoverPoints = chart.hoverPoint = null;
  27326. };
  27327. /**
  27328. * Import events from the series' and point's options. Only do it on
  27329. * demand, to save processing time on hovering.
  27330. *
  27331. * @private
  27332. * @function Highcharts.Point#importEvents
  27333. */
  27334. Point.prototype.importEvents = function () {
  27335. if (!this.hasImportedEvents) {
  27336. var point_1 = this,
  27337. options = merge(point_1.series.options.point,
  27338. point_1.options),
  27339. events = options.events;
  27340. point_1.events = events;
  27341. objectEach(events, function (event, eventType) {
  27342. if (isFunction(event)) {
  27343. addEvent(point_1, eventType, event);
  27344. }
  27345. });
  27346. this.hasImportedEvents = true;
  27347. }
  27348. };
  27349. /**
  27350. * Set the point's state.
  27351. *
  27352. * @function Highcharts.Point#setState
  27353. *
  27354. * @param {Highcharts.PointStateValue|""} [state]
  27355. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  27356. * or `''` (an empty string), `'normal'` or `undefined` to set to
  27357. * normal state.
  27358. * @param {boolean} [move]
  27359. * State for animation.
  27360. *
  27361. * @fires Highcharts.Point#event:afterSetState
  27362. */
  27363. Point.prototype.setState = function (state, move) {
  27364. var point = this,
  27365. series = point.series,
  27366. previousState = point.state,
  27367. stateOptions = (series.options.states[state || 'normal'] ||
  27368. {}),
  27369. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  27370. series.options.marker),
  27371. normalDisabled = (markerOptions && markerOptions.enabled === false),
  27372. markerStateOptions = ((markerOptions &&
  27373. markerOptions.states &&
  27374. markerOptions.states[state || 'normal']) || {}),
  27375. stateDisabled = markerStateOptions.enabled === false,
  27376. stateMarkerGraphic = series.stateMarkerGraphic,
  27377. pointMarker = point.marker || {},
  27378. chart = series.chart,
  27379. halo = series.halo,
  27380. haloOptions,
  27381. markerAttribs,
  27382. pointAttribs,
  27383. pointAttribsAnimation,
  27384. hasMarkers = (markerOptions && series.markerAttribs),
  27385. newSymbol;
  27386. state = state || ''; // empty string
  27387. if (
  27388. // already has this state
  27389. (state === point.state && !move) ||
  27390. // selected points don't respond to hover
  27391. (point.selected && state !== 'select') ||
  27392. // series' state options is disabled
  27393. (stateOptions.enabled === false) ||
  27394. // general point marker's state options is disabled
  27395. (state && (stateDisabled ||
  27396. (normalDisabled &&
  27397. markerStateOptions.enabled === false))) ||
  27398. // individual point marker's state options is disabled
  27399. (state &&
  27400. pointMarker.states &&
  27401. pointMarker.states[state] &&
  27402. pointMarker.states[state].enabled === false) // #1610
  27403. ) {
  27404. return;
  27405. }
  27406. point.state = state;
  27407. if (hasMarkers) {
  27408. markerAttribs = series.markerAttribs(point, state);
  27409. }
  27410. // Apply hover styles to the existing point
  27411. // Prevent from dummy null points (#14966)
  27412. if (point.graphic && !point.hasDummyGraphic) {
  27413. if (previousState) {
  27414. point.graphic.removeClass('highcharts-point-' + previousState);
  27415. }
  27416. if (state) {
  27417. point.graphic.addClass('highcharts-point-' + state);
  27418. }
  27419. if (!chart.styledMode) {
  27420. pointAttribs = series.pointAttribs(point, state);
  27421. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  27422. // Some inactive points (e.g. slices in pie) should apply
  27423. // oppacity also for it's labels
  27424. if (series.options.inactiveOtherPoints && isNumber(pointAttribs.opacity)) {
  27425. (point.dataLabels || []).forEach(function (label) {
  27426. if (label) {
  27427. label.animate({
  27428. opacity: pointAttribs.opacity
  27429. }, pointAttribsAnimation);
  27430. }
  27431. });
  27432. if (point.connector) {
  27433. point.connector.animate({
  27434. opacity: pointAttribs.opacity
  27435. }, pointAttribsAnimation);
  27436. }
  27437. }
  27438. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  27439. }
  27440. if (markerAttribs) {
  27441. point.graphic.animate(markerAttribs, pick(
  27442. // Turn off globally:
  27443. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  27444. }
  27445. // Zooming in from a range with no markers to a range with markers
  27446. if (stateMarkerGraphic) {
  27447. stateMarkerGraphic.hide();
  27448. }
  27449. }
  27450. else {
  27451. // if a graphic is not applied to each point in the normal state,
  27452. // create a shared graphic for the hover state
  27453. if (state && markerStateOptions) {
  27454. newSymbol = pointMarker.symbol || series.symbol;
  27455. // If the point has another symbol than the previous one, throw
  27456. // away the state marker graphic and force a new one (#1459)
  27457. if (stateMarkerGraphic &&
  27458. stateMarkerGraphic.currentSymbol !== newSymbol) {
  27459. stateMarkerGraphic = stateMarkerGraphic.destroy();
  27460. }
  27461. // Add a new state marker graphic
  27462. if (markerAttribs) {
  27463. if (!stateMarkerGraphic) {
  27464. if (newSymbol) {
  27465. series.stateMarkerGraphic = stateMarkerGraphic =
  27466. chart.renderer
  27467. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  27468. .add(series.markerGroup);
  27469. stateMarkerGraphic.currentSymbol = newSymbol;
  27470. }
  27471. // Move the existing graphic
  27472. }
  27473. else {
  27474. stateMarkerGraphic[move ? 'animate' : 'attr']({
  27475. x: markerAttribs.x,
  27476. y: markerAttribs.y
  27477. });
  27478. }
  27479. }
  27480. if (!chart.styledMode && stateMarkerGraphic) {
  27481. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  27482. }
  27483. }
  27484. if (stateMarkerGraphic) {
  27485. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  27486. stateMarkerGraphic.element.point = point; // #4310
  27487. }
  27488. }
  27489. // Show me your halo
  27490. haloOptions = stateOptions.halo;
  27491. var markerGraphic = (point.graphic || stateMarkerGraphic);
  27492. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  27493. if (haloOptions &&
  27494. haloOptions.size &&
  27495. markerGraphic &&
  27496. markerVisibility !== 'hidden' &&
  27497. !point.isCluster) {
  27498. if (!halo) {
  27499. series.halo = halo = chart.renderer.path()
  27500. // #5818, #5903, #6705
  27501. .add(markerGraphic.parentGroup);
  27502. }
  27503. halo.show()[move ? 'animate' : 'attr']({
  27504. d: point.haloPath(haloOptions.size)
  27505. });
  27506. halo.attr({
  27507. 'class': 'highcharts-halo highcharts-color-' +
  27508. pick(point.colorIndex, series.colorIndex) +
  27509. (point.className ? ' ' + point.className : ''),
  27510. 'visibility': markerVisibility,
  27511. 'zIndex': -1 // #4929, #8276
  27512. });
  27513. halo.point = point; // #6055
  27514. if (!chart.styledMode) {
  27515. halo.attr(extend({
  27516. 'fill': point.color || series.color,
  27517. 'fill-opacity': haloOptions.opacity
  27518. }, AST.filterUserAttributes(haloOptions.attributes || {})));
  27519. }
  27520. }
  27521. else if (halo && halo.point && halo.point.haloPath) {
  27522. // Animate back to 0 on the current halo point (#6055)
  27523. halo.animate({ d: halo.point.haloPath(0) }, null,
  27524. // Hide after unhovering. The `complete` callback runs in the
  27525. // halo's context (#7681).
  27526. halo.hide);
  27527. }
  27528. fireEvent(point, 'afterSetState', { state: state });
  27529. };
  27530. /**
  27531. * Get the path definition for the halo, which is usually a shadow-like
  27532. * circle around the currently hovered point.
  27533. *
  27534. * @function Highcharts.Point#haloPath
  27535. *
  27536. * @param {number} size
  27537. * The radius of the circular halo.
  27538. *
  27539. * @return {Highcharts.SVGPathArray}
  27540. * The path definition.
  27541. */
  27542. Point.prototype.haloPath = function (size) {
  27543. var series = this.series,
  27544. chart = series.chart;
  27545. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  27546. };
  27547. return Point;
  27548. }());
  27549. H.Point = Point;
  27550. return Point;
  27551. });
  27552. _registerModule(_modules, 'Core/Legend.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, F, H, Point, U) {
  27553. /* *
  27554. *
  27555. * (c) 2010-2021 Torstein Honsi
  27556. *
  27557. * License: www.highcharts.com/license
  27558. *
  27559. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27560. *
  27561. * */
  27562. var animObject = A.animObject,
  27563. setAnimation = A.setAnimation;
  27564. var format = F.format;
  27565. var isFirefox = H.isFirefox,
  27566. marginNames = H.marginNames,
  27567. win = H.win;
  27568. var addEvent = U.addEvent,
  27569. createElement = U.createElement,
  27570. css = U.css,
  27571. defined = U.defined,
  27572. discardElement = U.discardElement,
  27573. find = U.find,
  27574. fireEvent = U.fireEvent,
  27575. isNumber = U.isNumber,
  27576. merge = U.merge,
  27577. pick = U.pick,
  27578. relativeLength = U.relativeLength,
  27579. stableSort = U.stableSort,
  27580. syncTimeout = U.syncTimeout,
  27581. wrap = U.wrap;
  27582. /**
  27583. * Gets fired when the legend item belonging to a point is clicked. The default
  27584. * action is to toggle the visibility of the point. This can be prevented by
  27585. * returning `false` or calling `event.preventDefault()`.
  27586. *
  27587. * @callback Highcharts.PointLegendItemClickCallbackFunction
  27588. *
  27589. * @param {Highcharts.Point} this
  27590. * The point on which the event occured.
  27591. *
  27592. * @param {Highcharts.PointLegendItemClickEventObject} event
  27593. * The event that occured.
  27594. */
  27595. /**
  27596. * Information about the legend click event.
  27597. *
  27598. * @interface Highcharts.PointLegendItemClickEventObject
  27599. */ /**
  27600. * Related browser event.
  27601. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  27602. * @type {Highcharts.PointerEvent}
  27603. */ /**
  27604. * Prevent the default action of toggle the visibility of the point.
  27605. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  27606. * @type {Function}
  27607. */ /**
  27608. * Related point.
  27609. * @name Highcharts.PointLegendItemClickEventObject#target
  27610. * @type {Highcharts.Point}
  27611. */ /**
  27612. * Event type.
  27613. * @name Highcharts.PointLegendItemClickEventObject#type
  27614. * @type {"legendItemClick"}
  27615. */
  27616. /**
  27617. * Gets fired when the legend item belonging to a series is clicked. The default
  27618. * action is to toggle the visibility of the series. This can be prevented by
  27619. * returning `false` or calling `event.preventDefault()`.
  27620. *
  27621. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  27622. *
  27623. * @param {Highcharts.Series} this
  27624. * The series where the event occured.
  27625. *
  27626. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  27627. * The event that occured.
  27628. */
  27629. /**
  27630. * Information about the legend click event.
  27631. *
  27632. * @interface Highcharts.SeriesLegendItemClickEventObject
  27633. */ /**
  27634. * Related browser event.
  27635. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  27636. * @type {Highcharts.PointerEvent}
  27637. */ /**
  27638. * Prevent the default action of toggle the visibility of the series.
  27639. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  27640. * @type {Function}
  27641. */ /**
  27642. * Related series.
  27643. * @name Highcharts.SeriesLegendItemClickEventObject#target
  27644. * @type {Highcharts.Series}
  27645. */ /**
  27646. * Event type.
  27647. * @name Highcharts.SeriesLegendItemClickEventObject#type
  27648. * @type {"legendItemClick"}
  27649. */
  27650. /* eslint-disable no-invalid-this, valid-jsdoc */
  27651. /**
  27652. * The overview of the chart's series. The legend object is instanciated
  27653. * internally in the chart constructor, and is available from the `chart.legend`
  27654. * property. Each chart has only one legend.
  27655. *
  27656. * @class
  27657. * @name Highcharts.Legend
  27658. *
  27659. * @param {Highcharts.Chart} chart
  27660. * The chart instance.
  27661. *
  27662. * @param {Highcharts.LegendOptions} options
  27663. * Legend options.
  27664. */
  27665. var Legend = /** @class */ (function () {
  27666. /* *
  27667. *
  27668. * Constructors
  27669. *
  27670. * */
  27671. function Legend(chart, options) {
  27672. /* *
  27673. *
  27674. * Properties
  27675. *
  27676. * */
  27677. this.allItems = [];
  27678. this.box = void 0;
  27679. this.contentGroup = void 0;
  27680. this.display = false;
  27681. this.group = void 0;
  27682. this.initialItemY = 0;
  27683. this.itemHeight = 0;
  27684. this.itemMarginBottom = 0;
  27685. this.itemMarginTop = 0;
  27686. this.itemX = 0;
  27687. this.itemY = 0;
  27688. this.lastItemY = 0;
  27689. this.lastLineHeight = 0;
  27690. this.legendHeight = 0;
  27691. this.legendWidth = 0;
  27692. this.maxItemWidth = 0;
  27693. this.maxLegendWidth = 0;
  27694. this.offsetWidth = 0;
  27695. this.options = {};
  27696. this.padding = 0;
  27697. this.pages = [];
  27698. this.proximate = false;
  27699. this.scrollGroup = void 0;
  27700. this.symbolHeight = 0;
  27701. this.symbolWidth = 0;
  27702. this.titleHeight = 0;
  27703. this.totalItemWidth = 0;
  27704. this.widthOption = 0;
  27705. this.chart = chart;
  27706. this.init(chart, options);
  27707. }
  27708. /* *
  27709. *
  27710. * Functions
  27711. *
  27712. * */
  27713. /**
  27714. * Initialize the legend.
  27715. *
  27716. * @private
  27717. * @function Highcharts.Legend#init
  27718. *
  27719. * @param {Highcharts.Chart} chart
  27720. * The chart instance.
  27721. *
  27722. * @param {Highcharts.LegendOptions} options
  27723. * Legend options.
  27724. */
  27725. Legend.prototype.init = function (chart, options) {
  27726. /**
  27727. * Chart of this legend.
  27728. *
  27729. * @readonly
  27730. * @name Highcharts.Legend#chart
  27731. * @type {Highcharts.Chart}
  27732. */
  27733. this.chart = chart;
  27734. this.setOptions(options);
  27735. if (options.enabled) {
  27736. // Render it
  27737. this.render();
  27738. // move checkboxes
  27739. addEvent(this.chart, 'endResize', function () {
  27740. this.legend.positionCheckboxes();
  27741. });
  27742. if (this.proximate) {
  27743. this.unchartrender = addEvent(this.chart, 'render', function () {
  27744. this.legend.proximatePositions();
  27745. this.legend.positionItems();
  27746. });
  27747. }
  27748. else if (this.unchartrender) {
  27749. this.unchartrender();
  27750. }
  27751. }
  27752. };
  27753. /**
  27754. * @private
  27755. * @function Highcharts.Legend#setOptions
  27756. * @param {Highcharts.LegendOptions} options
  27757. */
  27758. Legend.prototype.setOptions = function (options) {
  27759. var padding = pick(options.padding, 8);
  27760. /**
  27761. * Legend options.
  27762. *
  27763. * @readonly
  27764. * @name Highcharts.Legend#options
  27765. * @type {Highcharts.LegendOptions}
  27766. */
  27767. this.options = options;
  27768. if (!this.chart.styledMode) {
  27769. this.itemStyle = options.itemStyle;
  27770. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  27771. }
  27772. this.itemMarginTop = options.itemMarginTop || 0;
  27773. this.itemMarginBottom = options.itemMarginBottom || 0;
  27774. this.padding = padding;
  27775. this.initialItemY = padding - 5; // 5 is pixels above the text
  27776. this.symbolWidth = pick(options.symbolWidth, 16);
  27777. this.pages = [];
  27778. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  27779. this.baseline = void 0; // #12705: baseline has to be reset on every update
  27780. };
  27781. /**
  27782. * Update the legend with new options. Equivalent to running `chart.update`
  27783. * with a legend configuration option.
  27784. *
  27785. * @sample highcharts/legend/legend-update/
  27786. * Legend update
  27787. *
  27788. * @function Highcharts.Legend#update
  27789. *
  27790. * @param {Highcharts.LegendOptions} options
  27791. * Legend options.
  27792. *
  27793. * @param {boolean} [redraw=true]
  27794. * Whether to redraw the chart after the axis is altered. If doing more
  27795. * operations on the chart, it is a good idea to set redraw to false and
  27796. * call {@link Chart#redraw} after. Whether to redraw the chart.
  27797. *
  27798. * @fires Highcharts.Legends#event:afterUpdate
  27799. */
  27800. Legend.prototype.update = function (options, redraw) {
  27801. var chart = this.chart;
  27802. this.setOptions(merge(true, this.options, options));
  27803. this.destroy();
  27804. chart.isDirtyLegend = chart.isDirtyBox = true;
  27805. if (pick(redraw, true)) {
  27806. chart.redraw();
  27807. }
  27808. fireEvent(this, 'afterUpdate');
  27809. };
  27810. /**
  27811. * Set the colors for the legend item.
  27812. *
  27813. * @private
  27814. * @function Highcharts.Legend#colorizeItem
  27815. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27816. * A Series or Point instance
  27817. * @param {boolean} [visible=false]
  27818. * Dimmed or colored
  27819. *
  27820. * @todo
  27821. * Make events official: Fires the event `afterColorizeItem`.
  27822. */
  27823. Legend.prototype.colorizeItem = function (item, visible) {
  27824. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  27825. if (!this.chart.styledMode) {
  27826. var legend = this,
  27827. options = legend.options,
  27828. legendItem = item.legendItem,
  27829. legendLine = item.legendLine,
  27830. legendSymbol = item.legendSymbol,
  27831. hiddenColor = legend.itemHiddenStyle.color,
  27832. textColor = visible ?
  27833. options.itemStyle.color :
  27834. hiddenColor,
  27835. symbolColor = visible ?
  27836. (item.color || hiddenColor) :
  27837. hiddenColor,
  27838. markerOptions = item.options && item.options.marker,
  27839. symbolAttr = { fill: symbolColor };
  27840. if (legendItem) {
  27841. legendItem.css({
  27842. fill: textColor,
  27843. color: textColor // #1553, oldIE
  27844. });
  27845. }
  27846. if (legendLine) {
  27847. legendLine.attr({ stroke: symbolColor });
  27848. }
  27849. if (legendSymbol) {
  27850. // Apply marker options
  27851. if (markerOptions && legendSymbol.isMarker) { // #585
  27852. symbolAttr = item.pointAttribs();
  27853. if (!visible) {
  27854. // #6769
  27855. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  27856. }
  27857. }
  27858. legendSymbol.attr(symbolAttr);
  27859. }
  27860. }
  27861. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  27862. };
  27863. /**
  27864. * @private
  27865. * @function Highcharts.Legend#positionItems
  27866. */
  27867. Legend.prototype.positionItems = function () {
  27868. // Now that the legend width and height are established, put the items
  27869. // in the final position
  27870. this.allItems.forEach(this.positionItem, this);
  27871. if (!this.chart.isResizing) {
  27872. this.positionCheckboxes();
  27873. }
  27874. };
  27875. /**
  27876. * Position the legend item.
  27877. *
  27878. * @private
  27879. * @function Highcharts.Legend#positionItem
  27880. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27881. * The item to position
  27882. */
  27883. Legend.prototype.positionItem = function (item) {
  27884. var _this = this;
  27885. var legend = this,
  27886. options = legend.options,
  27887. symbolPadding = options.symbolPadding,
  27888. ltr = !options.rtl,
  27889. legendItemPos = item._legendItemPos,
  27890. itemX = legendItemPos[0],
  27891. itemY = legendItemPos[1],
  27892. checkbox = item.checkbox,
  27893. legendGroup = item.legendGroup;
  27894. if (legendGroup && legendGroup.element) {
  27895. var attribs = {
  27896. translateX: ltr ?
  27897. itemX :
  27898. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  27899. translateY: itemY
  27900. };
  27901. var complete = function () {
  27902. fireEvent(_this, 'afterPositionItem', { item: item });
  27903. };
  27904. if (defined(legendGroup.translateY)) {
  27905. legendGroup.animate(attribs, void 0, complete);
  27906. }
  27907. else {
  27908. legendGroup.attr(attribs);
  27909. complete();
  27910. }
  27911. }
  27912. if (checkbox) {
  27913. checkbox.x = itemX;
  27914. checkbox.y = itemY;
  27915. }
  27916. };
  27917. /**
  27918. * Destroy a single legend item, used internally on removing series items.
  27919. *
  27920. * @private
  27921. * @function Highcharts.Legend#destroyItem
  27922. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27923. * The item to remove
  27924. */
  27925. Legend.prototype.destroyItem = function (item) {
  27926. var checkbox = item.checkbox;
  27927. // destroy SVG elements
  27928. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  27929. if (item[key]) {
  27930. item[key] = item[key].destroy();
  27931. }
  27932. });
  27933. if (checkbox) {
  27934. discardElement(item.checkbox);
  27935. }
  27936. };
  27937. /**
  27938. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  27939. * must be called after destruction.
  27940. *
  27941. * @private
  27942. * @function Highcharts.Legend#destroy
  27943. */
  27944. Legend.prototype.destroy = function () {
  27945. /**
  27946. * @private
  27947. * @param {string} key
  27948. * @return {void}
  27949. */
  27950. function destroyItems(key) {
  27951. if (this[key]) {
  27952. this[key] = this[key].destroy();
  27953. }
  27954. }
  27955. // Destroy items
  27956. this.getAllItems().forEach(function (item) {
  27957. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  27958. });
  27959. // Destroy legend elements
  27960. [
  27961. 'clipRect',
  27962. 'up',
  27963. 'down',
  27964. 'pager',
  27965. 'nav',
  27966. 'box',
  27967. 'title',
  27968. 'group'
  27969. ].forEach(destroyItems, this);
  27970. this.display = null; // Reset in .render on update.
  27971. };
  27972. /**
  27973. * Position the checkboxes after the width is determined.
  27974. *
  27975. * @private
  27976. * @function Highcharts.Legend#positionCheckboxes
  27977. */
  27978. Legend.prototype.positionCheckboxes = function () {
  27979. var alignAttr = this.group && this.group.alignAttr,
  27980. translateY,
  27981. clipHeight = this.clipHeight || this.legendHeight,
  27982. titleHeight = this.titleHeight;
  27983. if (alignAttr) {
  27984. translateY = alignAttr.translateY;
  27985. this.allItems.forEach(function (item) {
  27986. var checkbox = item.checkbox,
  27987. top;
  27988. if (checkbox) {
  27989. top = translateY + titleHeight + checkbox.y +
  27990. (this.scrollOffset || 0) + 3;
  27991. css(checkbox, {
  27992. left: (alignAttr.translateX + item.checkboxOffset +
  27993. checkbox.x - 20) + 'px',
  27994. top: top + 'px',
  27995. display: this.proximate || (top > translateY - 6 &&
  27996. top < translateY + clipHeight - 6) ?
  27997. '' :
  27998. 'none'
  27999. });
  28000. }
  28001. }, this);
  28002. }
  28003. };
  28004. /**
  28005. * Render the legend title on top of the legend.
  28006. *
  28007. * @private
  28008. * @function Highcharts.Legend#renderTitle
  28009. */
  28010. Legend.prototype.renderTitle = function () {
  28011. var options = this.options,
  28012. padding = this.padding,
  28013. titleOptions = options.title,
  28014. titleHeight = 0,
  28015. bBox;
  28016. if (titleOptions.text) {
  28017. if (!this.title) {
  28018. /**
  28019. * SVG element of the legend title.
  28020. *
  28021. * @readonly
  28022. * @name Highcharts.Legend#title
  28023. * @type {Highcharts.SVGElement}
  28024. */
  28025. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  28026. .attr({ zIndex: 1 });
  28027. if (!this.chart.styledMode) {
  28028. this.title.css(titleOptions.style);
  28029. }
  28030. this.title.add(this.group);
  28031. }
  28032. // Set the max title width (#7253)
  28033. if (!titleOptions.width) {
  28034. this.title.css({
  28035. width: this.maxLegendWidth + 'px'
  28036. });
  28037. }
  28038. bBox = this.title.getBBox();
  28039. titleHeight = bBox.height;
  28040. this.offsetWidth = bBox.width; // #1717
  28041. this.contentGroup.attr({ translateY: titleHeight });
  28042. }
  28043. this.titleHeight = titleHeight;
  28044. };
  28045. /**
  28046. * Set the legend item text.
  28047. *
  28048. * @function Highcharts.Legend#setText
  28049. * @param {Highcharts.Point|Highcharts.Series} item
  28050. * The item for which to update the text in the legend.
  28051. */
  28052. Legend.prototype.setText = function (item) {
  28053. var options = this.options;
  28054. item.legendItem.attr({
  28055. text: options.labelFormat ?
  28056. format(options.labelFormat, item, this.chart) :
  28057. options.labelFormatter.call(item)
  28058. });
  28059. };
  28060. /**
  28061. * Render a single specific legend item. Called internally from the `render`
  28062. * function.
  28063. *
  28064. * @private
  28065. * @function Highcharts.Legend#renderItem
  28066. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28067. * The item to render.
  28068. */
  28069. Legend.prototype.renderItem = function (item) {
  28070. var legend = this,
  28071. chart = legend.chart,
  28072. renderer = chart.renderer,
  28073. options = legend.options,
  28074. horizontal = options.layout === 'horizontal',
  28075. symbolWidth = legend.symbolWidth,
  28076. symbolPadding = options.symbolPadding || 0,
  28077. itemStyle = legend.itemStyle,
  28078. itemHiddenStyle = legend.itemHiddenStyle,
  28079. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28080. ltr = !options.rtl,
  28081. bBox,
  28082. li = item.legendItem,
  28083. isSeries = !item.series,
  28084. series = !isSeries && item.series.drawLegendSymbol ?
  28085. item.series :
  28086. item,
  28087. seriesOptions = series.options,
  28088. showCheckbox = legend.createCheckboxForItem &&
  28089. seriesOptions &&
  28090. seriesOptions.showCheckbox,
  28091. // full width minus text width
  28092. itemExtraWidth = symbolWidth + symbolPadding +
  28093. itemDistance + (showCheckbox ? 20 : 0),
  28094. useHTML = options.useHTML,
  28095. itemClassName = item.options.className;
  28096. if (!li) { // generate it once, later move it
  28097. // Generate the group box, a group to hold the symbol and text. Text
  28098. // is to be appended in Legend class.
  28099. item.legendGroup = renderer
  28100. .g('legend-item')
  28101. .addClass('highcharts-' + series.type + '-series ' +
  28102. 'highcharts-color-' + item.colorIndex +
  28103. (itemClassName ? ' ' + itemClassName : '') +
  28104. (isSeries ?
  28105. ' highcharts-series-' + item.index :
  28106. ''))
  28107. .attr({ zIndex: 1 })
  28108. .add(legend.scrollGroup);
  28109. // Generate the list item text and add it to the group
  28110. item.legendItem = li = renderer.text('', ltr ?
  28111. symbolWidth + symbolPadding :
  28112. -symbolPadding, legend.baseline || 0, useHTML);
  28113. if (!chart.styledMode) {
  28114. // merge to prevent modifying original (#1021)
  28115. li.css(merge(item.visible ?
  28116. itemStyle :
  28117. itemHiddenStyle));
  28118. }
  28119. li
  28120. .attr({
  28121. align: ltr ? 'left' : 'right',
  28122. zIndex: 2
  28123. })
  28124. .add(item.legendGroup);
  28125. // Get the baseline for the first item - the font size is equal for
  28126. // all
  28127. if (!legend.baseline) {
  28128. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  28129. legend.baseline =
  28130. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  28131. li.attr('y', legend.baseline);
  28132. legend.symbolHeight =
  28133. options.symbolHeight || legend.fontMetrics.f;
  28134. if (options.squareSymbol) {
  28135. legend.symbolWidth = pick(options.symbolWidth, Math.max(legend.symbolHeight, 16));
  28136. itemExtraWidth = legend.symbolWidth + symbolPadding +
  28137. itemDistance + (showCheckbox ? 20 : 0);
  28138. if (ltr) {
  28139. li.attr('x', legend.symbolWidth + symbolPadding);
  28140. }
  28141. }
  28142. }
  28143. // Draw the legend symbol inside the group box
  28144. series.drawLegendSymbol(legend, item);
  28145. if (legend.setItemEvents) {
  28146. legend.setItemEvents(item, li, useHTML);
  28147. }
  28148. }
  28149. // Add the HTML checkbox on top
  28150. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  28151. legend.createCheckboxForItem(item);
  28152. }
  28153. // Colorize the items
  28154. legend.colorizeItem(item, item.visible);
  28155. // Take care of max width and text overflow (#6659)
  28156. if (chart.styledMode || !itemStyle.width) {
  28157. li.css({
  28158. width: ((options.itemWidth ||
  28159. legend.widthOption ||
  28160. chart.spacingBox.width) - itemExtraWidth) + 'px'
  28161. });
  28162. }
  28163. // Always update the text
  28164. legend.setText(item);
  28165. // calculate the positions for the next line
  28166. bBox = li.getBBox();
  28167. item.itemWidth = item.checkboxOffset =
  28168. options.itemWidth ||
  28169. item.legendItemWidth ||
  28170. bBox.width + itemExtraWidth;
  28171. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  28172. legend.totalItemWidth += item.itemWidth;
  28173. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  28174. };
  28175. /**
  28176. * Get the position of the item in the layout. We now know the
  28177. * maxItemWidth from the previous loop.
  28178. *
  28179. * @private
  28180. * @function Highcharts.Legend#layoutItem
  28181. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28182. */
  28183. Legend.prototype.layoutItem = function (item) {
  28184. var options = this.options,
  28185. padding = this.padding,
  28186. horizontal = options.layout === 'horizontal',
  28187. itemHeight = item.itemHeight,
  28188. itemMarginBottom = this.itemMarginBottom,
  28189. itemMarginTop = this.itemMarginTop,
  28190. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28191. maxLegendWidth = this.maxLegendWidth,
  28192. itemWidth = (options.alignColumns &&
  28193. this.totalItemWidth > maxLegendWidth) ?
  28194. this.maxItemWidth :
  28195. item.itemWidth;
  28196. // If the item exceeds the width, start a new line
  28197. if (horizontal &&
  28198. this.itemX - padding + itemWidth > maxLegendWidth) {
  28199. this.itemX = padding;
  28200. if (this.lastLineHeight) { // Not for the first line (#10167)
  28201. this.itemY += (itemMarginTop +
  28202. this.lastLineHeight +
  28203. itemMarginBottom);
  28204. }
  28205. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  28206. }
  28207. // Set the edge positions
  28208. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  28209. this.lastLineHeight = Math.max(// #915
  28210. itemHeight, this.lastLineHeight);
  28211. // cache the position of the newly generated or reordered items
  28212. item._legendItemPos = [this.itemX, this.itemY];
  28213. // advance
  28214. if (horizontal) {
  28215. this.itemX += itemWidth;
  28216. }
  28217. else {
  28218. this.itemY +=
  28219. itemMarginTop + itemHeight + itemMarginBottom;
  28220. this.lastLineHeight = itemHeight;
  28221. }
  28222. // the width of the widest item
  28223. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  28224. // decrease by itemDistance only when no checkbox #4853
  28225. 0 :
  28226. itemDistance) : itemWidth) + padding, this.offsetWidth);
  28227. };
  28228. /**
  28229. * Get all items, which is one item per series for most series and one
  28230. * item per point for pie series and its derivatives. Fires the event
  28231. * `afterGetAllItems`.
  28232. *
  28233. * @private
  28234. * @function Highcharts.Legend#getAllItems
  28235. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  28236. * The current items in the legend.
  28237. * @fires Highcharts.Legend#event:afterGetAllItems
  28238. */
  28239. Legend.prototype.getAllItems = function () {
  28240. var allItems = [];
  28241. this.chart.series.forEach(function (series) {
  28242. var seriesOptions = series && series.options;
  28243. // Handle showInLegend. If the series is linked to another series,
  28244. // defaults to false.
  28245. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  28246. // Use points or series for the legend item depending on
  28247. // legendType
  28248. allItems = allItems.concat(series.legendItems ||
  28249. (seriesOptions.legendType === 'point' ?
  28250. series.data :
  28251. series));
  28252. }
  28253. });
  28254. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  28255. return allItems;
  28256. };
  28257. /**
  28258. * Get a short, three letter string reflecting the alignment and layout.
  28259. *
  28260. * @private
  28261. * @function Highcharts.Legend#getAlignment
  28262. * @return {string}
  28263. * The alignment, empty string if floating
  28264. */
  28265. Legend.prototype.getAlignment = function () {
  28266. var options = this.options;
  28267. // Use the first letter of each alignment option in order to detect
  28268. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  28269. if (this.proximate) {
  28270. return options.align.charAt(0) + 'tv';
  28271. }
  28272. return options.floating ? '' : (options.align.charAt(0) +
  28273. options.verticalAlign.charAt(0) +
  28274. options.layout.charAt(0));
  28275. };
  28276. /**
  28277. * Adjust the chart margins by reserving space for the legend on only one
  28278. * side of the chart. If the position is set to a corner, top or bottom is
  28279. * reserved for horizontal legends and left or right for vertical ones.
  28280. *
  28281. * @private
  28282. * @function Highcharts.Legend#adjustMargins
  28283. * @param {Array<number>} margin
  28284. * @param {Array<number>} spacing
  28285. */
  28286. Legend.prototype.adjustMargins = function (margin, spacing) {
  28287. var chart = this.chart,
  28288. options = this.options,
  28289. alignment = this.getAlignment();
  28290. if (alignment) {
  28291. ([
  28292. /(lth|ct|rth)/,
  28293. /(rtv|rm|rbv)/,
  28294. /(rbh|cb|lbh)/,
  28295. /(lbv|lm|ltv)/
  28296. ]).forEach(function (alignments, side) {
  28297. if (alignments.test(alignment) && !defined(margin[side])) {
  28298. // Now we have detected on which side of the chart we should
  28299. // reserve space for the legend
  28300. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  28301. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  28302. pick(options.margin, 12) +
  28303. spacing[side] +
  28304. (chart.titleOffset[side] || 0)));
  28305. }
  28306. });
  28307. }
  28308. };
  28309. /**
  28310. * @private
  28311. * @function Highcharts.Legend#proximatePositions
  28312. */
  28313. Legend.prototype.proximatePositions = function () {
  28314. var chart = this.chart,
  28315. boxes = [],
  28316. alignLeft = this.options.align === 'left';
  28317. this.allItems.forEach(function (item) {
  28318. var lastPoint,
  28319. height,
  28320. useFirstPoint = alignLeft,
  28321. target,
  28322. top;
  28323. if (item.yAxis) {
  28324. if (item.xAxis.options.reversed) {
  28325. useFirstPoint = !useFirstPoint;
  28326. }
  28327. if (item.points) {
  28328. lastPoint = find(useFirstPoint ?
  28329. item.points :
  28330. item.points.slice(0).reverse(), function (item) {
  28331. return isNumber(item.plotY);
  28332. });
  28333. }
  28334. height = this.itemMarginTop +
  28335. item.legendItem.getBBox().height +
  28336. this.itemMarginBottom;
  28337. top = item.yAxis.top - chart.plotTop;
  28338. if (item.visible) {
  28339. target = lastPoint ?
  28340. lastPoint.plotY :
  28341. item.yAxis.height;
  28342. target += top - 0.3 * height;
  28343. }
  28344. else {
  28345. target = top + item.yAxis.height;
  28346. }
  28347. boxes.push({
  28348. target: target,
  28349. size: height,
  28350. item: item
  28351. });
  28352. }
  28353. }, this);
  28354. H.distribute(boxes, chart.plotHeight);
  28355. boxes.forEach(function (box) {
  28356. box.item._legendItemPos[1] =
  28357. chart.plotTop - chart.spacing[0] + box.pos;
  28358. });
  28359. };
  28360. /**
  28361. * Render the legend. This method can be called both before and after
  28362. * `chart.render`. If called after, it will only rearrange items instead
  28363. * of creating new ones. Called internally on initial render and after
  28364. * redraws.
  28365. *
  28366. * @private
  28367. * @function Highcharts.Legend#render
  28368. */
  28369. Legend.prototype.render = function () {
  28370. var legend = this,
  28371. chart = legend.chart,
  28372. renderer = chart.renderer,
  28373. legendGroup = legend.group,
  28374. allItems,
  28375. display,
  28376. legendWidth,
  28377. legendHeight,
  28378. box = legend.box,
  28379. options = legend.options,
  28380. padding = legend.padding,
  28381. allowedWidth;
  28382. legend.itemX = padding;
  28383. legend.itemY = legend.initialItemY;
  28384. legend.offsetWidth = 0;
  28385. legend.lastItemY = 0;
  28386. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  28387. // Compute how wide the legend is allowed to be
  28388. allowedWidth =
  28389. chart.spacingBox.width - 2 * padding - options.x;
  28390. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  28391. allowedWidth /= 2;
  28392. }
  28393. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  28394. if (!legendGroup) {
  28395. /**
  28396. * SVG group of the legend.
  28397. *
  28398. * @readonly
  28399. * @name Highcharts.Legend#group
  28400. * @type {Highcharts.SVGElement}
  28401. */
  28402. legend.group = legendGroup = renderer.g('legend')
  28403. .attr({ zIndex: 7 })
  28404. .add();
  28405. legend.contentGroup = renderer.g()
  28406. .attr({ zIndex: 1 }) // above background
  28407. .add(legendGroup);
  28408. legend.scrollGroup = renderer.g()
  28409. .add(legend.contentGroup);
  28410. }
  28411. legend.renderTitle();
  28412. // add each series or point
  28413. allItems = legend.getAllItems();
  28414. // sort by legendIndex
  28415. stableSort(allItems, function (a, b) {
  28416. return ((a.options && a.options.legendIndex) || 0) -
  28417. ((b.options && b.options.legendIndex) || 0);
  28418. });
  28419. // reversed legend
  28420. if (options.reversed) {
  28421. allItems.reverse();
  28422. }
  28423. /**
  28424. * All items for the legend, which is an array of series for most series
  28425. * and an array of points for pie series and its derivatives.
  28426. *
  28427. * @readonly
  28428. * @name Highcharts.Legend#allItems
  28429. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  28430. */
  28431. legend.allItems = allItems;
  28432. legend.display = display = !!allItems.length;
  28433. // Render the items. First we run a loop to set the text and properties
  28434. // and read all the bounding boxes. The next loop computes the item
  28435. // positions based on the bounding boxes.
  28436. legend.lastLineHeight = 0;
  28437. legend.maxItemWidth = 0;
  28438. legend.totalItemWidth = 0;
  28439. legend.itemHeight = 0;
  28440. allItems.forEach(legend.renderItem, legend);
  28441. allItems.forEach(legend.layoutItem, legend);
  28442. // Get the box
  28443. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  28444. legendHeight = legend.lastItemY + legend.lastLineHeight +
  28445. legend.titleHeight;
  28446. legendHeight = legend.handleOverflow(legendHeight);
  28447. legendHeight += padding;
  28448. // Draw the border and/or background
  28449. if (!box) {
  28450. /**
  28451. * SVG element of the legend box.
  28452. *
  28453. * @readonly
  28454. * @name Highcharts.Legend#box
  28455. * @type {Highcharts.SVGElement}
  28456. */
  28457. legend.box = box = renderer.rect()
  28458. .addClass('highcharts-legend-box')
  28459. .attr({
  28460. r: options.borderRadius
  28461. })
  28462. .add(legendGroup);
  28463. box.isNew = true;
  28464. }
  28465. // Presentational
  28466. if (!chart.styledMode) {
  28467. box
  28468. .attr({
  28469. stroke: options.borderColor,
  28470. 'stroke-width': options.borderWidth || 0,
  28471. fill: options.backgroundColor || 'none'
  28472. })
  28473. .shadow(options.shadow);
  28474. }
  28475. if (legendWidth > 0 && legendHeight > 0) {
  28476. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  28477. x: 0,
  28478. y: 0,
  28479. width: legendWidth,
  28480. height: legendHeight
  28481. }, box.strokeWidth()));
  28482. box.isNew = false;
  28483. }
  28484. // hide the border if no items
  28485. box[display ? 'show' : 'hide']();
  28486. // Open for responsiveness
  28487. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  28488. legendWidth = legendHeight = 0;
  28489. }
  28490. legend.legendWidth = legendWidth;
  28491. legend.legendHeight = legendHeight;
  28492. if (display) {
  28493. legend.align();
  28494. }
  28495. if (!this.proximate) {
  28496. this.positionItems();
  28497. }
  28498. fireEvent(this, 'afterRender');
  28499. };
  28500. /**
  28501. * Align the legend to chart's box.
  28502. *
  28503. * @private
  28504. * @function Highcharts.align
  28505. * @param {Highcharts.BBoxObject} alignTo
  28506. * @return {void}
  28507. */
  28508. Legend.prototype.align = function (alignTo) {
  28509. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  28510. var chart = this.chart,
  28511. options = this.options;
  28512. // If aligning to the top and the layout is horizontal, adjust for
  28513. // the title (#7428)
  28514. var y = alignTo.y;
  28515. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  28516. chart.titleOffset[0] > 0) {
  28517. y += chart.titleOffset[0];
  28518. }
  28519. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  28520. chart.titleOffset[2] > 0) {
  28521. y -= chart.titleOffset[2];
  28522. }
  28523. if (y !== alignTo.y) {
  28524. alignTo = merge(alignTo, { y: y });
  28525. }
  28526. this.group.align(merge(options, {
  28527. width: this.legendWidth,
  28528. height: this.legendHeight,
  28529. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  28530. }), true, alignTo);
  28531. };
  28532. /**
  28533. * Set up the overflow handling by adding navigation with up and down arrows
  28534. * below the legend.
  28535. *
  28536. * @private
  28537. * @function Highcharts.Legend#handleOverflow
  28538. * @param {number} legendHeight
  28539. * @return {number}
  28540. */
  28541. Legend.prototype.handleOverflow = function (legendHeight) {
  28542. var legend = this,
  28543. chart = this.chart,
  28544. renderer = chart.renderer,
  28545. options = this.options,
  28546. optionsY = options.y,
  28547. alignTop = options.verticalAlign === 'top',
  28548. padding = this.padding,
  28549. spaceHeight = (chart.spacingBox.height +
  28550. (alignTop ? -optionsY : optionsY) - padding),
  28551. maxHeight = options.maxHeight,
  28552. clipHeight,
  28553. clipRect = this.clipRect,
  28554. navOptions = options.navigation,
  28555. animation = pick(navOptions.animation,
  28556. true),
  28557. arrowSize = navOptions.arrowSize || 12,
  28558. nav = this.nav,
  28559. pages = this.pages,
  28560. lastY,
  28561. allItems = this.allItems,
  28562. clipToHeight = function (height) {
  28563. if (typeof height === 'number') {
  28564. clipRect.attr({
  28565. height: height
  28566. });
  28567. }
  28568. else if (clipRect) { // Reset (#5912)
  28569. legend.clipRect = clipRect.destroy();
  28570. legend.contentGroup.clip();
  28571. }
  28572. // useHTML
  28573. if (legend.contentGroup.div) {
  28574. legend.contentGroup.div.style.clip = height ?
  28575. 'rect(' + padding + 'px,9999px,' +
  28576. (padding + height) + 'px,0)' :
  28577. 'auto';
  28578. }
  28579. }, addTracker = function (key) {
  28580. legend[key] = renderer
  28581. .circle(0, 0, arrowSize * 1.3)
  28582. .translate(arrowSize / 2, arrowSize / 2)
  28583. .add(nav);
  28584. if (!chart.styledMode) {
  28585. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  28586. }
  28587. return legend[key];
  28588. };
  28589. // Adjust the height
  28590. if (options.layout === 'horizontal' &&
  28591. options.verticalAlign !== 'middle' &&
  28592. !options.floating) {
  28593. spaceHeight /= 2;
  28594. }
  28595. if (maxHeight) {
  28596. spaceHeight = Math.min(spaceHeight, maxHeight);
  28597. }
  28598. // Reset the legend height and adjust the clipping rectangle
  28599. pages.length = 0;
  28600. if (legendHeight &&
  28601. spaceHeight > 0 &&
  28602. legendHeight > spaceHeight &&
  28603. navOptions.enabled !== false) {
  28604. this.clipHeight = clipHeight =
  28605. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  28606. this.currentPage = pick(this.currentPage, 1);
  28607. this.fullHeight = legendHeight;
  28608. // Fill pages with Y positions so that the top of each a legend item
  28609. // defines the scroll top for each page (#2098)
  28610. allItems.forEach(function (item, i) {
  28611. var y = item._legendItemPos[1],
  28612. h = Math.round(item.legendItem.getBBox().height),
  28613. len = pages.length;
  28614. if (!len || (y - pages[len - 1] > clipHeight &&
  28615. (lastY || y) !== pages[len - 1])) {
  28616. pages.push(lastY || y);
  28617. len++;
  28618. }
  28619. // Keep track of which page each item is on
  28620. item.pageIx = len - 1;
  28621. if (lastY) {
  28622. allItems[i - 1].pageIx = len - 1;
  28623. }
  28624. if (i === allItems.length - 1 &&
  28625. y + h - pages[len - 1] > clipHeight &&
  28626. y !== lastY // #2617
  28627. ) {
  28628. pages.push(y);
  28629. item.pageIx = len;
  28630. }
  28631. if (y !== lastY) {
  28632. lastY = y;
  28633. }
  28634. });
  28635. // Only apply clipping if needed. Clipping causes blurred legend in
  28636. // PDF export (#1787)
  28637. if (!clipRect) {
  28638. clipRect = legend.clipRect =
  28639. renderer.clipRect(0, padding, 9999, 0);
  28640. legend.contentGroup.clip(clipRect);
  28641. }
  28642. clipToHeight(clipHeight);
  28643. // Add navigation elements
  28644. if (!nav) {
  28645. this.nav = nav = renderer.g()
  28646. .attr({ zIndex: 1 })
  28647. .add(this.group);
  28648. this.up = renderer
  28649. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  28650. .add(nav);
  28651. addTracker('upTracker')
  28652. .on('click', function () {
  28653. legend.scroll(-1, animation);
  28654. });
  28655. this.pager = renderer.text('', 15, 10)
  28656. .addClass('highcharts-legend-navigation');
  28657. if (!chart.styledMode) {
  28658. this.pager.css(navOptions.style);
  28659. }
  28660. this.pager.add(nav);
  28661. this.down = renderer
  28662. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  28663. .add(nav);
  28664. addTracker('downTracker')
  28665. .on('click', function () {
  28666. legend.scroll(1, animation);
  28667. });
  28668. }
  28669. // Set initial position
  28670. legend.scroll(0);
  28671. legendHeight = spaceHeight;
  28672. // Reset
  28673. }
  28674. else if (nav) {
  28675. clipToHeight();
  28676. this.nav = nav.destroy(); // #6322
  28677. this.scrollGroup.attr({
  28678. translateY: 1
  28679. });
  28680. this.clipHeight = 0; // #1379
  28681. }
  28682. return legendHeight;
  28683. };
  28684. /**
  28685. * Scroll the legend by a number of pages.
  28686. *
  28687. * @private
  28688. * @function Highcharts.Legend#scroll
  28689. *
  28690. * @param {number} scrollBy
  28691. * The number of pages to scroll.
  28692. *
  28693. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  28694. * Whether and how to apply animation.
  28695. *
  28696. * @return {void}
  28697. */
  28698. Legend.prototype.scroll = function (scrollBy, animation) {
  28699. var _this = this;
  28700. var chart = this.chart,
  28701. pages = this.pages,
  28702. pageCount = pages.length,
  28703. currentPage = this.currentPage + scrollBy,
  28704. clipHeight = this.clipHeight,
  28705. navOptions = this.options.navigation,
  28706. pager = this.pager,
  28707. padding = this.padding;
  28708. // When resizing while looking at the last page
  28709. if (currentPage > pageCount) {
  28710. currentPage = pageCount;
  28711. }
  28712. if (currentPage > 0) {
  28713. if (typeof animation !== 'undefined') {
  28714. setAnimation(animation, chart);
  28715. }
  28716. this.nav.attr({
  28717. translateX: padding,
  28718. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  28719. visibility: 'visible'
  28720. });
  28721. [this.up, this.upTracker].forEach(function (elem) {
  28722. elem.attr({
  28723. 'class': currentPage === 1 ?
  28724. 'highcharts-legend-nav-inactive' :
  28725. 'highcharts-legend-nav-active'
  28726. });
  28727. });
  28728. pager.attr({
  28729. text: currentPage + '/' + pageCount
  28730. });
  28731. [this.down, this.downTracker].forEach(function (elem) {
  28732. elem.attr({
  28733. // adjust to text width
  28734. x: 18 + this.pager.getBBox().width,
  28735. 'class': currentPage === pageCount ?
  28736. 'highcharts-legend-nav-inactive' :
  28737. 'highcharts-legend-nav-active'
  28738. });
  28739. }, this);
  28740. if (!chart.styledMode) {
  28741. this.up
  28742. .attr({
  28743. fill: currentPage === 1 ?
  28744. navOptions.inactiveColor :
  28745. navOptions.activeColor
  28746. });
  28747. this.upTracker
  28748. .css({
  28749. cursor: currentPage === 1 ? 'default' : 'pointer'
  28750. });
  28751. this.down
  28752. .attr({
  28753. fill: currentPage === pageCount ?
  28754. navOptions.inactiveColor :
  28755. navOptions.activeColor
  28756. });
  28757. this.downTracker
  28758. .css({
  28759. cursor: currentPage === pageCount ?
  28760. 'default' :
  28761. 'pointer'
  28762. });
  28763. }
  28764. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  28765. this.scrollGroup.animate({
  28766. translateY: this.scrollOffset
  28767. });
  28768. this.currentPage = currentPage;
  28769. this.positionCheckboxes();
  28770. // Fire event after scroll animation is complete
  28771. var animOptions = animObject(pick(animation,
  28772. chart.renderer.globalAnimation,
  28773. true));
  28774. syncTimeout(function () {
  28775. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  28776. }, animOptions.duration);
  28777. }
  28778. };
  28779. /**
  28780. * @private
  28781. * @function Highcharts.Legend#setItemEvents
  28782. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28783. * @param {Highcharts.SVGElement} legendItem
  28784. * @param {boolean} [useHTML=false]
  28785. * @fires Highcharts.Point#event:legendItemClick
  28786. * @fires Highcharts.Series#event:legendItemClick
  28787. */
  28788. Legend.prototype.setItemEvents = function (item, legendItem, useHTML) {
  28789. var legend = this,
  28790. boxWrapper = legend.chart.renderer.boxWrapper,
  28791. isPoint = item instanceof Point,
  28792. activeClass = 'highcharts-legend-' +
  28793. (isPoint ? 'point' : 'series') + '-active',
  28794. styledMode = legend.chart.styledMode,
  28795. // When `useHTML`, the symbol is rendered in other group, so
  28796. // we need to apply events listeners to both places
  28797. legendItems = useHTML ?
  28798. [legendItem,
  28799. item.legendSymbol] :
  28800. [item.legendGroup];
  28801. // Set the events on the item group, or in case of useHTML, the item
  28802. // itself (#1249)
  28803. legendItems.forEach(function (element) {
  28804. if (element) {
  28805. element
  28806. .on('mouseover', function () {
  28807. if (item.visible) {
  28808. legend.allItems.forEach(function (inactiveItem) {
  28809. if (item !== inactiveItem) {
  28810. inactiveItem.setState('inactive', !isPoint);
  28811. }
  28812. });
  28813. }
  28814. item.setState('hover');
  28815. // A CSS class to dim or hide other than the hovered
  28816. // series.
  28817. // Works only if hovered series is visible (#10071).
  28818. if (item.visible) {
  28819. boxWrapper.addClass(activeClass);
  28820. }
  28821. if (!styledMode) {
  28822. legendItem.css(legend.options.itemHoverStyle);
  28823. }
  28824. })
  28825. .on('mouseout', function () {
  28826. if (!legend.chart.styledMode) {
  28827. legendItem.css(merge(item.visible ?
  28828. legend.itemStyle :
  28829. legend.itemHiddenStyle));
  28830. }
  28831. legend.allItems.forEach(function (inactiveItem) {
  28832. if (item !== inactiveItem) {
  28833. inactiveItem.setState('', !isPoint);
  28834. }
  28835. });
  28836. // A CSS class to dim or hide other than the hovered
  28837. // series.
  28838. boxWrapper.removeClass(activeClass);
  28839. item.setState();
  28840. })
  28841. .on('click', function (event) {
  28842. var strLegendItemClick = 'legendItemClick',
  28843. fnLegendItemClick = function () {
  28844. if (item.setVisible) {
  28845. item.setVisible();
  28846. }
  28847. // Reset inactive state
  28848. legend.allItems.forEach(function (inactiveItem) {
  28849. if (item !== inactiveItem) {
  28850. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  28851. }
  28852. });
  28853. };
  28854. // A CSS class to dim or hide other than the hovered
  28855. // series. Event handling in iOS causes the activeClass
  28856. // to be added prior to click in some cases (#7418).
  28857. boxWrapper.removeClass(activeClass);
  28858. // Pass over the click/touch event. #4.
  28859. event = {
  28860. browserEvent: event
  28861. };
  28862. // click the name or symbol
  28863. if (item.firePointEvent) { // point
  28864. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  28865. }
  28866. else {
  28867. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  28868. }
  28869. });
  28870. }
  28871. });
  28872. };
  28873. /**
  28874. * @private
  28875. * @function Highcharts.Legend#createCheckboxForItem
  28876. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28877. * @fires Highcharts.Series#event:checkboxClick
  28878. */
  28879. Legend.prototype.createCheckboxForItem = function (item) {
  28880. var legend = this;
  28881. item.checkbox = createElement('input', {
  28882. type: 'checkbox',
  28883. className: 'highcharts-legend-checkbox',
  28884. checked: item.selected,
  28885. defaultChecked: item.selected // required by IE7
  28886. }, legend.options.itemCheckboxStyle, legend.chart.container);
  28887. addEvent(item.checkbox, 'click', function (event) {
  28888. var target = event.target;
  28889. fireEvent(item.series || item, 'checkboxClick', {
  28890. checked: target.checked,
  28891. item: item
  28892. }, function () {
  28893. item.select();
  28894. });
  28895. });
  28896. };
  28897. return Legend;
  28898. }());
  28899. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  28900. // and for #2580, a similar drawing flaw in Firefox 26.
  28901. // Explore if there's a general cause for this. The problem may be related
  28902. // to nested group elements, as the legend item texts are within 4 group
  28903. // elements.
  28904. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  28905. isFirefox) {
  28906. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  28907. var legend = this,
  28908. // If chart destroyed in sync, this is undefined (#2030)
  28909. runPositionItem = function () {
  28910. if (item._legendItemPos) {
  28911. proceed.call(legend,
  28912. item);
  28913. }
  28914. };
  28915. // Do it now, for export and to get checkbox placement
  28916. runPositionItem();
  28917. // Do it after to work around the core issue
  28918. if (!legend.bubbleLegend) {
  28919. setTimeout(runPositionItem);
  28920. }
  28921. });
  28922. }
  28923. H.Legend = Legend;
  28924. return H.Legend;
  28925. });
  28926. _registerModule(_modules, 'Core/Series/SeriesRegistry.js', [_modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, O, Point, U) {
  28927. /* *
  28928. *
  28929. * (c) 2010-2021 Torstein Honsi
  28930. *
  28931. * License: www.highcharts.com/license
  28932. *
  28933. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28934. *
  28935. * */
  28936. var defaultOptions = O.defaultOptions;
  28937. var error = U.error,
  28938. extendClass = U.extendClass,
  28939. merge = U.merge;
  28940. /* *
  28941. *
  28942. * Namespace
  28943. *
  28944. * */
  28945. var SeriesRegistry;
  28946. (function (SeriesRegistry) {
  28947. /* *
  28948. *
  28949. * Static Properties
  28950. *
  28951. * */
  28952. /**
  28953. * @internal
  28954. * @todo Move `Globals.seriesTypes` code to her.
  28955. */
  28956. SeriesRegistry.seriesTypes = H.seriesTypes;
  28957. /* *
  28958. *
  28959. * Static Functions
  28960. *
  28961. * */
  28962. /* eslint-disable valid-jsdoc */
  28963. /**
  28964. * Internal function to initialize an individual series.
  28965. * @private
  28966. */
  28967. function getSeries(chart, options) {
  28968. if (options === void 0) { options = {}; }
  28969. var optionsChart = chart.options.chart,
  28970. type = (options.type ||
  28971. optionsChart.type ||
  28972. optionsChart.defaultSeriesType ||
  28973. ''),
  28974. SeriesClass = SeriesRegistry.seriesTypes[type];
  28975. // No such series type
  28976. if (!SeriesRegistry) {
  28977. error(17, true, chart, { missingModuleFor: type });
  28978. }
  28979. var series = new SeriesClass();
  28980. if (typeof series.init === 'function') {
  28981. series.init(chart, options);
  28982. }
  28983. return series;
  28984. }
  28985. SeriesRegistry.getSeries = getSeries;
  28986. /**
  28987. * Registers class pattern of a series.
  28988. *
  28989. * @private
  28990. */
  28991. function registerSeriesType(seriesType, seriesClass) {
  28992. var defaultPlotOptions = defaultOptions.plotOptions || {},
  28993. seriesOptions = seriesClass.defaultOptions;
  28994. if (!seriesClass.prototype.pointClass) {
  28995. seriesClass.prototype.pointClass = Point;
  28996. }
  28997. seriesClass.prototype.type = seriesType;
  28998. if (seriesOptions) {
  28999. defaultPlotOptions[seriesType] = seriesOptions;
  29000. }
  29001. SeriesRegistry.seriesTypes[seriesType] = seriesClass;
  29002. }
  29003. SeriesRegistry.registerSeriesType = registerSeriesType;
  29004. /**
  29005. * Old factory to create new series prototypes.
  29006. *
  29007. * @deprecated
  29008. * @function Highcharts.seriesType
  29009. *
  29010. * @param {string} type
  29011. * The series type name.
  29012. *
  29013. * @param {string} parent
  29014. * The parent series type name. Use `line` to inherit from the basic
  29015. * {@link Series} object.
  29016. *
  29017. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  29018. * The additional default options that are merged with the parent's options.
  29019. *
  29020. * @param {Highcharts.Dictionary<*>} [props]
  29021. * The properties (functions and primitives) to set on the new prototype.
  29022. *
  29023. * @param {Highcharts.Dictionary<*>} [pointProps]
  29024. * Members for a series-specific extension of the {@link Point} prototype if
  29025. * needed.
  29026. *
  29027. * @return {Highcharts.Series}
  29028. * The newly created prototype as extended from {@link Series} or its
  29029. * derivatives.
  29030. */
  29031. function seriesType(type, parent, options, seriesProto, pointProto) {
  29032. var defaultPlotOptions = defaultOptions.plotOptions || {};
  29033. parent = parent || '';
  29034. // Merge the options
  29035. defaultPlotOptions[type] = merge(defaultPlotOptions[parent], options);
  29036. // Create the class
  29037. registerSeriesType(type, extendClass(SeriesRegistry.seriesTypes[parent] || function () { }, seriesProto));
  29038. SeriesRegistry.seriesTypes[type].prototype.type = type;
  29039. // Create the point class if needed
  29040. if (pointProto) {
  29041. SeriesRegistry.seriesTypes[type].prototype.pointClass =
  29042. extendClass(Point, pointProto);
  29043. }
  29044. return SeriesRegistry.seriesTypes[type];
  29045. }
  29046. SeriesRegistry.seriesType = seriesType;
  29047. /* eslint-enable valid-jsdoc */
  29048. })(SeriesRegistry || (SeriesRegistry = {}));
  29049. /* *
  29050. *
  29051. * Compatibility
  29052. *
  29053. * */
  29054. H.seriesType = SeriesRegistry.seriesType;
  29055. /* *
  29056. *
  29057. * Export
  29058. *
  29059. * */
  29060. return SeriesRegistry;
  29061. });
  29062. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Pointer.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (A, Axis, F, H, Legend, MSPointer, O, palette, Pointer, SeriesRegistry, Time, U, AST) {
  29063. /* *
  29064. *
  29065. * (c) 2010-2021 Torstein Honsi
  29066. *
  29067. * License: www.highcharts.com/license
  29068. *
  29069. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29070. *
  29071. * */
  29072. var animate = A.animate,
  29073. animObject = A.animObject,
  29074. setAnimation = A.setAnimation;
  29075. var numberFormat = F.numberFormat;
  29076. var charts = H.charts,
  29077. doc = H.doc,
  29078. win = H.win;
  29079. var defaultOptions = O.defaultOptions,
  29080. defaultTime = O.defaultTime;
  29081. var seriesTypes = SeriesRegistry.seriesTypes;
  29082. var addEvent = U.addEvent,
  29083. attr = U.attr,
  29084. cleanRecursively = U.cleanRecursively,
  29085. createElement = U.createElement,
  29086. css = U.css,
  29087. defined = U.defined,
  29088. discardElement = U.discardElement,
  29089. erase = U.erase,
  29090. error = U.error,
  29091. extend = U.extend,
  29092. find = U.find,
  29093. fireEvent = U.fireEvent,
  29094. getStyle = U.getStyle,
  29095. isArray = U.isArray,
  29096. isFunction = U.isFunction,
  29097. isNumber = U.isNumber,
  29098. isObject = U.isObject,
  29099. isString = U.isString,
  29100. merge = U.merge,
  29101. objectEach = U.objectEach,
  29102. pick = U.pick,
  29103. pInt = U.pInt,
  29104. relativeLength = U.relativeLength,
  29105. removeEvent = U.removeEvent,
  29106. splat = U.splat,
  29107. syncTimeout = U.syncTimeout,
  29108. uniqueKey = U.uniqueKey;
  29109. var marginNames = H.marginNames;
  29110. /* eslint-disable no-invalid-this, valid-jsdoc */
  29111. /**
  29112. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  29113. *
  29114. * @example
  29115. * let chart = Highcharts.chart('container', {
  29116. * title: {
  29117. * text: 'My chart'
  29118. * },
  29119. * series: [{
  29120. * data: [1, 3, 2, 4]
  29121. * }]
  29122. * })
  29123. *
  29124. * @class
  29125. * @name Highcharts.Chart
  29126. *
  29127. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29128. * The DOM element to render to, or its id.
  29129. *
  29130. * @param {Highcharts.Options} options
  29131. * The chart options structure.
  29132. *
  29133. * @param {Highcharts.ChartCallbackFunction} [callback]
  29134. * Function to run when the chart has loaded and and all external images
  29135. * are loaded. Defining a
  29136. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29137. * handler is equivalent.
  29138. */
  29139. var Chart = /** @class */ (function () {
  29140. function Chart(a, b, c) {
  29141. this.axes = void 0;
  29142. this.axisOffset = void 0;
  29143. this.bounds = void 0;
  29144. this.chartHeight = void 0;
  29145. this.chartWidth = void 0;
  29146. this.clipBox = void 0;
  29147. this.colorCounter = void 0;
  29148. this.container = void 0;
  29149. this.index = void 0;
  29150. this.isResizing = void 0;
  29151. this.labelCollectors = void 0;
  29152. this.legend = void 0;
  29153. this.margin = void 0;
  29154. this.numberFormatter = void 0;
  29155. this.options = void 0;
  29156. this.plotBox = void 0;
  29157. this.plotHeight = void 0;
  29158. this.plotLeft = void 0;
  29159. this.plotTop = void 0;
  29160. this.plotWidth = void 0;
  29161. this.pointCount = void 0;
  29162. this.pointer = void 0;
  29163. this.renderer = void 0;
  29164. this.renderTo = void 0;
  29165. this.series = void 0;
  29166. this.sharedClips = {};
  29167. this.spacing = void 0;
  29168. this.spacingBox = void 0;
  29169. this.symbolCounter = void 0;
  29170. this.time = void 0;
  29171. this.titleOffset = void 0;
  29172. this.userOptions = void 0;
  29173. this.xAxis = void 0;
  29174. this.yAxis = void 0;
  29175. this.getArgs(a, b, c);
  29176. }
  29177. /* *
  29178. *
  29179. * Functions
  29180. *
  29181. * */
  29182. /**
  29183. * Handle the arguments passed to the constructor.
  29184. *
  29185. * @private
  29186. * @function Highcharts.Chart#getArgs
  29187. *
  29188. * @param {...Array<*>} arguments
  29189. * All arguments for the constructor.
  29190. *
  29191. * @fires Highcharts.Chart#event:init
  29192. * @fires Highcharts.Chart#event:afterInit
  29193. */
  29194. Chart.prototype.getArgs = function (a, b, c) {
  29195. // Remove the optional first argument, renderTo, and
  29196. // set it on this.
  29197. if (isString(a) || a.nodeName) {
  29198. this.renderTo = a;
  29199. this.init(b, c);
  29200. }
  29201. else {
  29202. this.init(a, b);
  29203. }
  29204. };
  29205. /**
  29206. * Overridable function that initializes the chart. The constructor's
  29207. * arguments are passed on directly.
  29208. *
  29209. * @function Highcharts.Chart#init
  29210. *
  29211. * @param {Highcharts.Options} userOptions
  29212. * Custom options.
  29213. *
  29214. * @param {Function} [callback]
  29215. * Function to run when the chart has loaded and and all external
  29216. * images are loaded.
  29217. *
  29218. * @return {void}
  29219. *
  29220. * @fires Highcharts.Chart#event:init
  29221. * @fires Highcharts.Chart#event:afterInit
  29222. */
  29223. Chart.prototype.init = function (userOptions, callback) {
  29224. // Handle regular options
  29225. var userPlotOptions = userOptions.plotOptions || {};
  29226. // Fire the event with a default function
  29227. fireEvent(this, 'init', { args: arguments }, function () {
  29228. var options = merge(defaultOptions,
  29229. userOptions); // do the merge
  29230. var optionsChart = options.chart;
  29231. // Override (by copy of user options) or clear tooltip options
  29232. // in chart.options.plotOptions (#6218)
  29233. objectEach(options.plotOptions, function (typeOptions, type) {
  29234. if (isObject(typeOptions)) { // #8766
  29235. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  29236. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  29237. }
  29238. });
  29239. // User options have higher priority than default options
  29240. // (#6218). In case of exporting: path is changed
  29241. options.tooltip.userOptions = (userOptions.chart &&
  29242. userOptions.chart.forExport &&
  29243. userOptions.tooltip.userOptions) || userOptions.tooltip;
  29244. /**
  29245. * The original options given to the constructor or a chart factory
  29246. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  29247. *
  29248. * @name Highcharts.Chart#userOptions
  29249. * @type {Highcharts.Options}
  29250. */
  29251. this.userOptions = userOptions;
  29252. var chartEvents = optionsChart.events;
  29253. this.margin = [];
  29254. this.spacing = [];
  29255. // Pixel data bounds for touch zoom
  29256. this.bounds = { h: {}, v: {} };
  29257. // An array of functions that returns labels that should be
  29258. // considered for anti-collision
  29259. this.labelCollectors = [];
  29260. this.callback = callback;
  29261. this.isResizing = 0;
  29262. /**
  29263. * The options structure for the chart after merging
  29264. * {@link #defaultOptions} and {@link #userOptions}. It contains
  29265. * members for the sub elements like series, legend, tooltip etc.
  29266. *
  29267. * @name Highcharts.Chart#options
  29268. * @type {Highcharts.Options}
  29269. */
  29270. this.options = options;
  29271. /**
  29272. * All the axes in the chart.
  29273. *
  29274. * @see Highcharts.Chart.xAxis
  29275. * @see Highcharts.Chart.yAxis
  29276. *
  29277. * @name Highcharts.Chart#axes
  29278. * @type {Array<Highcharts.Axis>}
  29279. */
  29280. this.axes = [];
  29281. /**
  29282. * All the current series in the chart.
  29283. *
  29284. * @name Highcharts.Chart#series
  29285. * @type {Array<Highcharts.Series>}
  29286. */
  29287. this.series = [];
  29288. /**
  29289. * The `Time` object associated with the chart. Since v6.0.5,
  29290. * time settings can be applied individually for each chart. If
  29291. * no individual settings apply, the `Time` object is shared by
  29292. * all instances.
  29293. *
  29294. * @name Highcharts.Chart#time
  29295. * @type {Highcharts.Time}
  29296. */
  29297. this.time =
  29298. userOptions.time && Object.keys(userOptions.time).length ?
  29299. new Time(userOptions.time) :
  29300. H.time;
  29301. /**
  29302. * Callback function to override the default function that formats
  29303. * all the numbers in the chart. Returns a string with the formatted
  29304. * number.
  29305. *
  29306. * @name Highcharts.Chart#numberFormatter
  29307. * @type {Highcharts.NumberFormatterCallbackFunction}
  29308. */
  29309. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  29310. /**
  29311. * Whether the chart is in styled mode, meaning all presentatinoal
  29312. * attributes are avoided.
  29313. *
  29314. * @name Highcharts.Chart#styledMode
  29315. * @type {boolean}
  29316. */
  29317. this.styledMode = optionsChart.styledMode;
  29318. this.hasCartesianSeries = optionsChart.showAxes;
  29319. var chart = this;
  29320. /**
  29321. * Index position of the chart in the {@link Highcharts#charts}
  29322. * property.
  29323. *
  29324. * @name Highcharts.Chart#index
  29325. * @type {number}
  29326. * @readonly
  29327. */
  29328. chart.index = charts.length; // Add the chart to the global lookup
  29329. charts.push(chart);
  29330. H.chartCount++;
  29331. // Chart event handlers
  29332. if (chartEvents) {
  29333. objectEach(chartEvents, function (event, eventType) {
  29334. if (isFunction(event)) {
  29335. addEvent(chart, eventType, event);
  29336. }
  29337. });
  29338. }
  29339. /**
  29340. * A collection of the X axes in the chart.
  29341. *
  29342. * @name Highcharts.Chart#xAxis
  29343. * @type {Array<Highcharts.Axis>}
  29344. */
  29345. chart.xAxis = [];
  29346. /**
  29347. * A collection of the Y axes in the chart.
  29348. *
  29349. * @name Highcharts.Chart#yAxis
  29350. * @type {Array<Highcharts.Axis>}
  29351. *
  29352. * @todo
  29353. * Make events official: Fire the event `afterInit`.
  29354. */
  29355. chart.yAxis = [];
  29356. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  29357. // Fire after init but before first render, before axes and series
  29358. // have been initialized.
  29359. fireEvent(chart, 'afterInit');
  29360. chart.firstRender();
  29361. });
  29362. };
  29363. /**
  29364. * Internal function to unitialize an individual series.
  29365. *
  29366. * @private
  29367. * @function Highcharts.Chart#initSeries
  29368. */
  29369. Chart.prototype.initSeries = function (options) {
  29370. var chart = this,
  29371. optionsChart = chart.options.chart,
  29372. type = (options.type ||
  29373. optionsChart.type ||
  29374. optionsChart.defaultSeriesType),
  29375. series,
  29376. SeriesClass = seriesTypes[type];
  29377. // No such series type
  29378. if (!SeriesClass) {
  29379. error(17, true, chart, { missingModuleFor: type });
  29380. }
  29381. series = new SeriesClass();
  29382. if (typeof series.init === 'function') {
  29383. series.init(chart, options);
  29384. }
  29385. return series;
  29386. };
  29387. /**
  29388. * Internal function to set data for all series with enabled sorting.
  29389. *
  29390. * @private
  29391. * @function Highcharts.Chart#setSeriesData
  29392. */
  29393. Chart.prototype.setSeriesData = function () {
  29394. this.getSeriesOrderByLinks().forEach(function (series) {
  29395. // We need to set data for series with sorting after series init
  29396. if (!series.points && !series.data && series.enabledDataSorting) {
  29397. series.setData(series.options.data, false);
  29398. }
  29399. });
  29400. };
  29401. /**
  29402. * Sort and return chart series in order depending on the number of linked
  29403. * series.
  29404. *
  29405. * @private
  29406. * @function Highcharts.Series#getSeriesOrderByLinks
  29407. * @return {Array<Highcharts.Series>}
  29408. */
  29409. Chart.prototype.getSeriesOrderByLinks = function () {
  29410. return this.series.concat().sort(function (a, b) {
  29411. if (a.linkedSeries.length || b.linkedSeries.length) {
  29412. return b.linkedSeries.length - a.linkedSeries.length;
  29413. }
  29414. return 0;
  29415. });
  29416. };
  29417. /**
  29418. * Order all series above a given index. When series are added and ordered
  29419. * by configuration, only the last series is handled (#248, #1123, #2456,
  29420. * #6112). This function is called on series initialization and destroy.
  29421. *
  29422. * @private
  29423. * @function Highcharts.Series#orderSeries
  29424. * @param {number} [fromIndex]
  29425. * If this is given, only the series above this index are handled.
  29426. */
  29427. Chart.prototype.orderSeries = function (fromIndex) {
  29428. var series = this.series,
  29429. i = fromIndex || 0;
  29430. for (; i < series.length; i++) {
  29431. if (series[i]) {
  29432. /**
  29433. * Contains the series' index in the `Chart.series` array.
  29434. *
  29435. * @name Highcharts.Series#index
  29436. * @type {number}
  29437. * @readonly
  29438. */
  29439. series[i].index = i;
  29440. series[i].name = series[i].getName();
  29441. }
  29442. }
  29443. };
  29444. /**
  29445. * Check whether a given point is within the plot area.
  29446. *
  29447. * @function Highcharts.Chart#isInsidePlot
  29448. *
  29449. * @param {number} plotX
  29450. * Pixel x relative to the plot area.
  29451. *
  29452. * @param {number} plotY
  29453. * Pixel y relative to the plot area.
  29454. *
  29455. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  29456. * Options object.
  29457. *
  29458. * @return {boolean}
  29459. * Returns true if the given point is inside the plot area.
  29460. */
  29461. Chart.prototype.isInsidePlot = function (plotX, plotY, options) {
  29462. if (options === void 0) { options = {}; }
  29463. var _a = this,
  29464. inverted = _a.inverted,
  29465. plotBox = _a.plotBox,
  29466. plotLeft = _a.plotLeft,
  29467. plotTop = _a.plotTop,
  29468. scrollablePlotBox = _a.scrollablePlotBox,
  29469. _b = _a.scrollingContainer,
  29470. _c = _b === void 0 ? {
  29471. scrollLeft: 0,
  29472. scrollTop: 0
  29473. } : _b,
  29474. scrollLeft = _c.scrollLeft,
  29475. scrollTop = _c.scrollTop;
  29476. var series = options.series;
  29477. var box = (options.visiblePlotOnly && scrollablePlotBox) || plotBox;
  29478. var x = options.inverted ? plotY : plotX;
  29479. var y = options.inverted ? plotX : plotY;
  29480. var e = {
  29481. x: x,
  29482. y: y,
  29483. isInsidePlot: true
  29484. };
  29485. if (!options.ignoreX) {
  29486. var xAxis = (series && (inverted ? series.yAxis : series.xAxis)) || {
  29487. pos: plotLeft,
  29488. len: Infinity
  29489. };
  29490. var chartX = options.paneCoordinates ? xAxis.pos + x : plotLeft + x;
  29491. if (!(chartX >= Math.max(scrollLeft + plotLeft, xAxis.pos) &&
  29492. chartX <= Math.min(scrollLeft + plotLeft + box.width, xAxis.pos + xAxis.len))) {
  29493. e.isInsidePlot = false;
  29494. }
  29495. }
  29496. if (!options.ignoreY && e.isInsidePlot) {
  29497. var yAxis = (series && (inverted ? series.xAxis : series.yAxis)) || {
  29498. pos: plotTop,
  29499. len: Infinity
  29500. };
  29501. var chartY = options.paneCoordinates ? yAxis.pos + y : plotTop + y;
  29502. if (!(chartY >= Math.max(scrollTop + plotTop, yAxis.pos) &&
  29503. chartY <= Math.min(scrollTop + plotTop + box.height, yAxis.pos + yAxis.len))) {
  29504. e.isInsidePlot = false;
  29505. }
  29506. }
  29507. fireEvent(this, 'afterIsInsidePlot', e);
  29508. return e.isInsidePlot;
  29509. };
  29510. /**
  29511. * Redraw the chart after changes have been done to the data, axis extremes
  29512. * chart size or chart elements. All methods for updating axes, series or
  29513. * points have a parameter for redrawing the chart. This is `true` by
  29514. * default. But in many cases you want to do more than one operation on the
  29515. * chart before redrawing, for example add a number of points. In those
  29516. * cases it is a waste of resources to redraw the chart for each new point
  29517. * added. So you add the points and call `chart.redraw()` after.
  29518. *
  29519. * @function Highcharts.Chart#redraw
  29520. *
  29521. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29522. * If or how to apply animation to the redraw.
  29523. *
  29524. * @fires Highcharts.Chart#event:afterSetExtremes
  29525. * @fires Highcharts.Chart#event:beforeRedraw
  29526. * @fires Highcharts.Chart#event:predraw
  29527. * @fires Highcharts.Chart#event:redraw
  29528. * @fires Highcharts.Chart#event:render
  29529. * @fires Highcharts.Chart#event:updatedData
  29530. */
  29531. Chart.prototype.redraw = function (animation) {
  29532. fireEvent(this, 'beforeRedraw');
  29533. var chart = this,
  29534. axes = chart.hasCartesianSeries ? chart.axes : chart.colorAxis || [],
  29535. series = chart.series,
  29536. pointer = chart.pointer,
  29537. legend = chart.legend,
  29538. legendUserOptions = chart.userOptions.legend,
  29539. redrawLegend = chart.isDirtyLegend,
  29540. hasStackedSeries,
  29541. hasDirtyStacks,
  29542. isDirtyBox = chart.isDirtyBox,
  29543. i,
  29544. serie,
  29545. renderer = chart.renderer,
  29546. isHiddenChart = renderer.isHidden(),
  29547. afterRedraw = [];
  29548. // Handle responsive rules, not only on resize (#6130)
  29549. if (chart.setResponsive) {
  29550. chart.setResponsive(false);
  29551. }
  29552. // Set the global animation. When chart.hasRendered is not true, the
  29553. // redraw call comes from a responsive rule and animation should not
  29554. // occur.
  29555. setAnimation(chart.hasRendered ? animation : false, chart);
  29556. if (isHiddenChart) {
  29557. chart.temporaryDisplay();
  29558. }
  29559. // Adjust title layout (reflow multiline text)
  29560. chart.layOutTitles();
  29561. // link stacked series
  29562. i = series.length;
  29563. while (i--) {
  29564. serie = series[i];
  29565. if (serie.options.stacking || serie.options.centerInCategory) {
  29566. hasStackedSeries = true;
  29567. if (serie.isDirty) {
  29568. hasDirtyStacks = true;
  29569. break;
  29570. }
  29571. }
  29572. }
  29573. if (hasDirtyStacks) { // mark others as dirty
  29574. i = series.length;
  29575. while (i--) {
  29576. serie = series[i];
  29577. if (serie.options.stacking) {
  29578. serie.isDirty = true;
  29579. }
  29580. }
  29581. }
  29582. // Handle updated data in the series
  29583. series.forEach(function (serie) {
  29584. if (serie.isDirty) {
  29585. if (serie.options.legendType === 'point') {
  29586. if (typeof serie.updateTotals === 'function') {
  29587. serie.updateTotals();
  29588. }
  29589. redrawLegend = true;
  29590. }
  29591. else if (legendUserOptions &&
  29592. (legendUserOptions.labelFormatter ||
  29593. legendUserOptions.labelFormat)) {
  29594. redrawLegend = true; // #2165
  29595. }
  29596. }
  29597. if (serie.isDirtyData) {
  29598. fireEvent(serie, 'updatedData');
  29599. }
  29600. });
  29601. // handle added or removed series
  29602. if (redrawLegend && legend && legend.options.enabled) {
  29603. // draw legend graphics
  29604. legend.render();
  29605. chart.isDirtyLegend = false;
  29606. }
  29607. // reset stacks
  29608. if (hasStackedSeries) {
  29609. chart.getStacks();
  29610. }
  29611. // set axes scales
  29612. axes.forEach(function (axis) {
  29613. axis.updateNames();
  29614. axis.setScale();
  29615. });
  29616. chart.getMargins(); // #3098
  29617. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  29618. axes.forEach(function (axis) {
  29619. if (axis.isDirty) {
  29620. isDirtyBox = true;
  29621. }
  29622. });
  29623. // redraw axes
  29624. axes.forEach(function (axis) {
  29625. // Fire 'afterSetExtremes' only if extremes are set
  29626. var key = axis.min + ',' + axis.max;
  29627. if (axis.extKey !== key) { // #821, #4452
  29628. axis.extKey = key;
  29629. // prevent a recursive call to chart.redraw() (#1119)
  29630. afterRedraw.push(function () {
  29631. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  29632. delete axis.eventArgs;
  29633. });
  29634. }
  29635. if (isDirtyBox || hasStackedSeries) {
  29636. axis.redraw();
  29637. }
  29638. });
  29639. // the plot areas size has changed
  29640. if (isDirtyBox) {
  29641. chart.drawChartBox();
  29642. }
  29643. // Fire an event before redrawing series, used by the boost module to
  29644. // clear previous series renderings.
  29645. fireEvent(chart, 'predraw');
  29646. // redraw affected series
  29647. series.forEach(function (serie) {
  29648. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  29649. serie.redraw();
  29650. }
  29651. // Set it here, otherwise we will have unlimited 'updatedData' calls
  29652. // for a hidden series after setData(). Fixes #6012
  29653. serie.isDirtyData = false;
  29654. });
  29655. // move tooltip or reset
  29656. if (pointer) {
  29657. pointer.reset(true);
  29658. }
  29659. // redraw if canvas
  29660. renderer.draw();
  29661. // Fire the events
  29662. fireEvent(chart, 'redraw');
  29663. fireEvent(chart, 'render');
  29664. if (isHiddenChart) {
  29665. chart.temporaryDisplay(true);
  29666. }
  29667. // Fire callbacks that are put on hold until after the redraw
  29668. afterRedraw.forEach(function (callback) {
  29669. callback.call();
  29670. });
  29671. };
  29672. /**
  29673. * Get an axis, series or point object by `id` as given in the configuration
  29674. * options. Returns `undefined` if no item is found.
  29675. *
  29676. * @sample highcharts/plotoptions/series-id/
  29677. * Get series by id
  29678. *
  29679. * @function Highcharts.Chart#get
  29680. *
  29681. * @param {string} id
  29682. * The id as given in the configuration options.
  29683. *
  29684. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  29685. * The retrieved item.
  29686. */
  29687. Chart.prototype.get = function (id) {
  29688. var ret,
  29689. series = this.series,
  29690. i;
  29691. /**
  29692. * @private
  29693. * @param {Highcharts.Axis|Highcharts.Series} item
  29694. * @return {boolean}
  29695. */
  29696. function itemById(item) {
  29697. return (item.id === id ||
  29698. (item.options && item.options.id === id));
  29699. }
  29700. ret =
  29701. // Search axes
  29702. find(this.axes, itemById) ||
  29703. // Search series
  29704. find(this.series, itemById);
  29705. // Search points
  29706. for (i = 0; !ret && i < series.length; i++) {
  29707. ret = find(series[i].points || [], itemById);
  29708. }
  29709. return ret;
  29710. };
  29711. /**
  29712. * Create the Axis instances based on the config options.
  29713. *
  29714. * @private
  29715. * @function Highcharts.Chart#getAxes
  29716. * @fires Highcharts.Chart#event:afterGetAxes
  29717. * @fires Highcharts.Chart#event:getAxes
  29718. */
  29719. Chart.prototype.getAxes = function () {
  29720. var chart = this,
  29721. options = this.options,
  29722. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  29723. yAxisOptions = options.yAxis = splat(options.yAxis || {}),
  29724. optionsArray;
  29725. fireEvent(this, 'getAxes');
  29726. // make sure the options are arrays and add some members
  29727. xAxisOptions.forEach(function (axis, i) {
  29728. axis.index = i;
  29729. axis.isX = true;
  29730. });
  29731. yAxisOptions.forEach(function (axis, i) {
  29732. axis.index = i;
  29733. });
  29734. // concatenate all axis options into one array
  29735. optionsArray = xAxisOptions.concat(yAxisOptions);
  29736. optionsArray.forEach(function (axisOptions) {
  29737. new Axis(chart, axisOptions); // eslint-disable-line no-new
  29738. });
  29739. fireEvent(this, 'afterGetAxes');
  29740. };
  29741. /**
  29742. * Returns an array of all currently selected points in the chart. Points
  29743. * can be selected by clicking or programmatically by the
  29744. * {@link Highcharts.Point#select}
  29745. * function.
  29746. *
  29747. * @sample highcharts/plotoptions/series-allowpointselect-line/
  29748. * Get selected points
  29749. *
  29750. * @function Highcharts.Chart#getSelectedPoints
  29751. *
  29752. * @return {Array<Highcharts.Point>}
  29753. * The currently selected points.
  29754. */
  29755. Chart.prototype.getSelectedPoints = function () {
  29756. var points = [];
  29757. this.series.forEach(function (serie) {
  29758. // For one-to-one points inspect series.data in order to retrieve
  29759. // points outside the visible range (#6445). For grouped data,
  29760. // inspect the generated series.points.
  29761. points = points.concat(serie.getPointsCollection().filter(function (point) {
  29762. return pick(point.selectedStaging, point.selected);
  29763. }));
  29764. });
  29765. return points;
  29766. };
  29767. /**
  29768. * Returns an array of all currently selected series in the chart. Series
  29769. * can be selected either programmatically by the
  29770. * {@link Highcharts.Series#select}
  29771. * function or by checking the checkbox next to the legend item if
  29772. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  29773. * is true.
  29774. *
  29775. * @sample highcharts/members/chart-getselectedseries/
  29776. * Get selected series
  29777. *
  29778. * @function Highcharts.Chart#getSelectedSeries
  29779. *
  29780. * @return {Array<Highcharts.Series>}
  29781. * The currently selected series.
  29782. */
  29783. Chart.prototype.getSelectedSeries = function () {
  29784. return this.series.filter(function (serie) {
  29785. return serie.selected;
  29786. });
  29787. };
  29788. /**
  29789. * Set a new title or subtitle for the chart.
  29790. *
  29791. * @sample highcharts/members/chart-settitle/
  29792. * Set title text and styles
  29793. *
  29794. * @function Highcharts.Chart#setTitle
  29795. *
  29796. * @param {Highcharts.TitleOptions} [titleOptions]
  29797. * New title options. The title text itself is set by the
  29798. * `titleOptions.text` property.
  29799. *
  29800. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  29801. * New subtitle options. The subtitle text itself is set by the
  29802. * `subtitleOptions.text` property.
  29803. *
  29804. * @param {boolean} [redraw]
  29805. * Whether to redraw the chart or wait for a later call to
  29806. * `chart.redraw()`.
  29807. */
  29808. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  29809. this.applyDescription('title', titleOptions);
  29810. this.applyDescription('subtitle', subtitleOptions);
  29811. // The initial call also adds the caption. On update, chart.update will
  29812. // relay to Chart.setCaption.
  29813. this.applyDescription('caption', void 0);
  29814. this.layOutTitles(redraw);
  29815. };
  29816. /**
  29817. * Apply a title, subtitle or caption for the chart
  29818. *
  29819. * @private
  29820. * @function Highcharts.Chart#applyDescription
  29821. * @param name {string}
  29822. * Either title, subtitle or caption
  29823. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  29824. * The options to set, will be merged with default options.
  29825. */
  29826. Chart.prototype.applyDescription = function (name, explicitOptions) {
  29827. var chart = this;
  29828. // Default style
  29829. var style = name === 'title' ? {
  29830. color: palette.neutralColor80,
  29831. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  29832. } : {
  29833. color: palette.neutralColor60
  29834. };
  29835. // Merge default options with explicit options
  29836. var options = this.options[name] = merge(
  29837. // Default styles
  29838. (!this.styledMode && { style: style }),
  29839. this.options[name],
  29840. explicitOptions);
  29841. var elem = this[name];
  29842. if (elem && explicitOptions) {
  29843. this[name] = elem = elem.destroy(); // remove old
  29844. }
  29845. if (options && !elem) {
  29846. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  29847. .attr({
  29848. align: options.align,
  29849. 'class': 'highcharts-' + name,
  29850. zIndex: options.zIndex || 4
  29851. })
  29852. .add();
  29853. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  29854. // Chart.setCaption
  29855. elem.update = function (updateOptions) {
  29856. var fn = {
  29857. title: 'setTitle',
  29858. subtitle: 'setSubtitle',
  29859. caption: 'setCaption'
  29860. }[name];
  29861. chart[fn](updateOptions);
  29862. };
  29863. // Presentational
  29864. if (!this.styledMode) {
  29865. elem.css(options.style);
  29866. }
  29867. /**
  29868. * The chart title. The title has an `update` method that allows
  29869. * modifying the options directly or indirectly via
  29870. * `chart.update`.
  29871. *
  29872. * @sample highcharts/members/title-update/
  29873. * Updating titles
  29874. *
  29875. * @name Highcharts.Chart#title
  29876. * @type {Highcharts.TitleObject}
  29877. */
  29878. /**
  29879. * The chart subtitle. The subtitle has an `update` method that
  29880. * allows modifying the options directly or indirectly via
  29881. * `chart.update`.
  29882. *
  29883. * @name Highcharts.Chart#subtitle
  29884. * @type {Highcharts.SubtitleObject}
  29885. */
  29886. this[name] = elem;
  29887. }
  29888. };
  29889. /**
  29890. * Internal function to lay out the chart title, subtitle and caption, and
  29891. * cache the full offset height for use in `getMargins`. The result is
  29892. * stored in `this.titleOffset`.
  29893. *
  29894. * @private
  29895. * @function Highcharts.Chart#layOutTitles
  29896. *
  29897. * @param {boolean} [redraw=true]
  29898. * @fires Highcharts.Chart#event:afterLayOutTitles
  29899. */
  29900. Chart.prototype.layOutTitles = function (redraw) {
  29901. var titleOffset = [0, 0, 0],
  29902. requiresDirtyBox,
  29903. renderer = this.renderer,
  29904. spacingBox = this.spacingBox;
  29905. // Lay out the title and the subtitle respectively
  29906. ['title', 'subtitle', 'caption'].forEach(function (key) {
  29907. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  29908. // Floating subtitle (#6574)
  29909. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  29910. if (title) {
  29911. if (!this.styledMode) {
  29912. titleSize = titleOptions.style.fontSize;
  29913. }
  29914. titleSize = renderer.fontMetrics(titleSize, title).b;
  29915. title
  29916. .css({
  29917. width: (titleOptions.width ||
  29918. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  29919. });
  29920. // Skip the cache for HTML (#3481, #11666)
  29921. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  29922. title.align(extend({
  29923. y: verticalAlign === 'bottom' ?
  29924. titleSize :
  29925. offset + titleSize,
  29926. height: height
  29927. }, titleOptions), false, 'spacingBox');
  29928. if (!titleOptions.floating) {
  29929. if (verticalAlign === 'top') {
  29930. titleOffset[0] = Math.ceil(titleOffset[0] +
  29931. height);
  29932. }
  29933. else if (verticalAlign === 'bottom') {
  29934. titleOffset[2] = Math.ceil(titleOffset[2] +
  29935. height);
  29936. }
  29937. }
  29938. }
  29939. }, this);
  29940. // Handle title.margin and caption.margin
  29941. if (titleOffset[0] &&
  29942. (this.options.title.verticalAlign || 'top') === 'top') {
  29943. titleOffset[0] += this.options.title.margin;
  29944. }
  29945. if (titleOffset[2] &&
  29946. this.options.caption.verticalAlign === 'bottom') {
  29947. titleOffset[2] += this.options.caption.margin;
  29948. }
  29949. requiresDirtyBox = (!this.titleOffset ||
  29950. this.titleOffset.join(',') !== titleOffset.join(','));
  29951. // Used in getMargins
  29952. this.titleOffset = titleOffset;
  29953. fireEvent(this, 'afterLayOutTitles');
  29954. if (!this.isDirtyBox && requiresDirtyBox) {
  29955. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  29956. // Redraw if necessary (#2719, #2744)
  29957. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  29958. this.redraw();
  29959. }
  29960. }
  29961. };
  29962. /**
  29963. * Internal function to get the chart width and height according to options
  29964. * and container size. Sets {@link Chart.chartWidth} and
  29965. * {@link Chart.chartHeight}.
  29966. *
  29967. * @private
  29968. * @function Highcharts.Chart#getChartSize
  29969. */
  29970. Chart.prototype.getChartSize = function () {
  29971. var chart = this,
  29972. optionsChart = chart.options.chart,
  29973. widthOption = optionsChart.width,
  29974. heightOption = optionsChart.height,
  29975. renderTo = chart.renderTo;
  29976. // Get inner width and height
  29977. if (!defined(widthOption)) {
  29978. chart.containerWidth = getStyle(renderTo, 'width');
  29979. }
  29980. if (!defined(heightOption)) {
  29981. chart.containerHeight = getStyle(renderTo, 'height');
  29982. }
  29983. /**
  29984. * The current pixel width of the chart.
  29985. *
  29986. * @name Highcharts.Chart#chartWidth
  29987. * @type {number}
  29988. */
  29989. chart.chartWidth = Math.max(// #1393
  29990. 0, widthOption || chart.containerWidth || 600 // #1460
  29991. );
  29992. /**
  29993. * The current pixel height of the chart.
  29994. *
  29995. * @name Highcharts.Chart#chartHeight
  29996. * @type {number}
  29997. */
  29998. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  29999. (chart.containerHeight > 1 ?
  30000. chart.containerHeight :
  30001. 400));
  30002. };
  30003. /**
  30004. * If the renderTo element has no offsetWidth, most likely one or more of
  30005. * its parents are hidden. Loop up the DOM tree to temporarily display the
  30006. * parents, then save the original display properties, and when the true
  30007. * size is retrieved, reset them. Used on first render and on redraws.
  30008. *
  30009. * @private
  30010. * @function Highcharts.Chart#temporaryDisplay
  30011. *
  30012. * @param {boolean} [revert]
  30013. * Revert to the saved original styles.
  30014. */
  30015. Chart.prototype.temporaryDisplay = function (revert) {
  30016. var node = this.renderTo,
  30017. tempStyle;
  30018. if (!revert) {
  30019. while (node && node.style) {
  30020. // When rendering to a detached node, it needs to be temporarily
  30021. // attached in order to read styling and bounding boxes (#5783,
  30022. // #7024).
  30023. if (!doc.body.contains(node) && !node.parentNode) {
  30024. node.hcOrigDetached = true;
  30025. doc.body.appendChild(node);
  30026. }
  30027. if (getStyle(node, 'display', false) === 'none' ||
  30028. node.hcOricDetached) {
  30029. node.hcOrigStyle = {
  30030. display: node.style.display,
  30031. height: node.style.height,
  30032. overflow: node.style.overflow
  30033. };
  30034. tempStyle = {
  30035. display: 'block',
  30036. overflow: 'hidden'
  30037. };
  30038. if (node !== this.renderTo) {
  30039. tempStyle.height = 0;
  30040. }
  30041. css(node, tempStyle);
  30042. // If it still doesn't have an offset width after setting
  30043. // display to block, it probably has an !important priority
  30044. // #2631, 6803
  30045. if (!node.offsetWidth) {
  30046. node.style.setProperty('display', 'block', 'important');
  30047. }
  30048. }
  30049. node = node.parentNode;
  30050. if (node === doc.body) {
  30051. break;
  30052. }
  30053. }
  30054. }
  30055. else {
  30056. while (node && node.style) {
  30057. if (node.hcOrigStyle) {
  30058. css(node, node.hcOrigStyle);
  30059. delete node.hcOrigStyle;
  30060. }
  30061. if (node.hcOrigDetached) {
  30062. doc.body.removeChild(node);
  30063. node.hcOrigDetached = false;
  30064. }
  30065. node = node.parentNode;
  30066. }
  30067. }
  30068. };
  30069. /**
  30070. * Set the {@link Chart.container|chart container's} class name, in
  30071. * addition to `highcharts-container`.
  30072. *
  30073. * @function Highcharts.Chart#setClassName
  30074. *
  30075. * @param {string} [className]
  30076. * The additional class name.
  30077. */
  30078. Chart.prototype.setClassName = function (className) {
  30079. this.container.className = 'highcharts-container ' + (className || '');
  30080. };
  30081. /**
  30082. * Get the containing element, determine the size and create the inner
  30083. * container div to hold the chart.
  30084. *
  30085. * @private
  30086. * @function Highcharts.Chart#afterGetContainer
  30087. * @fires Highcharts.Chart#event:afterGetContainer
  30088. */
  30089. Chart.prototype.getContainer = function () {
  30090. var chart = this,
  30091. container,
  30092. options = chart.options,
  30093. optionsChart = options.chart,
  30094. chartWidth,
  30095. chartHeight,
  30096. renderTo = chart.renderTo,
  30097. indexAttrName = 'data-highcharts-chart',
  30098. oldChartIndex,
  30099. Ren,
  30100. containerId = uniqueKey(),
  30101. containerStyle,
  30102. key;
  30103. if (!renderTo) {
  30104. chart.renderTo = renderTo =
  30105. optionsChart.renderTo;
  30106. }
  30107. if (isString(renderTo)) {
  30108. chart.renderTo = renderTo =
  30109. doc.getElementById(renderTo);
  30110. }
  30111. // Display an error if the renderTo is wrong
  30112. if (!renderTo) {
  30113. error(13, true, chart);
  30114. }
  30115. // If the container already holds a chart, destroy it. The check for
  30116. // hasRendered is there because web pages that are saved to disk from
  30117. // the browser, will preserve the data-highcharts-chart attribute and
  30118. // the SVG contents, but not an interactive chart. So in this case,
  30119. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  30120. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  30121. if (isNumber(oldChartIndex) &&
  30122. charts[oldChartIndex] &&
  30123. charts[oldChartIndex].hasRendered) {
  30124. charts[oldChartIndex].destroy();
  30125. }
  30126. // Make a reference to the chart from the div
  30127. attr(renderTo, indexAttrName, chart.index);
  30128. // remove previous chart
  30129. renderTo.innerHTML = '';
  30130. // If the container doesn't have an offsetWidth, it has or is a child of
  30131. // a node that has display:none. We need to temporarily move it out to a
  30132. // visible state to determine the size, else the legend and tooltips
  30133. // won't render properly. The skipClone option is used in sparklines as
  30134. // a micro optimization, saving about 1-2 ms each chart.
  30135. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  30136. chart.temporaryDisplay();
  30137. }
  30138. // get the width and height
  30139. chart.getChartSize();
  30140. chartWidth = chart.chartWidth;
  30141. chartHeight = chart.chartHeight;
  30142. // Allow table cells and flex-boxes to shrink without the chart blocking
  30143. // them out (#6427)
  30144. css(renderTo, { overflow: 'hidden' });
  30145. // Create the inner container
  30146. if (!chart.styledMode) {
  30147. containerStyle = extend({
  30148. position: 'relative',
  30149. // needed for context menu (avoidscrollbars) and content
  30150. // overflow in IE
  30151. overflow: 'hidden',
  30152. width: chartWidth + 'px',
  30153. height: chartHeight + 'px',
  30154. textAlign: 'left',
  30155. lineHeight: 'normal',
  30156. zIndex: 0,
  30157. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  30158. userSelect: 'none',
  30159. 'touch-action': 'manipulation',
  30160. outline: 'none'
  30161. }, optionsChart.style || {});
  30162. }
  30163. /**
  30164. * The containing HTML element of the chart. The container is
  30165. * dynamically inserted into the element given as the `renderTo`
  30166. * parameter in the {@link Highcharts#chart} constructor.
  30167. *
  30168. * @name Highcharts.Chart#container
  30169. * @type {Highcharts.HTMLDOMElement}
  30170. */
  30171. container = createElement('div', {
  30172. id: containerId
  30173. }, containerStyle, renderTo);
  30174. chart.container = container;
  30175. // cache the cursor (#1650)
  30176. chart._cursor = container.style.cursor;
  30177. // Initialize the renderer
  30178. Ren = H[optionsChart.renderer] || H.Renderer;
  30179. /**
  30180. * The renderer instance of the chart. Each chart instance has only one
  30181. * associated renderer.
  30182. *
  30183. * @name Highcharts.Chart#renderer
  30184. * @type {Highcharts.SVGRenderer}
  30185. */
  30186. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  30187. // Set the initial animation from the options
  30188. setAnimation(void 0, chart);
  30189. chart.setClassName(optionsChart.className);
  30190. if (!chart.styledMode) {
  30191. chart.renderer.setStyle(optionsChart.style);
  30192. }
  30193. else {
  30194. // Initialize definitions
  30195. for (key in options.defs) { // eslint-disable-line guard-for-in
  30196. this.renderer.definition(options.defs[key]);
  30197. }
  30198. }
  30199. // Add a reference to the charts index
  30200. chart.renderer.chartIndex = chart.index;
  30201. fireEvent(this, 'afterGetContainer');
  30202. };
  30203. /**
  30204. * Calculate margins by rendering axis labels in a preliminary position.
  30205. * Title, subtitle and legend have already been rendered at this stage, but
  30206. * will be moved into their final positions.
  30207. *
  30208. * @private
  30209. * @function Highcharts.Chart#getMargins
  30210. * @fires Highcharts.Chart#event:getMargins
  30211. */
  30212. Chart.prototype.getMargins = function (skipAxes) {
  30213. var _a = this,
  30214. spacing = _a.spacing,
  30215. margin = _a.margin,
  30216. titleOffset = _a.titleOffset;
  30217. this.resetMargins();
  30218. // Adjust for title and subtitle
  30219. if (titleOffset[0] && !defined(margin[0])) {
  30220. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  30221. }
  30222. if (titleOffset[2] && !defined(margin[2])) {
  30223. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  30224. }
  30225. // Adjust for legend
  30226. if (this.legend && this.legend.display) {
  30227. this.legend.adjustMargins(margin, spacing);
  30228. }
  30229. fireEvent(this, 'getMargins');
  30230. if (!skipAxes) {
  30231. this.getAxisMargins();
  30232. }
  30233. };
  30234. /**
  30235. * @private
  30236. * @function Highcharts.Chart#getAxisMargins
  30237. */
  30238. Chart.prototype.getAxisMargins = function () {
  30239. var chart = this,
  30240. // [top, right, bottom, left]
  30241. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  30242. colorAxis = chart.colorAxis,
  30243. margin = chart.margin,
  30244. getOffset = function (axes) {
  30245. axes.forEach(function (axis) {
  30246. if (axis.visible) {
  30247. axis.getOffset();
  30248. }
  30249. });
  30250. };
  30251. // pre-render axes to get labels offset width
  30252. if (chart.hasCartesianSeries) {
  30253. getOffset(chart.axes);
  30254. }
  30255. else if (colorAxis && colorAxis.length) {
  30256. getOffset(colorAxis);
  30257. }
  30258. // Add the axis offsets
  30259. marginNames.forEach(function (m, side) {
  30260. if (!defined(margin[side])) {
  30261. chart[m] += axisOffset[side];
  30262. }
  30263. });
  30264. chart.setChartSize();
  30265. };
  30266. /**
  30267. * Reflows the chart to its container. By default, the chart reflows
  30268. * automatically to its container following a `window.resize` event, as per
  30269. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  30270. * option. However, there are no reliable events for div resize, so if the
  30271. * container is resized without a window resize event, this must be called
  30272. * explicitly.
  30273. *
  30274. * @sample highcharts/members/chart-reflow/
  30275. * Resize div and reflow
  30276. * @sample highcharts/chart/events-container/
  30277. * Pop up and reflow
  30278. *
  30279. * @function Highcharts.Chart#reflow
  30280. *
  30281. * @param {global.Event} [e]
  30282. * Event arguments. Used primarily when the function is called
  30283. * internally as a response to window resize.
  30284. */
  30285. Chart.prototype.reflow = function (e) {
  30286. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  30287. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  30288. delete chart.pointer.chartPosition;
  30289. // Width and height checks for display:none. Target is doc in IE8 and
  30290. // Opera, win in Firefox, Chrome and IE9.
  30291. if (!hasUserSize &&
  30292. !chart.isPrinting &&
  30293. width &&
  30294. height &&
  30295. (target === win || target === doc)) {
  30296. if (width !== chart.containerWidth ||
  30297. height !== chart.containerHeight) {
  30298. U.clearTimeout(chart.reflowTimeout);
  30299. // When called from window.resize, e is set, else it's called
  30300. // directly (#2224)
  30301. chart.reflowTimeout = syncTimeout(function () {
  30302. // Set size, it may have been destroyed in the meantime
  30303. // (#1257)
  30304. if (chart.container) {
  30305. chart.setSize(void 0, void 0, false);
  30306. }
  30307. }, e ? 100 : 0);
  30308. }
  30309. chart.containerWidth = width;
  30310. chart.containerHeight = height;
  30311. }
  30312. };
  30313. /**
  30314. * Toggle the event handlers necessary for auto resizing, depending on the
  30315. * `chart.reflow` option.
  30316. *
  30317. * @private
  30318. * @function Highcharts.Chart#setReflow
  30319. */
  30320. Chart.prototype.setReflow = function (reflow) {
  30321. var chart = this;
  30322. if (reflow !== false && !this.unbindReflow) {
  30323. this.unbindReflow = addEvent(win, 'resize', function (e) {
  30324. // a removed event listener still runs in Edge and IE if the
  30325. // listener was removed while the event runs, so check if the
  30326. // chart is not destroyed (#11609)
  30327. if (chart.options) {
  30328. chart.reflow(e);
  30329. }
  30330. });
  30331. addEvent(this, 'destroy', this.unbindReflow);
  30332. }
  30333. else if (reflow === false && this.unbindReflow) {
  30334. // Unbind and unset
  30335. this.unbindReflow = this.unbindReflow();
  30336. }
  30337. // The following will add listeners to re-fit the chart before and after
  30338. // printing (#2284). However it only works in WebKit. Should have worked
  30339. // in Firefox, but not supported in IE.
  30340. /*
  30341. if (win.matchMedia) {
  30342. win.matchMedia('print').addListener(function reflow() {
  30343. chart.reflow();
  30344. });
  30345. }
  30346. //*/
  30347. };
  30348. /**
  30349. * Resize the chart to a given width and height. In order to set the width
  30350. * only, the height argument may be skipped. To set the height only, pass
  30351. * `undefined` for the width.
  30352. *
  30353. * @sample highcharts/members/chart-setsize-button/
  30354. * Test resizing from buttons
  30355. * @sample highcharts/members/chart-setsize-jquery-resizable/
  30356. * Add a jQuery UI resizable
  30357. * @sample stock/members/chart-setsize/
  30358. * Highcharts Stock with UI resizable
  30359. *
  30360. * @function Highcharts.Chart#setSize
  30361. *
  30362. * @param {number|null} [width]
  30363. * The new pixel width of the chart. Since v4.2.6, the argument can
  30364. * be `undefined` in order to preserve the current value (when
  30365. * setting height only), or `null` to adapt to the width of the
  30366. * containing element.
  30367. *
  30368. * @param {number|null} [height]
  30369. * The new pixel height of the chart. Since v4.2.6, the argument can
  30370. * be `undefined` in order to preserve the current value, or `null`
  30371. * in order to adapt to the height of the containing element.
  30372. *
  30373. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  30374. * Whether and how to apply animation.
  30375. *
  30376. * @return {void}
  30377. *
  30378. * @fires Highcharts.Chart#event:endResize
  30379. * @fires Highcharts.Chart#event:resize
  30380. */
  30381. Chart.prototype.setSize = function (width, height, animation) {
  30382. var chart = this,
  30383. renderer = chart.renderer,
  30384. globalAnimation;
  30385. // Handle the isResizing counter
  30386. chart.isResizing += 1;
  30387. // set the animation for the current process
  30388. setAnimation(animation, chart);
  30389. globalAnimation = renderer.globalAnimation;
  30390. chart.oldChartHeight = chart.chartHeight;
  30391. chart.oldChartWidth = chart.chartWidth;
  30392. if (typeof width !== 'undefined') {
  30393. chart.options.chart.width = width;
  30394. }
  30395. if (typeof height !== 'undefined') {
  30396. chart.options.chart.height = height;
  30397. }
  30398. chart.getChartSize();
  30399. // Resize the container with the global animation applied if enabled
  30400. // (#2503)
  30401. if (!chart.styledMode) {
  30402. (globalAnimation ? animate : css)(chart.container, {
  30403. width: chart.chartWidth + 'px',
  30404. height: chart.chartHeight + 'px'
  30405. }, globalAnimation);
  30406. }
  30407. chart.setChartSize(true);
  30408. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  30409. // handle axes
  30410. chart.axes.forEach(function (axis) {
  30411. axis.isDirty = true;
  30412. axis.setScale();
  30413. });
  30414. chart.isDirtyLegend = true; // force legend redraw
  30415. chart.isDirtyBox = true; // force redraw of plot and chart border
  30416. chart.layOutTitles(); // #2857
  30417. chart.getMargins();
  30418. chart.redraw(globalAnimation);
  30419. chart.oldChartHeight = null;
  30420. fireEvent(chart, 'resize');
  30421. // Fire endResize and set isResizing back. If animation is disabled,
  30422. // fire without delay
  30423. syncTimeout(function () {
  30424. if (chart) {
  30425. fireEvent(chart, 'endResize', null, function () {
  30426. chart.isResizing -= 1;
  30427. });
  30428. }
  30429. }, animObject(globalAnimation).duration);
  30430. };
  30431. /**
  30432. * Set the public chart properties. This is done before and after the
  30433. * pre-render to determine margin sizes.
  30434. *
  30435. * @private
  30436. * @function Highcharts.Chart#setChartSize
  30437. * @fires Highcharts.Chart#event:afterSetChartSize
  30438. */
  30439. Chart.prototype.setChartSize = function (skipAxes) {
  30440. var chart = this,
  30441. inverted = chart.inverted,
  30442. renderer = chart.renderer,
  30443. chartWidth = chart.chartWidth,
  30444. chartHeight = chart.chartHeight,
  30445. optionsChart = chart.options.chart,
  30446. spacing = chart.spacing,
  30447. clipOffset = chart.clipOffset,
  30448. clipX,
  30449. clipY,
  30450. plotLeft,
  30451. plotTop,
  30452. plotWidth,
  30453. plotHeight,
  30454. plotBorderWidth;
  30455. /**
  30456. * The current left position of the plot area in pixels.
  30457. *
  30458. * @name Highcharts.Chart#plotLeft
  30459. * @type {number}
  30460. */
  30461. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  30462. /**
  30463. * The current top position of the plot area in pixels.
  30464. *
  30465. * @name Highcharts.Chart#plotTop
  30466. * @type {number}
  30467. */
  30468. chart.plotTop = plotTop = Math.round(chart.plotTop);
  30469. /**
  30470. * The current width of the plot area in pixels.
  30471. *
  30472. * @name Highcharts.Chart#plotWidth
  30473. * @type {number}
  30474. */
  30475. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  30476. /**
  30477. * The current height of the plot area in pixels.
  30478. *
  30479. * @name Highcharts.Chart#plotHeight
  30480. * @type {number}
  30481. */
  30482. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  30483. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  30484. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  30485. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  30486. // Set boxes used for alignment
  30487. chart.spacingBox = renderer.spacingBox = {
  30488. x: spacing[3],
  30489. y: spacing[0],
  30490. width: chartWidth - spacing[3] - spacing[1],
  30491. height: chartHeight - spacing[0] - spacing[2]
  30492. };
  30493. chart.plotBox = renderer.plotBox = {
  30494. x: plotLeft,
  30495. y: plotTop,
  30496. width: plotWidth,
  30497. height: plotHeight
  30498. };
  30499. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  30500. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  30501. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  30502. chart.clipBox = {
  30503. x: clipX,
  30504. y: clipY,
  30505. width: Math.floor(chart.plotSizeX -
  30506. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  30507. clipX),
  30508. height: Math.max(0, Math.floor(chart.plotSizeY -
  30509. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  30510. clipY))
  30511. };
  30512. if (!skipAxes) {
  30513. chart.axes.forEach(function (axis) {
  30514. axis.setAxisSize();
  30515. axis.setAxisTranslation();
  30516. });
  30517. renderer.alignElements();
  30518. }
  30519. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  30520. };
  30521. /**
  30522. * Initial margins before auto size margins are applied.
  30523. *
  30524. * @private
  30525. * @function Highcharts.Chart#resetMargins
  30526. */
  30527. Chart.prototype.resetMargins = function () {
  30528. fireEvent(this, 'resetMargins');
  30529. var chart = this,
  30530. chartOptions = chart.options.chart;
  30531. // Create margin and spacing array
  30532. ['margin', 'spacing'].forEach(function splashArrays(target) {
  30533. var value = chartOptions[target],
  30534. values = isObject(value) ? value : [value,
  30535. value,
  30536. value,
  30537. value];
  30538. [
  30539. 'Top',
  30540. 'Right',
  30541. 'Bottom',
  30542. 'Left'
  30543. ].forEach(function (sideName, side) {
  30544. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  30545. });
  30546. });
  30547. // Set margin names like chart.plotTop, chart.plotLeft,
  30548. // chart.marginRight, chart.marginBottom.
  30549. marginNames.forEach(function (m, side) {
  30550. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  30551. });
  30552. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  30553. chart.clipOffset = [0, 0, 0, 0];
  30554. };
  30555. /**
  30556. * Internal function to draw or redraw the borders and backgrounds for chart
  30557. * and plot area.
  30558. *
  30559. * @private
  30560. * @function Highcharts.Chart#drawChartBox
  30561. * @fires Highcharts.Chart#event:afterDrawChartBox
  30562. */
  30563. Chart.prototype.drawChartBox = function () {
  30564. var chart = this,
  30565. optionsChart = chart.options.chart,
  30566. renderer = chart.renderer,
  30567. chartWidth = chart.chartWidth,
  30568. chartHeight = chart.chartHeight,
  30569. chartBackground = chart.chartBackground,
  30570. plotBackground = chart.plotBackground,
  30571. plotBorder = chart.plotBorder,
  30572. chartBorderWidth,
  30573. styledMode = chart.styledMode,
  30574. plotBGImage = chart.plotBGImage,
  30575. chartBackgroundColor = optionsChart.backgroundColor,
  30576. plotBackgroundColor = optionsChart.plotBackgroundColor,
  30577. plotBackgroundImage = optionsChart.plotBackgroundImage,
  30578. mgn,
  30579. bgAttr,
  30580. plotLeft = chart.plotLeft,
  30581. plotTop = chart.plotTop,
  30582. plotWidth = chart.plotWidth,
  30583. plotHeight = chart.plotHeight,
  30584. plotBox = chart.plotBox,
  30585. clipRect = chart.clipRect,
  30586. clipBox = chart.clipBox,
  30587. verb = 'animate';
  30588. // Chart area
  30589. if (!chartBackground) {
  30590. chart.chartBackground = chartBackground = renderer.rect()
  30591. .addClass('highcharts-background')
  30592. .add();
  30593. verb = 'attr';
  30594. }
  30595. if (!styledMode) {
  30596. // Presentational
  30597. chartBorderWidth = optionsChart.borderWidth || 0;
  30598. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  30599. bgAttr = {
  30600. fill: chartBackgroundColor || 'none'
  30601. };
  30602. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  30603. bgAttr.stroke = optionsChart.borderColor;
  30604. bgAttr['stroke-width'] = chartBorderWidth;
  30605. }
  30606. chartBackground
  30607. .attr(bgAttr)
  30608. .shadow(optionsChart.shadow);
  30609. }
  30610. else {
  30611. chartBorderWidth = mgn = chartBackground.strokeWidth();
  30612. }
  30613. chartBackground[verb]({
  30614. x: mgn / 2,
  30615. y: mgn / 2,
  30616. width: chartWidth - mgn - chartBorderWidth % 2,
  30617. height: chartHeight - mgn - chartBorderWidth % 2,
  30618. r: optionsChart.borderRadius
  30619. });
  30620. // Plot background
  30621. verb = 'animate';
  30622. if (!plotBackground) {
  30623. verb = 'attr';
  30624. chart.plotBackground = plotBackground = renderer.rect()
  30625. .addClass('highcharts-plot-background')
  30626. .add();
  30627. }
  30628. plotBackground[verb](plotBox);
  30629. if (!styledMode) {
  30630. // Presentational attributes for the background
  30631. plotBackground
  30632. .attr({
  30633. fill: plotBackgroundColor || 'none'
  30634. })
  30635. .shadow(optionsChart.plotShadow);
  30636. // Create the background image
  30637. if (plotBackgroundImage) {
  30638. if (!plotBGImage) {
  30639. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  30640. }
  30641. else {
  30642. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  30643. plotBGImage.attr('href', plotBackgroundImage);
  30644. }
  30645. plotBGImage.animate(plotBox);
  30646. }
  30647. }
  30648. }
  30649. // Plot clip
  30650. if (!clipRect) {
  30651. chart.clipRect = renderer.clipRect(clipBox);
  30652. }
  30653. else {
  30654. clipRect.animate({
  30655. width: clipBox.width,
  30656. height: clipBox.height
  30657. });
  30658. }
  30659. // Plot area border
  30660. verb = 'animate';
  30661. if (!plotBorder) {
  30662. verb = 'attr';
  30663. chart.plotBorder = plotBorder = renderer.rect()
  30664. .addClass('highcharts-plot-border')
  30665. .attr({
  30666. zIndex: 1 // Above the grid
  30667. })
  30668. .add();
  30669. }
  30670. if (!styledMode) {
  30671. // Presentational
  30672. plotBorder.attr({
  30673. stroke: optionsChart.plotBorderColor,
  30674. 'stroke-width': optionsChart.plotBorderWidth || 0,
  30675. fill: 'none'
  30676. });
  30677. }
  30678. plotBorder[verb](plotBorder.crisp({
  30679. x: plotLeft,
  30680. y: plotTop,
  30681. width: plotWidth,
  30682. height: plotHeight
  30683. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  30684. // reset
  30685. chart.isDirtyBox = false;
  30686. fireEvent(this, 'afterDrawChartBox');
  30687. };
  30688. /**
  30689. * Detect whether a certain chart property is needed based on inspecting its
  30690. * options and series. This mainly applies to the chart.inverted property,
  30691. * and in extensions to the chart.angular and chart.polar properties.
  30692. *
  30693. * @private
  30694. * @function Highcharts.Chart#propFromSeries
  30695. * @return {void}
  30696. */
  30697. Chart.prototype.propFromSeries = function () {
  30698. var chart = this,
  30699. optionsChart = chart.options.chart,
  30700. klass,
  30701. seriesOptions = chart.options.series,
  30702. i,
  30703. value;
  30704. /**
  30705. * The flag is set to `true` if a series of the chart is inverted.
  30706. *
  30707. * @name Highcharts.Chart#inverted
  30708. * @type {boolean|undefined}
  30709. */
  30710. ['inverted', 'angular', 'polar'].forEach(function (key) {
  30711. // The default series type's class
  30712. klass = seriesTypes[(optionsChart.type || optionsChart.defaultSeriesType)];
  30713. // Get the value from available chart-wide properties
  30714. value =
  30715. // It is set in the options:
  30716. optionsChart[key] ||
  30717. // The default series class:
  30718. (klass && klass.prototype[key]);
  30719. // requires it
  30720. // 4. Check if any the chart's series require it
  30721. i = seriesOptions && seriesOptions.length;
  30722. while (!value && i--) {
  30723. klass = seriesTypes[seriesOptions[i].type];
  30724. if (klass && klass.prototype[key]) {
  30725. value = true;
  30726. }
  30727. }
  30728. // Set the chart property
  30729. chart[key] = value;
  30730. });
  30731. };
  30732. /**
  30733. * Internal function to link two or more series together, based on the
  30734. * `linkedTo` option. This is done from `Chart.render`, and after
  30735. * `Chart.addSeries` and `Series.remove`.
  30736. *
  30737. * @private
  30738. * @function Highcharts.Chart#linkSeries
  30739. * @fires Highcharts.Chart#event:afterLinkSeries
  30740. */
  30741. Chart.prototype.linkSeries = function () {
  30742. var chart = this,
  30743. chartSeries = chart.series;
  30744. // Reset links
  30745. chartSeries.forEach(function (series) {
  30746. series.linkedSeries.length = 0;
  30747. });
  30748. // Apply new links
  30749. chartSeries.forEach(function (series) {
  30750. var linkedTo = series.options.linkedTo;
  30751. if (isString(linkedTo)) {
  30752. if (linkedTo === ':previous') {
  30753. linkedTo = chart.series[series.index - 1];
  30754. }
  30755. else {
  30756. linkedTo = chart.get(linkedTo);
  30757. }
  30758. // #3341 avoid mutual linking
  30759. if (linkedTo && linkedTo.linkedParent !== series) {
  30760. linkedTo.linkedSeries.push(series);
  30761. series.linkedParent = linkedTo;
  30762. if (linkedTo.enabledDataSorting) {
  30763. series.setDataSortingOptions();
  30764. }
  30765. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  30766. }
  30767. }
  30768. });
  30769. fireEvent(this, 'afterLinkSeries');
  30770. };
  30771. /**
  30772. * Render series for the chart.
  30773. *
  30774. * @private
  30775. * @function Highcharts.Chart#renderSeries
  30776. */
  30777. Chart.prototype.renderSeries = function () {
  30778. this.series.forEach(function (serie) {
  30779. serie.translate();
  30780. serie.render();
  30781. });
  30782. };
  30783. /**
  30784. * Render labels for the chart.
  30785. *
  30786. * @private
  30787. * @function Highcharts.Chart#renderLabels
  30788. */
  30789. Chart.prototype.renderLabels = function () {
  30790. var chart = this,
  30791. labels = chart.options.labels;
  30792. if (labels.items) {
  30793. labels.items.forEach(function (label) {
  30794. var style = extend(labels.style,
  30795. label.style),
  30796. x = pInt(style.left) + chart.plotLeft,
  30797. y = pInt(style.top) + chart.plotTop + 12;
  30798. // delete to prevent rewriting in IE
  30799. delete style.left;
  30800. delete style.top;
  30801. chart.renderer.text(label.html, x, y)
  30802. .attr({ zIndex: 2 })
  30803. .css(style)
  30804. .add();
  30805. });
  30806. }
  30807. };
  30808. /**
  30809. * Render all graphics for the chart. Runs internally on initialization.
  30810. *
  30811. * @private
  30812. * @function Highcharts.Chart#render
  30813. */
  30814. Chart.prototype.render = function () {
  30815. var chart = this,
  30816. axes = chart.axes,
  30817. colorAxis = chart.colorAxis,
  30818. renderer = chart.renderer,
  30819. options = chart.options,
  30820. correction = 0, // correction for X axis labels
  30821. tempWidth,
  30822. tempHeight,
  30823. redoHorizontal,
  30824. redoVertical,
  30825. renderAxes = function (axes) {
  30826. axes.forEach(function (axis) {
  30827. if (axis.visible) {
  30828. axis.render();
  30829. }
  30830. });
  30831. };
  30832. // Title
  30833. chart.setTitle();
  30834. /**
  30835. * The overview of the chart's series.
  30836. *
  30837. * @name Highcharts.Chart#legend
  30838. * @type {Highcharts.Legend}
  30839. */
  30840. chart.legend = new Legend(chart, options.legend);
  30841. // Get stacks
  30842. if (chart.getStacks) {
  30843. chart.getStacks();
  30844. }
  30845. // Get chart margins
  30846. chart.getMargins(true);
  30847. chart.setChartSize();
  30848. // Record preliminary dimensions for later comparison
  30849. tempWidth = chart.plotWidth;
  30850. axes.some(function (axis) {
  30851. if (axis.horiz &&
  30852. axis.visible &&
  30853. axis.options.labels.enabled &&
  30854. axis.series.length) {
  30855. // 21 is the most common correction for X axis labels
  30856. correction = 21;
  30857. return true;
  30858. }
  30859. });
  30860. // use Math.max to prevent negative plotHeight
  30861. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  30862. tempHeight = chart.plotHeight;
  30863. // Get margins by pre-rendering axes
  30864. axes.forEach(function (axis) {
  30865. axis.setScale();
  30866. });
  30867. chart.getAxisMargins();
  30868. // If the plot area size has changed significantly, calculate tick
  30869. // positions again
  30870. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  30871. // Height is more sensitive, use lower threshold
  30872. redoVertical = tempHeight / chart.plotHeight > 1.05;
  30873. if (redoHorizontal || redoVertical) {
  30874. axes.forEach(function (axis) {
  30875. if ((axis.horiz && redoHorizontal) ||
  30876. (!axis.horiz && redoVertical)) {
  30877. // update to reflect the new margins
  30878. axis.setTickInterval(true);
  30879. }
  30880. });
  30881. chart.getMargins(); // second pass to check for new labels
  30882. }
  30883. // Draw the borders and backgrounds
  30884. chart.drawChartBox();
  30885. // Axes
  30886. if (chart.hasCartesianSeries) {
  30887. renderAxes(axes);
  30888. }
  30889. else if (colorAxis && colorAxis.length) {
  30890. renderAxes(colorAxis);
  30891. }
  30892. // The series
  30893. if (!chart.seriesGroup) {
  30894. chart.seriesGroup = renderer.g('series-group')
  30895. .attr({ zIndex: 3 })
  30896. .add();
  30897. }
  30898. chart.renderSeries();
  30899. // Labels
  30900. chart.renderLabels();
  30901. // Credits
  30902. chart.addCredits();
  30903. // Handle responsiveness
  30904. if (chart.setResponsive) {
  30905. chart.setResponsive();
  30906. }
  30907. // Set flag
  30908. chart.hasRendered = true;
  30909. };
  30910. /**
  30911. * Set a new credits label for the chart.
  30912. *
  30913. * @sample highcharts/credits/credits-update/
  30914. * Add and update credits
  30915. *
  30916. * @function Highcharts.Chart#addCredits
  30917. *
  30918. * @param {Highcharts.CreditsOptions} [credits]
  30919. * A configuration object for the new credits.
  30920. */
  30921. Chart.prototype.addCredits = function (credits) {
  30922. var chart = this,
  30923. creds = merge(true,
  30924. this.options.credits,
  30925. credits);
  30926. if (creds.enabled && !this.credits) {
  30927. /**
  30928. * The chart's credits label. The label has an `update` method that
  30929. * allows setting new options as per the
  30930. * [credits options set](https://api.highcharts.com/highcharts/credits).
  30931. *
  30932. * @name Highcharts.Chart#credits
  30933. * @type {Highcharts.SVGElement}
  30934. */
  30935. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  30936. .addClass('highcharts-credits')
  30937. .on('click', function () {
  30938. if (creds.href) {
  30939. win.location.href = creds.href;
  30940. }
  30941. })
  30942. .attr({
  30943. align: creds.position.align,
  30944. zIndex: 8
  30945. });
  30946. if (!chart.styledMode) {
  30947. this.credits.css(creds.style);
  30948. }
  30949. this.credits
  30950. .add()
  30951. .align(creds.position);
  30952. // Dynamically update
  30953. this.credits.update = function (options) {
  30954. chart.credits = chart.credits.destroy();
  30955. chart.addCredits(options);
  30956. };
  30957. }
  30958. };
  30959. /**
  30960. * Remove the chart and purge memory. This method is called internally
  30961. * before adding a second chart into the same container, as well as on
  30962. * window unload to prevent leaks.
  30963. *
  30964. * @sample highcharts/members/chart-destroy/
  30965. * Destroy the chart from a button
  30966. * @sample stock/members/chart-destroy/
  30967. * Destroy with Highcharts Stock
  30968. *
  30969. * @function Highcharts.Chart#destroy
  30970. *
  30971. * @fires Highcharts.Chart#event:destroy
  30972. */
  30973. Chart.prototype.destroy = function () {
  30974. var chart = this,
  30975. axes = chart.axes,
  30976. series = chart.series,
  30977. container = chart.container,
  30978. i,
  30979. parentNode = container && container.parentNode;
  30980. // fire the chart.destoy event
  30981. fireEvent(chart, 'destroy');
  30982. // Delete the chart from charts lookup array
  30983. if (chart.renderer.forExport) {
  30984. erase(charts, chart); // #6569
  30985. }
  30986. else {
  30987. charts[chart.index] = void 0;
  30988. }
  30989. H.chartCount--;
  30990. chart.renderTo.removeAttribute('data-highcharts-chart');
  30991. // remove events
  30992. removeEvent(chart);
  30993. // ==== Destroy collections:
  30994. // Destroy axes
  30995. i = axes.length;
  30996. while (i--) {
  30997. axes[i] = axes[i].destroy();
  30998. }
  30999. // Destroy scroller & scroller series before destroying base series
  31000. if (this.scroller && this.scroller.destroy) {
  31001. this.scroller.destroy();
  31002. }
  31003. // Destroy each series
  31004. i = series.length;
  31005. while (i--) {
  31006. series[i] = series[i].destroy();
  31007. }
  31008. // ==== Destroy chart properties:
  31009. [
  31010. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  31011. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  31012. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  31013. 'renderer'
  31014. ].forEach(function (name) {
  31015. var prop = chart[name];
  31016. if (prop && prop.destroy) {
  31017. chart[name] = prop.destroy();
  31018. }
  31019. });
  31020. // Remove container and all SVG, check container as it can break in IE
  31021. // when destroyed before finished loading
  31022. if (container) {
  31023. container.innerHTML = '';
  31024. removeEvent(container);
  31025. if (parentNode) {
  31026. discardElement(container);
  31027. }
  31028. }
  31029. // clean it all up
  31030. objectEach(chart, function (val, key) {
  31031. delete chart[key];
  31032. });
  31033. };
  31034. /**
  31035. * Prepare for first rendering after all data are loaded.
  31036. *
  31037. * @private
  31038. * @function Highcharts.Chart#firstRender
  31039. * @fires Highcharts.Chart#event:beforeRender
  31040. */
  31041. Chart.prototype.firstRender = function () {
  31042. var chart = this,
  31043. options = chart.options;
  31044. // Hook for oldIE to check whether the chart is ready to render
  31045. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  31046. return;
  31047. }
  31048. // Create the container
  31049. chart.getContainer();
  31050. chart.resetMargins();
  31051. chart.setChartSize();
  31052. // Set the common chart properties (mainly invert) from the given series
  31053. chart.propFromSeries();
  31054. // get axes
  31055. chart.getAxes();
  31056. // Initialize the series
  31057. (isArray(options.series) ? options.series : []).forEach(
  31058. // #9680
  31059. function (serieOptions) {
  31060. chart.initSeries(serieOptions);
  31061. });
  31062. chart.linkSeries();
  31063. chart.setSeriesData();
  31064. // Run an event after axes and series are initialized, but before
  31065. // render. At this stage, the series data is indexed and cached in the
  31066. // xData and yData arrays, so we can access those before rendering. Used
  31067. // in Highcharts Stock.
  31068. fireEvent(chart, 'beforeRender');
  31069. // depends on inverted and on margins being set
  31070. if (Pointer) {
  31071. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  31072. chart.pointer = new MSPointer(chart, options);
  31073. }
  31074. else {
  31075. /**
  31076. * The Pointer that keeps track of mouse and touch interaction.
  31077. *
  31078. * @memberof Highcharts.Chart
  31079. * @name pointer
  31080. * @type {Highcharts.Pointer}
  31081. * @instance
  31082. */
  31083. chart.pointer = new Pointer(chart, options);
  31084. }
  31085. }
  31086. chart.render();
  31087. chart.pointer.getChartPosition(); // #14973
  31088. // Fire the load event if there are no external images
  31089. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  31090. chart.onload();
  31091. }
  31092. // If the chart was rendered outside the top container, put it back in
  31093. // (#3679)
  31094. chart.temporaryDisplay(true);
  31095. };
  31096. /**
  31097. * Internal function that runs on chart load, async if any images are loaded
  31098. * in the chart. Runs the callbacks and triggers the `load` and `render`
  31099. * events.
  31100. *
  31101. * @private
  31102. * @function Highcharts.Chart#onload
  31103. * @fires Highcharts.Chart#event:load
  31104. * @fires Highcharts.Chart#event:render
  31105. */
  31106. Chart.prototype.onload = function () {
  31107. // Run callbacks, first the ones registered by modules, then user's one
  31108. this.callbacks.concat([this.callback]).forEach(function (fn) {
  31109. // Chart destroyed in its own callback (#3600)
  31110. if (fn && typeof this.index !== 'undefined') {
  31111. fn.apply(this, [this]);
  31112. }
  31113. }, this);
  31114. fireEvent(this, 'load');
  31115. fireEvent(this, 'render');
  31116. // Set up auto resize, check for not destroyed (#6068)
  31117. if (defined(this.index)) {
  31118. this.setReflow(this.options.chart.reflow);
  31119. }
  31120. // Don't run again
  31121. this.hasLoaded = true;
  31122. };
  31123. /**
  31124. * Add a series to the chart after render time. Note that this method should
  31125. * never be used when adding data synchronously at chart render time, as it
  31126. * adds expense to the calculations and rendering. When adding data at the
  31127. * same time as the chart is initialized, add the series as a configuration
  31128. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  31129. *
  31130. * @sample highcharts/members/chart-addseries/
  31131. * Add a series from a button
  31132. * @sample stock/members/chart-addseries/
  31133. * Add a series in Highcharts Stock
  31134. *
  31135. * @function Highcharts.Chart#addSeries
  31136. *
  31137. * @param {Highcharts.SeriesOptionsType} options
  31138. * The config options for the series.
  31139. *
  31140. * @param {boolean} [redraw=true]
  31141. * Whether to redraw the chart after adding.
  31142. *
  31143. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  31144. * Whether to apply animation, and optionally animation
  31145. * configuration.
  31146. *
  31147. * @return {Highcharts.Series}
  31148. * The newly created series object.
  31149. *
  31150. * @fires Highcharts.Chart#event:addSeries
  31151. * @fires Highcharts.Chart#event:afterAddSeries
  31152. */
  31153. Chart.prototype.addSeries = function (options, redraw, animation) {
  31154. var series,
  31155. chart = this;
  31156. if (options) { // <- not necessary
  31157. redraw = pick(redraw, true); // defaults to true
  31158. fireEvent(chart, 'addSeries', { options: options }, function () {
  31159. series = chart.initSeries(options);
  31160. chart.isDirtyLegend = true;
  31161. chart.linkSeries();
  31162. if (series.enabledDataSorting) {
  31163. // We need to call `setData` after `linkSeries`
  31164. series.setData(options.data, false);
  31165. }
  31166. fireEvent(chart, 'afterAddSeries', { series: series });
  31167. if (redraw) {
  31168. chart.redraw(animation);
  31169. }
  31170. });
  31171. }
  31172. return series;
  31173. };
  31174. /**
  31175. * Add an axis to the chart after render time. Note that this method should
  31176. * never be used when adding data synchronously at chart render time, as it
  31177. * adds expense to the calculations and rendering. When adding data at the
  31178. * same time as the chart is initialized, add the axis as a configuration
  31179. * option instead.
  31180. *
  31181. * @sample highcharts/members/chart-addaxis/
  31182. * Add and remove axes
  31183. *
  31184. * @function Highcharts.Chart#addAxis
  31185. *
  31186. * @param {Highcharts.AxisOptions} options
  31187. * The axis options.
  31188. *
  31189. * @param {boolean} [isX=false]
  31190. * Whether it is an X axis or a value axis.
  31191. *
  31192. * @param {boolean} [redraw=true]
  31193. * Whether to redraw the chart after adding.
  31194. *
  31195. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31196. * Whether and how to apply animation in the redraw.
  31197. *
  31198. * @return {Highcharts.Axis}
  31199. * The newly generated Axis object.
  31200. */
  31201. Chart.prototype.addAxis = function (options, isX, redraw, animation) {
  31202. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  31203. };
  31204. /**
  31205. * Add a color axis to the chart after render time. Note that this method
  31206. * should never be used when adding data synchronously at chart render time,
  31207. * as it adds expense to the calculations and rendering. When adding data at
  31208. * the same time as the chart is initialized, add the axis as a
  31209. * configuration option instead.
  31210. *
  31211. * @sample highcharts/members/chart-addaxis/
  31212. * Add and remove axes
  31213. *
  31214. * @function Highcharts.Chart#addColorAxis
  31215. *
  31216. * @param {Highcharts.ColorAxisOptions} options
  31217. * The axis options.
  31218. *
  31219. * @param {boolean} [redraw=true]
  31220. * Whether to redraw the chart after adding.
  31221. *
  31222. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31223. * Whether and how to apply animation in the redraw.
  31224. *
  31225. * @return {Highcharts.ColorAxis}
  31226. * The newly generated Axis object.
  31227. */
  31228. Chart.prototype.addColorAxis = function (options, redraw, animation) {
  31229. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  31230. };
  31231. /**
  31232. * Factory for creating different axis types.
  31233. *
  31234. * @private
  31235. * @function Highcharts.Chart#createAxis
  31236. *
  31237. * @param {string} type
  31238. * An axis type.
  31239. *
  31240. * @param {...Array<*>} arguments
  31241. * All arguments for the constructor.
  31242. *
  31243. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  31244. * The newly generated Axis object.
  31245. */
  31246. Chart.prototype.createAxis = function (type, options) {
  31247. var chartOptions = this.options,
  31248. isColorAxis = type === 'colorAxis',
  31249. axisOptions = options.axis,
  31250. redraw = options.redraw,
  31251. animation = options.animation,
  31252. userOptions = merge(axisOptions, {
  31253. index: this[type].length,
  31254. isX: type === 'xAxis'
  31255. }),
  31256. axis;
  31257. if (isColorAxis) {
  31258. axis = new H.ColorAxis(this, userOptions);
  31259. }
  31260. else {
  31261. axis = new Axis(this, userOptions);
  31262. }
  31263. if (isColorAxis) {
  31264. this.isDirtyLegend = true;
  31265. // Clear before 'bindAxes' (#11924)
  31266. this.axes.forEach(function (axis) {
  31267. axis.series = [];
  31268. });
  31269. this.series.forEach(function (series) {
  31270. series.bindAxes();
  31271. series.isDirtyData = true;
  31272. });
  31273. }
  31274. if (pick(redraw, true)) {
  31275. this.redraw(animation);
  31276. }
  31277. return axis;
  31278. };
  31279. /**
  31280. * Dim the chart and show a loading text or symbol. Options for the loading
  31281. * screen are defined in {@link
  31282. * https://api.highcharts.com/highcharts/loading|the loading options}.
  31283. *
  31284. * @sample highcharts/members/chart-hideloading/
  31285. * Show and hide loading from a button
  31286. * @sample highcharts/members/chart-showloading/
  31287. * Apply different text labels
  31288. * @sample stock/members/chart-show-hide-loading/
  31289. * Toggle loading in Highcharts Stock
  31290. *
  31291. * @function Highcharts.Chart#showLoading
  31292. *
  31293. * @param {string} [str]
  31294. * An optional text to show in the loading label instead of the
  31295. * default one. The default text is set in
  31296. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  31297. */
  31298. Chart.prototype.showLoading = function (str) {
  31299. var chart = this,
  31300. options = chart.options,
  31301. loadingDiv = chart.loadingDiv,
  31302. loadingSpan = chart.loadingSpan,
  31303. loadingOptions = options.loading,
  31304. setLoadingSize = function () {
  31305. if (loadingDiv) {
  31306. css(loadingDiv, {
  31307. left: chart.plotLeft + 'px',
  31308. top: chart.plotTop + 'px',
  31309. width: chart.plotWidth + 'px',
  31310. height: chart.plotHeight + 'px'
  31311. });
  31312. }
  31313. };
  31314. // create the layer at the first call
  31315. if (!loadingDiv) {
  31316. chart.loadingDiv = loadingDiv = createElement('div', {
  31317. className: 'highcharts-loading highcharts-loading-hidden'
  31318. }, null, chart.container);
  31319. }
  31320. if (!loadingSpan) {
  31321. chart.loadingSpan = loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  31322. addEvent(chart, 'redraw', setLoadingSize); // #1080
  31323. }
  31324. loadingDiv.className = 'highcharts-loading';
  31325. // Update text
  31326. AST.setElementHTML(loadingSpan, pick(str, options.lang.loading, ''));
  31327. if (!chart.styledMode) {
  31328. // Update visuals
  31329. css(loadingDiv, extend(loadingOptions.style, {
  31330. zIndex: 10
  31331. }));
  31332. css(loadingSpan, loadingOptions.labelStyle);
  31333. // Show it
  31334. if (!chart.loadingShown) {
  31335. css(loadingDiv, {
  31336. opacity: 0,
  31337. display: ''
  31338. });
  31339. animate(loadingDiv, {
  31340. opacity: loadingOptions.style.opacity || 0.5
  31341. }, {
  31342. duration: loadingOptions.showDuration || 0
  31343. });
  31344. }
  31345. }
  31346. chart.loadingShown = true;
  31347. setLoadingSize();
  31348. };
  31349. /**
  31350. * Hide the loading layer.
  31351. *
  31352. * @see Highcharts.Chart#showLoading
  31353. *
  31354. * @sample highcharts/members/chart-hideloading/
  31355. * Show and hide loading from a button
  31356. * @sample stock/members/chart-show-hide-loading/
  31357. * Toggle loading in Highcharts Stock
  31358. *
  31359. * @function Highcharts.Chart#hideLoading
  31360. */
  31361. Chart.prototype.hideLoading = function () {
  31362. var options = this.options,
  31363. loadingDiv = this.loadingDiv;
  31364. if (loadingDiv) {
  31365. loadingDiv.className =
  31366. 'highcharts-loading highcharts-loading-hidden';
  31367. if (!this.styledMode) {
  31368. animate(loadingDiv, {
  31369. opacity: 0
  31370. }, {
  31371. duration: options.loading.hideDuration || 100,
  31372. complete: function () {
  31373. css(loadingDiv, { display: 'none' });
  31374. }
  31375. });
  31376. }
  31377. }
  31378. this.loadingShown = false;
  31379. };
  31380. /**
  31381. * A generic function to update any element of the chart. Elements can be
  31382. * enabled and disabled, moved, re-styled, re-formatted etc.
  31383. *
  31384. * A special case is configuration objects that take arrays, for example
  31385. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  31386. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  31387. * [series](https://api.highcharts.com/highcharts/series). For these
  31388. * collections, an `id` option is used to map the new option set to an
  31389. * existing object. If an existing object of the same id is not found, the
  31390. * corresponding item is updated. So for example, running `chart.update`
  31391. * with a series item without an id, will cause the existing chart's series
  31392. * with the same index in the series array to be updated. When the
  31393. * `oneToOne` parameter is true, `chart.update` will also take care of
  31394. * adding and removing items from the collection. Read more under the
  31395. * parameter description below.
  31396. *
  31397. * Note that when changing series data, `chart.update` may mutate the passed
  31398. * data options.
  31399. *
  31400. * See also the
  31401. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  31402. * Switching between `responsive.rules` basically runs `chart.update` under
  31403. * the hood.
  31404. *
  31405. * @sample highcharts/members/chart-update/
  31406. * Update chart geometry
  31407. *
  31408. * @function Highcharts.Chart#update
  31409. *
  31410. * @param {Highcharts.Options} options
  31411. * A configuration object for the new chart options.
  31412. *
  31413. * @param {boolean} [redraw=true]
  31414. * Whether to redraw the chart.
  31415. *
  31416. * @param {boolean} [oneToOne=false]
  31417. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  31418. * collections will be updated one to one, and items will be either
  31419. * added or removed to match the new updated options. For example,
  31420. * if the chart has two series and we call `chart.update` with a
  31421. * configuration containing three series, one will be added. If we
  31422. * call `chart.update` with one series, one will be removed. Setting
  31423. * an empty `series` array will remove all series, but leaving out
  31424. * the`series` property will leave all series untouched. If the
  31425. * series have id's, the new series options will be matched by id,
  31426. * and the remaining ones removed.
  31427. *
  31428. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31429. * Whether to apply animation, and optionally animation
  31430. * configuration.
  31431. *
  31432. * @fires Highcharts.Chart#event:update
  31433. * @fires Highcharts.Chart#event:afterUpdate
  31434. */
  31435. Chart.prototype.update = function (options, redraw, oneToOne, animation) {
  31436. var chart = this,
  31437. adders = {
  31438. credits: 'addCredits',
  31439. title: 'setTitle',
  31440. subtitle: 'setSubtitle',
  31441. caption: 'setCaption'
  31442. },
  31443. optionsChart,
  31444. updateAllAxes,
  31445. updateAllSeries,
  31446. newWidth,
  31447. newHeight,
  31448. runSetSize,
  31449. isResponsiveOptions = options.isResponsiveOptions,
  31450. itemsForRemoval = [];
  31451. fireEvent(chart, 'update', { options: options });
  31452. // If there are responsive rules in action, undo the responsive rules
  31453. // before we apply the updated options and replay the responsive rules
  31454. // on top from the chart.redraw function (#9617).
  31455. if (!isResponsiveOptions) {
  31456. chart.setResponsive(false, true);
  31457. }
  31458. options = cleanRecursively(options, chart.options);
  31459. chart.userOptions = merge(chart.userOptions, options);
  31460. // If the top-level chart option is present, some special updates are
  31461. // required
  31462. optionsChart = options.chart;
  31463. if (optionsChart) {
  31464. merge(true, chart.options.chart, optionsChart);
  31465. // Setter function
  31466. if ('className' in optionsChart) {
  31467. chart.setClassName(optionsChart.className);
  31468. }
  31469. if ('reflow' in optionsChart) {
  31470. chart.setReflow(optionsChart.reflow);
  31471. }
  31472. if ('inverted' in optionsChart ||
  31473. 'polar' in optionsChart ||
  31474. 'type' in optionsChart) {
  31475. // Parse options.chart.inverted and options.chart.polar together
  31476. // with the available series.
  31477. chart.propFromSeries();
  31478. updateAllAxes = true;
  31479. }
  31480. if ('alignTicks' in optionsChart) { // #6452
  31481. updateAllAxes = true;
  31482. }
  31483. objectEach(optionsChart, function (val, key) {
  31484. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  31485. -1) {
  31486. updateAllSeries = true;
  31487. }
  31488. // Only dirty box
  31489. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  31490. chart.isDirtyBox = true;
  31491. }
  31492. // Chart setSize
  31493. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  31494. if (isResponsiveOptions) {
  31495. chart.isDirtyBox = true;
  31496. }
  31497. else {
  31498. runSetSize = true;
  31499. }
  31500. }
  31501. });
  31502. if (!chart.styledMode && 'style' in optionsChart) {
  31503. chart.renderer.setStyle(optionsChart.style);
  31504. }
  31505. }
  31506. // Moved up, because tooltip needs updated plotOptions (#6218)
  31507. if (!chart.styledMode && options.colors) {
  31508. this.options.colors = options.colors;
  31509. }
  31510. if (options.time) {
  31511. // Maintaining legacy global time. If the chart is instanciated
  31512. // first with global time, then updated with time options, we need
  31513. // to create a new Time instance to avoid mutating the global time
  31514. // (#10536).
  31515. if (this.time === defaultTime) {
  31516. this.time = new Time(options.time);
  31517. }
  31518. // If we're updating, the time class is different from other chart
  31519. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  31520. // about the chart. The other chart[something].update functions also
  31521. // set the chart.options[something]. For the time class however we
  31522. // need to update the chart options separately. #14230.
  31523. merge(true, chart.options.time, options.time);
  31524. }
  31525. // Some option stuctures correspond one-to-one to chart objects that
  31526. // have update methods, for example
  31527. // options.credits => chart.credits
  31528. // options.legend => chart.legend
  31529. // options.title => chart.title
  31530. // options.tooltip => chart.tooltip
  31531. // options.subtitle => chart.subtitle
  31532. // options.mapNavigation => chart.mapNavigation
  31533. // options.navigator => chart.navigator
  31534. // options.scrollbar => chart.scrollbar
  31535. objectEach(options, function (val, key) {
  31536. if (chart[key] &&
  31537. typeof chart[key].update === 'function') {
  31538. chart[key].update(val, false);
  31539. // If a one-to-one object does not exist, look for an adder function
  31540. }
  31541. else if (typeof chart[adders[key]] === 'function') {
  31542. chart[adders[key]](val);
  31543. // Else, just merge the options. For nodes like loading, noData,
  31544. // plotOptions
  31545. }
  31546. else if (key !== 'colors' &&
  31547. chart.collectionsWithUpdate.indexOf(key) === -1) {
  31548. merge(true, chart.options[key], options[key]);
  31549. }
  31550. if (key !== 'chart' &&
  31551. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  31552. updateAllSeries = true;
  31553. }
  31554. });
  31555. // Setters for collections. For axes and series, each item is referred
  31556. // by an id. If the id is not found, it defaults to the corresponding
  31557. // item in the collection, so setting one series without an id, will
  31558. // update the first series in the chart. Setting two series without
  31559. // an id will update the first and the second respectively (#6019)
  31560. // chart.update and responsive.
  31561. this.collectionsWithUpdate.forEach(function (coll) {
  31562. var indexMap;
  31563. if (options[coll]) {
  31564. // In stock charts, the navigator series are also part of the
  31565. // chart.series array, but those series should not be handled
  31566. // here (#8196) and neither should the navigator axis (#9671).
  31567. indexMap = [];
  31568. chart[coll].forEach(function (s, i) {
  31569. if (!s.options.isInternal) {
  31570. indexMap.push(pick(s.options.index, i));
  31571. }
  31572. });
  31573. splat(options[coll]).forEach(function (newOptions, i) {
  31574. var hasId = defined(newOptions.id);
  31575. var item;
  31576. // Match by id
  31577. if (hasId) {
  31578. item = chart.get(newOptions.id);
  31579. }
  31580. // No match by id found, match by index instead
  31581. if (!item && chart[coll]) {
  31582. item = chart[coll][indexMap ? indexMap[i] : i];
  31583. // Check if we grabbed an item with an exising but
  31584. // different id (#13541)
  31585. if (item && hasId && defined(item.options.id)) {
  31586. item = void 0;
  31587. }
  31588. }
  31589. if (item && item.coll === coll) {
  31590. item.update(newOptions, false);
  31591. if (oneToOne) {
  31592. item.touched = true;
  31593. }
  31594. }
  31595. // If oneToOne and no matching item is found, add one
  31596. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  31597. chart.collectionsWithInit[coll][0].apply(chart,
  31598. // [newOptions, ...extraArguments, redraw=false]
  31599. [
  31600. newOptions
  31601. ].concat(
  31602. // Not all initializers require extra args
  31603. chart.collectionsWithInit[coll][1] || []).concat([
  31604. false
  31605. ])).touched = true;
  31606. }
  31607. });
  31608. // Add items for removal
  31609. if (oneToOne) {
  31610. chart[coll].forEach(function (item) {
  31611. if (!item.touched && !item.options.isInternal) {
  31612. itemsForRemoval.push(item);
  31613. }
  31614. else {
  31615. delete item.touched;
  31616. }
  31617. });
  31618. }
  31619. }
  31620. });
  31621. itemsForRemoval.forEach(function (item) {
  31622. if (item.chart) { // #9097, avoid removing twice
  31623. item.remove(false);
  31624. }
  31625. });
  31626. if (updateAllAxes) {
  31627. chart.axes.forEach(function (axis) {
  31628. axis.update({}, false);
  31629. });
  31630. }
  31631. // Certain options require the whole series structure to be thrown away
  31632. // and rebuilt
  31633. if (updateAllSeries) {
  31634. chart.getSeriesOrderByLinks().forEach(function (series) {
  31635. // Avoid removed navigator series
  31636. if (series.chart) {
  31637. series.update({}, false);
  31638. }
  31639. }, this);
  31640. }
  31641. // Update size. Redraw is forced.
  31642. newWidth = optionsChart && optionsChart.width;
  31643. newHeight = optionsChart && optionsChart.height;
  31644. if (isString(newHeight)) {
  31645. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  31646. }
  31647. if (
  31648. // In this case, run chart.setSize with newWidth and newHeight which
  31649. // are undefined, only for reflowing chart elements because margin
  31650. // or spacing has been set (#8190)
  31651. runSetSize ||
  31652. // In this case, the size is actually set
  31653. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  31654. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  31655. chart.setSize(newWidth, newHeight, animation);
  31656. }
  31657. else if (pick(redraw, true)) {
  31658. chart.redraw(animation);
  31659. }
  31660. fireEvent(chart, 'afterUpdate', {
  31661. options: options,
  31662. redraw: redraw,
  31663. animation: animation
  31664. });
  31665. };
  31666. /**
  31667. * Shortcut to set the subtitle options. This can also be done from {@link
  31668. * Chart#update} or {@link Chart#setTitle}.
  31669. *
  31670. * @function Highcharts.Chart#setSubtitle
  31671. *
  31672. * @param {Highcharts.SubtitleOptions} options
  31673. * New subtitle options. The subtitle text itself is set by the
  31674. * `options.text` property.
  31675. */
  31676. Chart.prototype.setSubtitle = function (options, redraw) {
  31677. this.applyDescription('subtitle', options);
  31678. this.layOutTitles(redraw);
  31679. };
  31680. /**
  31681. * Set the caption options. This can also be done from {@link
  31682. * Chart#update}.
  31683. *
  31684. * @function Highcharts.Chart#setCaption
  31685. *
  31686. * @param {Highcharts.CaptionOptions} options
  31687. * New caption options. The caption text itself is set by the
  31688. * `options.text` property.
  31689. */
  31690. Chart.prototype.setCaption = function (options, redraw) {
  31691. this.applyDescription('caption', options);
  31692. this.layOutTitles(redraw);
  31693. };
  31694. /**
  31695. * Display the zoom button, so users can reset zoom to the default view
  31696. * settings.
  31697. *
  31698. * @function Highcharts.Chart#showResetZoom
  31699. *
  31700. * @fires Highcharts.Chart#event:afterShowResetZoom
  31701. * @fires Highcharts.Chart#event:beforeShowResetZoom
  31702. */
  31703. Chart.prototype.showResetZoom = function () {
  31704. var chart = this,
  31705. lang = defaultOptions.lang,
  31706. btnOptions = chart.options.chart.resetZoomButton,
  31707. theme = btnOptions.theme,
  31708. states = theme.states,
  31709. alignTo = (btnOptions.relativeTo === 'chart' ||
  31710. btnOptions.relativeTo === 'spacingBox' ?
  31711. null :
  31712. 'scrollablePlotBox');
  31713. /**
  31714. * @private
  31715. */
  31716. function zoomOut() {
  31717. chart.zoomOut();
  31718. }
  31719. fireEvent(this, 'beforeShowResetZoom', null, function () {
  31720. chart.resetZoomButton = chart.renderer
  31721. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  31722. .attr({
  31723. align: btnOptions.position.align,
  31724. title: lang.resetZoomTitle
  31725. })
  31726. .addClass('highcharts-reset-zoom')
  31727. .add()
  31728. .align(btnOptions.position, false, alignTo);
  31729. });
  31730. fireEvent(this, 'afterShowResetZoom');
  31731. };
  31732. /**
  31733. * Zoom the chart out after a user has zoomed in. See also
  31734. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  31735. *
  31736. * @function Highcharts.Chart#zoomOut
  31737. *
  31738. * @fires Highcharts.Chart#event:selection
  31739. */
  31740. Chart.prototype.zoomOut = function () {
  31741. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  31742. };
  31743. /**
  31744. * Zoom into a given portion of the chart given by axis coordinates.
  31745. *
  31746. * @private
  31747. * @function Highcharts.Chart#zoom
  31748. * @param {Highcharts.SelectEventObject} event
  31749. */
  31750. Chart.prototype.zoom = function (event) {
  31751. var chart = this,
  31752. hasZoomed,
  31753. pointer = chart.pointer,
  31754. displayButton = false,
  31755. mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY,
  31756. resetZoomButton;
  31757. // If zoom is called with no arguments, reset the axes
  31758. if (!event || event.resetSelection) {
  31759. chart.axes.forEach(function (axis) {
  31760. hasZoomed = axis.zoom();
  31761. });
  31762. pointer.initiated = false; // #6804
  31763. }
  31764. else { // else, zoom in on all axes
  31765. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  31766. var axis = axisData.axis,
  31767. axisStartPos = chart.inverted ? axis.left : axis.top,
  31768. axisEndPos = chart.inverted ?
  31769. axisStartPos + axis.width : axisStartPos + axis.height,
  31770. isXAxis = axis.isXAxis,
  31771. isWithinPane = false;
  31772. // Check if zoomed area is within the pane (#1289).
  31773. // In case of multiple panes only one pane should be zoomed.
  31774. if ((!isXAxis &&
  31775. mouseDownPos >= axisStartPos &&
  31776. mouseDownPos <= axisEndPos) ||
  31777. isXAxis ||
  31778. !defined(mouseDownPos)) {
  31779. isWithinPane = true;
  31780. }
  31781. // don't zoom more than minRange
  31782. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  31783. hasZoomed = axis.zoom(axisData.min, axisData.max);
  31784. if (axis.displayBtn) {
  31785. displayButton = true;
  31786. }
  31787. }
  31788. });
  31789. }
  31790. // Show or hide the Reset zoom button
  31791. resetZoomButton = chart.resetZoomButton;
  31792. if (displayButton && !resetZoomButton) {
  31793. chart.showResetZoom();
  31794. }
  31795. else if (!displayButton && isObject(resetZoomButton)) {
  31796. chart.resetZoomButton = resetZoomButton.destroy();
  31797. }
  31798. // Redraw
  31799. if (hasZoomed) {
  31800. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  31801. }
  31802. };
  31803. /**
  31804. * Pan the chart by dragging the mouse across the pane. This function is
  31805. * called on mouse move, and the distance to pan is computed from chartX
  31806. * compared to the first chartX position in the dragging operation.
  31807. *
  31808. * @private
  31809. * @function Highcharts.Chart#pan
  31810. * @param {Highcharts.PointerEventObject} e
  31811. * @param {string} panning
  31812. */
  31813. Chart.prototype.pan = function (e, panning) {
  31814. var chart = this,
  31815. hoverPoints = chart.hoverPoints,
  31816. panningOptions,
  31817. chartOptions = chart.options.chart,
  31818. hasMapNavigation = chart.options.mapNavigation &&
  31819. chart.options.mapNavigation.enabled,
  31820. doRedraw,
  31821. type;
  31822. if (typeof panning === 'object') {
  31823. panningOptions = panning;
  31824. }
  31825. else {
  31826. panningOptions = {
  31827. enabled: panning,
  31828. type: 'x'
  31829. };
  31830. }
  31831. if (chartOptions && chartOptions.panning) {
  31832. chartOptions.panning = panningOptions;
  31833. }
  31834. type = panningOptions.type;
  31835. fireEvent(this, 'pan', { originalEvent: e }, function () {
  31836. // remove active points for shared tooltip
  31837. if (hoverPoints) {
  31838. hoverPoints.forEach(function (point) {
  31839. point.setState();
  31840. });
  31841. }
  31842. // panning axis mapping
  31843. var xy = [1]; // x
  31844. if (type === 'xy') {
  31845. xy = [1, 0];
  31846. }
  31847. else if (type === 'y') {
  31848. xy = [0];
  31849. }
  31850. xy.forEach(function (isX) {
  31851. var axis = chart[isX ? 'xAxis' : 'yAxis'][0], horiz = axis.horiz, mousePos = e[horiz ? 'chartX' : 'chartY'], mouseDown = horiz ? 'mouseDownX' : 'mouseDownY', startPos = chart[mouseDown], halfPointRange = (axis.pointRange || 0) / 2, pointRangeDirection = (axis.reversed && !chart.inverted) ||
  31852. (!axis.reversed && chart.inverted) ?
  31853. -1 :
  31854. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  31855. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  31856. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  31857. // General calculations of panning state.
  31858. // This is related to using vertical panning. (#11315).
  31859. if (hasVerticalPanning &&
  31860. !isX && (!panningState || panningState.isDirty)) {
  31861. axis.series.forEach(function (series) {
  31862. var processedData = series.getProcessedData(true),
  31863. dataExtremes = series.getExtremes(processedData.yData,
  31864. true);
  31865. if (!panningState) {
  31866. panningState = {
  31867. startMin: Number.MAX_VALUE,
  31868. startMax: -Number.MAX_VALUE
  31869. };
  31870. }
  31871. if (isNumber(dataExtremes.dataMin) &&
  31872. isNumber(dataExtremes.dataMax)) {
  31873. panningState.startMin = Math.min(pick(series.options.threshold, Infinity), dataExtremes.dataMin, panningState.startMin);
  31874. panningState.startMax = Math.max(pick(series.options.threshold, -Infinity), dataExtremes.dataMax, panningState.startMax);
  31875. }
  31876. });
  31877. }
  31878. paddedMin = Math.min(pick(panningState && panningState.startMin, extremes.dataMin), halfPointRange ?
  31879. extremes.min :
  31880. axis.toValue(axis.toPixels(extremes.min) -
  31881. axis.minPixelPadding));
  31882. paddedMax = Math.max(pick(panningState && panningState.startMax, extremes.dataMax), halfPointRange ?
  31883. extremes.max :
  31884. axis.toValue(axis.toPixels(extremes.max) +
  31885. axis.minPixelPadding));
  31886. axis.panningState = panningState;
  31887. // It is not necessary to calculate extremes on ordinal axis,
  31888. // because they are already calculated, so we don't want to
  31889. // override them.
  31890. if (!axis.isOrdinal) {
  31891. // If the new range spills over, either to the min or max,
  31892. // adjust the new range.
  31893. spill = paddedMin - newMin;
  31894. if (spill > 0) {
  31895. newMax += spill;
  31896. newMin = paddedMin;
  31897. }
  31898. spill = newMax - paddedMax;
  31899. if (spill > 0) {
  31900. newMax = paddedMax;
  31901. newMin -= spill;
  31902. }
  31903. // Set new extremes if they are actually new
  31904. if (axis.series.length &&
  31905. newMin !== extremes.min &&
  31906. newMax !== extremes.max &&
  31907. newMin >= paddedMin &&
  31908. newMax <= paddedMax) {
  31909. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  31910. if (!chart.resetZoomButton &&
  31911. !hasMapNavigation &&
  31912. // Show reset zoom button only when both newMin and
  31913. // newMax values are between padded axis range.
  31914. newMin !== paddedMin &&
  31915. newMax !== paddedMax &&
  31916. type.match('y')) {
  31917. chart.showResetZoom();
  31918. axis.displayBtn = false;
  31919. }
  31920. doRedraw = true;
  31921. }
  31922. // set new reference for next run:
  31923. chart[mouseDown] = mousePos;
  31924. }
  31925. });
  31926. if (doRedraw) {
  31927. chart.redraw(false);
  31928. }
  31929. css(chart.container, { cursor: 'move' });
  31930. });
  31931. };
  31932. return Chart;
  31933. }());
  31934. extend(Chart.prototype, {
  31935. // Hook for adding callbacks in modules
  31936. callbacks: [],
  31937. /**
  31938. * These collections (arrays) implement `Chart.addSomethig` method used in
  31939. * chart.update() to create new object in the collection. Equivalent for
  31940. * deleting is resolved by simple `Somethig.remove()`.
  31941. *
  31942. * Note: We need to define these references after initializers are bound to
  31943. * chart's prototype.
  31944. */
  31945. collectionsWithInit: {
  31946. // collectionName: [ initializingMethod, [extraArguments] ]
  31947. xAxis: [Chart.prototype.addAxis, [true]],
  31948. yAxis: [Chart.prototype.addAxis, [false]],
  31949. series: [Chart.prototype.addSeries]
  31950. },
  31951. /**
  31952. * These collections (arrays) implement update() methods with support for
  31953. * one-to-one option.
  31954. */
  31955. collectionsWithUpdate: [
  31956. 'xAxis',
  31957. 'yAxis',
  31958. 'zAxis',
  31959. 'series'
  31960. ],
  31961. /**
  31962. * These properties cause isDirtyBox to be set to true when updating. Can be
  31963. * extended from plugins.
  31964. */
  31965. propsRequireDirtyBox: [
  31966. 'backgroundColor',
  31967. 'borderColor',
  31968. 'borderWidth',
  31969. 'borderRadius',
  31970. 'plotBackgroundColor',
  31971. 'plotBackgroundImage',
  31972. 'plotBorderColor',
  31973. 'plotBorderWidth',
  31974. 'plotShadow',
  31975. 'shadow'
  31976. ],
  31977. /**
  31978. * These properties require a full reflow of chart elements, best
  31979. * implemented through running `Chart.setSize` internally (#8190).
  31980. * @type {Array}
  31981. */
  31982. propsRequireReflow: [
  31983. 'margin',
  31984. 'marginTop',
  31985. 'marginRight',
  31986. 'marginBottom',
  31987. 'marginLeft',
  31988. 'spacing',
  31989. 'spacingTop',
  31990. 'spacingRight',
  31991. 'spacingBottom',
  31992. 'spacingLeft'
  31993. ],
  31994. /**
  31995. * These properties cause all series to be updated when updating. Can be
  31996. * extended from plugins.
  31997. */
  31998. propsRequireUpdateSeries: [
  31999. 'chart.inverted',
  32000. 'chart.polar',
  32001. 'chart.ignoreHiddenSeries',
  32002. 'chart.type',
  32003. 'colors',
  32004. 'plotOptions',
  32005. 'time',
  32006. 'tooltip'
  32007. ]
  32008. });
  32009. /**
  32010. * Factory function for basic charts.
  32011. *
  32012. * @example
  32013. * // Render a chart in to div#container
  32014. * let chart = Highcharts.chart('container', {
  32015. * title: {
  32016. * text: 'My chart'
  32017. * },
  32018. * series: [{
  32019. * data: [1, 3, 2, 4]
  32020. * }]
  32021. * });
  32022. *
  32023. * @function Highcharts.chart
  32024. *
  32025. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  32026. * The DOM element to render to, or its id.
  32027. *
  32028. * @param {Highcharts.Options} options
  32029. * The chart options structure.
  32030. *
  32031. * @param {Highcharts.ChartCallbackFunction} [callback]
  32032. * Function to run when the chart has loaded and and all external images
  32033. * are loaded. Defining a
  32034. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  32035. * handler is equivalent.
  32036. *
  32037. * @return {Highcharts.Chart}
  32038. * Returns the Chart object.
  32039. */
  32040. function chart(a, b, c) {
  32041. return new Chart(a, b, c);
  32042. }
  32043. H.chart = chart;
  32044. H.Chart = Chart;
  32045. /* *
  32046. *
  32047. * Export
  32048. *
  32049. * */
  32050. /* *
  32051. *
  32052. * API Declarations
  32053. *
  32054. * */
  32055. /**
  32056. * Callback for chart constructors.
  32057. *
  32058. * @callback Highcharts.ChartCallbackFunction
  32059. *
  32060. * @param {Highcharts.Chart} chart
  32061. * Created chart.
  32062. */
  32063. /**
  32064. * Format a number and return a string based on input settings.
  32065. *
  32066. * @callback Highcharts.NumberFormatterCallbackFunction
  32067. *
  32068. * @param {number} number
  32069. * The input number to format.
  32070. *
  32071. * @param {number} decimals
  32072. * The amount of decimals. A value of -1 preserves the amount in the
  32073. * input number.
  32074. *
  32075. * @param {string} [decimalPoint]
  32076. * The decimal point, defaults to the one given in the lang options, or
  32077. * a dot.
  32078. *
  32079. * @param {string} [thousandsSep]
  32080. * The thousands separator, defaults to the one given in the lang
  32081. * options, or a space character.
  32082. *
  32083. * @return {string} The formatted number.
  32084. */
  32085. /**
  32086. * The chart title. The title has an `update` method that allows modifying the
  32087. * options directly or indirectly via `chart.update`.
  32088. *
  32089. * @interface Highcharts.TitleObject
  32090. * @extends Highcharts.SVGElement
  32091. */ /**
  32092. * Modify options for the title.
  32093. *
  32094. * @function Highcharts.TitleObject#update
  32095. *
  32096. * @param {Highcharts.TitleOptions} titleOptions
  32097. * Options to modify.
  32098. *
  32099. * @param {boolean} [redraw=true]
  32100. * Whether to redraw the chart after the title is altered. If doing more
  32101. * operations on the chart, it is a good idea to set redraw to false and
  32102. * call {@link Chart#redraw} after.
  32103. */
  32104. /**
  32105. * The chart subtitle. The subtitle has an `update` method that
  32106. * allows modifying the options directly or indirectly via
  32107. * `chart.update`.
  32108. *
  32109. * @interface Highcharts.SubtitleObject
  32110. * @extends Highcharts.SVGElement
  32111. */ /**
  32112. * Modify options for the subtitle.
  32113. *
  32114. * @function Highcharts.SubtitleObject#update
  32115. *
  32116. * @param {Highcharts.SubtitleOptions} subtitleOptions
  32117. * Options to modify.
  32118. *
  32119. * @param {boolean} [redraw=true]
  32120. * Whether to redraw the chart after the subtitle is altered. If doing
  32121. * more operations on the chart, it is a good idea to set redraw to false
  32122. * and call {@link Chart#redraw} after.
  32123. */
  32124. /**
  32125. * The chart caption. The caption has an `update` method that
  32126. * allows modifying the options directly or indirectly via
  32127. * `chart.update`.
  32128. *
  32129. * @interface Highcharts.CaptionObject
  32130. * @extends Highcharts.SVGElement
  32131. */ /**
  32132. * Modify options for the caption.
  32133. *
  32134. * @function Highcharts.CaptionObject#update
  32135. *
  32136. * @param {Highcharts.CaptionOptions} captionOptions
  32137. * Options to modify.
  32138. *
  32139. * @param {boolean} [redraw=true]
  32140. * Whether to redraw the chart after the caption is altered. If doing
  32141. * more operations on the chart, it is a good idea to set redraw to false
  32142. * and call {@link Chart#redraw} after.
  32143. */
  32144. /**
  32145. * @interface Highcharts.ChartIsInsideOptionsObject
  32146. */ /**
  32147. * @name Highcharts.ChartIsInsideOptionsObject#ignoreX
  32148. * @type {boolean|undefined}
  32149. */ /**
  32150. * @name Highcharts.ChartIsInsideOptionsObject#ignoreY
  32151. * @type {boolean|undefined}
  32152. */ /**
  32153. * @name Highcharts.ChartIsInsideOptionsObject#inverted
  32154. * @type {boolean|undefined}
  32155. */ /**
  32156. * @name Highcharts.ChartIsInsideOptionsObject#paneCoordinates
  32157. * @type {boolean|undefined}
  32158. */ /**
  32159. * @name Highcharts.ChartIsInsideOptionsObject#series
  32160. * @type {Highcharts.Series|undefined}
  32161. */ /**
  32162. * @name Highcharts.ChartIsInsideOptionsObject#visiblePlotOnly
  32163. * @type {boolean|undefined}
  32164. */
  32165. ''; // include doclets above in transpilat
  32166. return Chart;
  32167. });
  32168. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32169. /* *
  32170. *
  32171. * (c) 2010-2021 Torstein Honsi
  32172. *
  32173. * License: www.highcharts.com/license
  32174. *
  32175. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32176. *
  32177. * */
  32178. var merge = U.merge,
  32179. pick = U.pick;
  32180. /* eslint-disable valid-jsdoc */
  32181. /**
  32182. * Legend symbol mixin.
  32183. *
  32184. * @private
  32185. * @mixin Highcharts.LegendSymbolMixin
  32186. */
  32187. var LegendSymbolMixin = H.LegendSymbolMixin = {
  32188. /**
  32189. * Get the series' symbol in the legend
  32190. *
  32191. * @private
  32192. * @function Highcharts.LegendSymbolMixin.drawRectangle
  32193. *
  32194. * @param {Highcharts.Legend} legend
  32195. * The legend object
  32196. *
  32197. * @param {Highcharts.Point|Highcharts.Series} item
  32198. * The series (this) or point
  32199. */
  32200. drawRectangle: function (legend,
  32201. item) {
  32202. var options = legend.options,
  32203. symbolHeight = legend.symbolHeight,
  32204. square = options.squareSymbol,
  32205. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  32206. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  32207. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  32208. .addClass('highcharts-point')
  32209. .attr({
  32210. zIndex: 3
  32211. }).add(item.legendGroup);
  32212. },
  32213. /**
  32214. * Get the series' symbol in the legend. This method should be overridable
  32215. * to create custom symbols through
  32216. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  32217. *
  32218. * @private
  32219. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  32220. *
  32221. * @param {Highcharts.Legend} legend
  32222. * The legend object.
  32223. */
  32224. drawLineMarker: function (legend) {
  32225. var options = this.options,
  32226. markerOptions = options.marker,
  32227. radius,
  32228. legendSymbol,
  32229. symbolWidth = legend.symbolWidth,
  32230. symbolHeight = legend.symbolHeight,
  32231. generalRadius = symbolHeight / 2,
  32232. renderer = this.chart.renderer,
  32233. legendItemGroup = this.legendGroup,
  32234. verticalCenter = legend.baseline -
  32235. Math.round(legend.fontMetrics.b * 0.3),
  32236. attr = {};
  32237. // Draw the line
  32238. if (!this.chart.styledMode) {
  32239. attr = {
  32240. 'stroke-width': options.lineWidth || 0
  32241. };
  32242. if (options.dashStyle) {
  32243. attr.dashstyle = options.dashStyle;
  32244. }
  32245. }
  32246. this.legendLine = renderer
  32247. .path([
  32248. ['M', 0, verticalCenter],
  32249. ['L', symbolWidth, verticalCenter]
  32250. ])
  32251. .addClass('highcharts-graph')
  32252. .attr(attr)
  32253. .add(legendItemGroup);
  32254. // Draw the marker
  32255. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  32256. // Do not allow the marker to be larger than the symbolHeight
  32257. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  32258. // Restrict symbol markers size
  32259. if (this.symbol.indexOf('url') === 0) {
  32260. markerOptions = merge(markerOptions, {
  32261. width: symbolHeight,
  32262. height: symbolHeight
  32263. });
  32264. radius = 0;
  32265. }
  32266. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  32267. .addClass('highcharts-point')
  32268. .add(legendItemGroup);
  32269. legendSymbol.isMarker = true;
  32270. }
  32271. }
  32272. };
  32273. return LegendSymbolMixin;
  32274. });
  32275. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (A, H, LegendSymbolMixin, O, palette, Point, SeriesRegistry, SVGElement, U) {
  32276. /* *
  32277. *
  32278. * (c) 2010-2021 Torstein Honsi
  32279. *
  32280. * License: www.highcharts.com/license
  32281. *
  32282. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32283. *
  32284. * */
  32285. var animObject = A.animObject,
  32286. setAnimation = A.setAnimation;
  32287. var hasTouch = H.hasTouch,
  32288. svg = H.svg,
  32289. win = H.win;
  32290. var defaultOptions = O.defaultOptions;
  32291. var seriesTypes = SeriesRegistry.seriesTypes;
  32292. var addEvent = U.addEvent,
  32293. arrayMax = U.arrayMax,
  32294. arrayMin = U.arrayMin,
  32295. clamp = U.clamp,
  32296. cleanRecursively = U.cleanRecursively,
  32297. correctFloat = U.correctFloat,
  32298. defined = U.defined,
  32299. erase = U.erase,
  32300. error = U.error,
  32301. extend = U.extend,
  32302. find = U.find,
  32303. fireEvent = U.fireEvent,
  32304. getNestedProperty = U.getNestedProperty,
  32305. isArray = U.isArray,
  32306. isFunction = U.isFunction,
  32307. isNumber = U.isNumber,
  32308. isString = U.isString,
  32309. merge = U.merge,
  32310. objectEach = U.objectEach,
  32311. pick = U.pick,
  32312. removeEvent = U.removeEvent,
  32313. splat = U.splat,
  32314. syncTimeout = U.syncTimeout;
  32315. /* *
  32316. *
  32317. * Class
  32318. *
  32319. * */
  32320. /**
  32321. * This is the base series prototype that all other series types inherit from.
  32322. * A new series is initialized either through the
  32323. * [series](https://api.highcharts.com/highcharts/series)
  32324. * option structure, or after the chart is initialized, through
  32325. * {@link Highcharts.Chart#addSeries}.
  32326. *
  32327. * The object can be accessed in a number of ways. All series and point event
  32328. * handlers give a reference to the `series` object. The chart object has a
  32329. * {@link Highcharts.Chart#series|series} property that is a collection of all
  32330. * the chart's series. The point objects and axis objects also have the same
  32331. * reference.
  32332. *
  32333. * Another way to reference the series programmatically is by `id`. Add an id
  32334. * in the series configuration options, and get the series object by
  32335. * {@link Highcharts.Chart#get}.
  32336. *
  32337. * Configuration options for the series are given in three levels. Options for
  32338. * all series in a chart are given in the
  32339. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  32340. * object. Then options for all series of a specific type
  32341. * are given in the plotOptions of that type, for example `plotOptions.line`.
  32342. * Next, options for one single series are given in the series array, or as
  32343. * arguments to `chart.addSeries`.
  32344. *
  32345. * The data in the series is stored in various arrays.
  32346. *
  32347. * - First, `series.options.data` contains all the original config options for
  32348. * each point whether added by options or methods like `series.addPoint`.
  32349. *
  32350. * - Next, `series.data` contains those values converted to points, but in case
  32351. * the series data length exceeds the `cropThreshold`, or if the data is
  32352. * grouped, `series.data` doesn't contain all the points. It only contains the
  32353. * points that have been created on demand.
  32354. *
  32355. * - Then there's `series.points` that contains all currently visible point
  32356. * objects. In case of cropping, the cropped-away points are not part of this
  32357. * array. The `series.points` array starts at `series.cropStart` compared to
  32358. * `series.data` and `series.options.data`. If however the series data is
  32359. * grouped, these can't be correlated one to one.
  32360. *
  32361. * - `series.xData` and `series.processedXData` contain clean x values,
  32362. * equivalent to `series.data` and `series.points`.
  32363. *
  32364. * - `series.yData` and `series.processedYData` contain clean y values,
  32365. * equivalent to `series.data` and `series.points`.
  32366. *
  32367. * @class
  32368. * @name Highcharts.Series
  32369. *
  32370. * @param {Highcharts.Chart} chart
  32371. * The chart instance.
  32372. *
  32373. * @param {Highcharts.SeriesOptionsType|object} options
  32374. * The series options.
  32375. */
  32376. var Series = /** @class */ (function () {
  32377. function Series() {
  32378. /* *
  32379. *
  32380. * Static Functions
  32381. *
  32382. * */
  32383. this._i = void 0;
  32384. this.chart = void 0;
  32385. this.data = void 0;
  32386. this.eventOptions = void 0;
  32387. this.eventsToUnbind = void 0;
  32388. this.index = void 0;
  32389. this.linkedSeries = void 0;
  32390. this.options = void 0;
  32391. this.points = void 0;
  32392. this.processedXData = void 0;
  32393. this.processedYData = void 0;
  32394. this.tooltipOptions = void 0;
  32395. this.userOptions = void 0;
  32396. this.xAxis = void 0;
  32397. this.yAxis = void 0;
  32398. this.zones = void 0;
  32399. /** eslint-enable valid-jsdoc */
  32400. }
  32401. /* *
  32402. *
  32403. * Functions
  32404. *
  32405. * */
  32406. /* eslint-disable valid-jsdoc */
  32407. Series.prototype.init = function (chart, userOptions) {
  32408. fireEvent(this, 'init', { options: userOptions });
  32409. var series = this,
  32410. events,
  32411. chartSeries = chart.series,
  32412. lastSeries;
  32413. // A lookup over those events that are added by _options_ (not
  32414. // programmatically). These are updated through Series.update()
  32415. // (#10861).
  32416. this.eventOptions = this.eventOptions || {};
  32417. // The 'eventsToUnbind' property moved from prototype into the
  32418. // Series init to avoid reference to the same array between
  32419. // the different series and charts. #12959, #13937
  32420. this.eventsToUnbind = [];
  32421. /**
  32422. * Read only. The chart that the series belongs to.
  32423. *
  32424. * @name Highcharts.Series#chart
  32425. * @type {Highcharts.Chart}
  32426. */
  32427. series.chart = chart;
  32428. /**
  32429. * Read only. The series' type, like "line", "area", "column" etc.
  32430. * The type in the series options anc can be altered using
  32431. * {@link Series#update}.
  32432. *
  32433. * @name Highcharts.Series#type
  32434. * @type {string}
  32435. */
  32436. /**
  32437. * Read only. The series' current options. To update, use
  32438. * {@link Series#update}.
  32439. *
  32440. * @name Highcharts.Series#options
  32441. * @type {Highcharts.SeriesOptionsType}
  32442. */
  32443. series.options = series.setOptions(userOptions);
  32444. var options = series.options;
  32445. series.linkedSeries = [];
  32446. // bind the axes
  32447. series.bindAxes();
  32448. extend(series, {
  32449. /**
  32450. * The series name as given in the options. Defaults to
  32451. * "Series {n}".
  32452. *
  32453. * @name Highcharts.Series#name
  32454. * @type {string}
  32455. */
  32456. name: options.name,
  32457. state: '',
  32458. /**
  32459. * Read only. The series' visibility state as set by {@link
  32460. * Series#show}, {@link Series#hide}, or in the initial
  32461. * configuration.
  32462. *
  32463. * @name Highcharts.Series#visible
  32464. * @type {boolean}
  32465. */
  32466. visible: options.visible !== false,
  32467. /**
  32468. * Read only. The series' selected state as set by {@link
  32469. * Highcharts.Series#select}.
  32470. *
  32471. * @name Highcharts.Series#selected
  32472. * @type {boolean}
  32473. */
  32474. selected: options.selected === true // false by default
  32475. });
  32476. // Register event listeners
  32477. events = options.events;
  32478. objectEach(events, function (event, eventType) {
  32479. if (isFunction(event)) {
  32480. // If event does not exist, or is changed by Series.update
  32481. if (series.eventOptions[eventType] !== event) {
  32482. // Remove existing if set by option
  32483. if (isFunction(series.eventOptions[eventType])) {
  32484. removeEvent(series, eventType, series.eventOptions[eventType]);
  32485. }
  32486. series.eventOptions[eventType] = event;
  32487. addEvent(series, eventType, event);
  32488. }
  32489. }
  32490. });
  32491. if ((events && events.click) ||
  32492. (options.point &&
  32493. options.point.events &&
  32494. options.point.events.click) ||
  32495. options.allowPointSelect) {
  32496. chart.runTrackerClick = true;
  32497. }
  32498. series.getColor();
  32499. series.getSymbol();
  32500. // Initialize the parallel data arrays
  32501. series.parallelArrays.forEach(function (key) {
  32502. if (!series[key + 'Data']) {
  32503. series[key + 'Data'] = [];
  32504. }
  32505. });
  32506. // Mark cartesian
  32507. if (series.isCartesian) {
  32508. chart.hasCartesianSeries = true;
  32509. }
  32510. // Get the index and register the series in the chart. The index is
  32511. // one more than the current latest series index (#5960).
  32512. if (chartSeries.length) {
  32513. lastSeries = chartSeries[chartSeries.length - 1];
  32514. }
  32515. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32516. series.opacity = series.options.opacity;
  32517. // Insert the series and re-order all series above the insertion
  32518. // point.
  32519. chart.orderSeries(this.insert(chartSeries));
  32520. // Set options for series with sorting and set data later.
  32521. if (options.dataSorting && options.dataSorting.enabled) {
  32522. series.setDataSortingOptions();
  32523. }
  32524. else if (!series.points && !series.data) {
  32525. series.setData(options.data, false);
  32526. }
  32527. fireEvent(this, 'afterInit');
  32528. };
  32529. /**
  32530. * Check whether the series item is itself or inherits from a certain
  32531. * series type.
  32532. *
  32533. * @function Highcharts.Series#is
  32534. * @param {string} type The type of series to check for, can be either
  32535. * featured or custom series types. For example `column`, `pie`,
  32536. * `ohlc` etc.
  32537. *
  32538. * @return {boolean}
  32539. * True if this item is or inherits from the given type.
  32540. */
  32541. Series.prototype.is = function (type) {
  32542. return seriesTypes[type] && this instanceof seriesTypes[type];
  32543. };
  32544. /**
  32545. * Insert the series in a collection with other series, either the chart
  32546. * series or yAxis series, in the correct order according to the index
  32547. * option. Used internally when adding series.
  32548. *
  32549. * @private
  32550. * @function Highcharts.Series#insert
  32551. * @param {Array<Highcharts.Series>} collection
  32552. * A collection of series, like `chart.series` or `xAxis.series`.
  32553. * @return {number}
  32554. * The index of the series in the collection.
  32555. */
  32556. Series.prototype.insert = function (collection) {
  32557. var indexOption = this.options.index,
  32558. i;
  32559. // Insert by index option
  32560. if (isNumber(indexOption)) {
  32561. i = collection.length;
  32562. while (i--) {
  32563. // Loop down until the interted element has higher index
  32564. if (indexOption >=
  32565. pick(collection[i].options.index, collection[i]._i)) {
  32566. collection.splice(i + 1, 0, this);
  32567. break;
  32568. }
  32569. }
  32570. if (i === -1) {
  32571. collection.unshift(this);
  32572. }
  32573. i = i + 1;
  32574. // Or just push it to the end
  32575. }
  32576. else {
  32577. collection.push(this);
  32578. }
  32579. return pick(i, collection.length - 1);
  32580. };
  32581. /**
  32582. * Set the xAxis and yAxis properties of cartesian series, and register
  32583. * the series in the `axis.series` array.
  32584. *
  32585. * @private
  32586. * @function Highcharts.Series#bindAxes
  32587. */
  32588. Series.prototype.bindAxes = function () {
  32589. var series = this,
  32590. seriesOptions = series.options,
  32591. chart = series.chart,
  32592. axisOptions;
  32593. fireEvent(this, 'bindAxes', null, function () {
  32594. // repeat for xAxis and yAxis
  32595. (series.axisTypes || []).forEach(function (AXIS) {
  32596. var index = 0;
  32597. // loop through the chart's axis objects
  32598. chart[AXIS].forEach(function (axis) {
  32599. axisOptions = axis.options;
  32600. // apply if the series xAxis or yAxis option mathches
  32601. // the number of the axis, or if undefined, use the
  32602. // first axis
  32603. if ((seriesOptions[AXIS] === index &&
  32604. !axisOptions.isInternal) ||
  32605. (typeof seriesOptions[AXIS] !==
  32606. 'undefined' &&
  32607. seriesOptions[AXIS] === axisOptions.id) ||
  32608. (typeof seriesOptions[AXIS] ===
  32609. 'undefined' &&
  32610. axisOptions.index === 0)) {
  32611. // register this series in the axis.series lookup
  32612. series.insert(axis.series);
  32613. // set this series.xAxis or series.yAxis reference
  32614. /**
  32615. * Read only. The unique xAxis object associated
  32616. * with the series.
  32617. *
  32618. * @name Highcharts.Series#xAxis
  32619. * @type {Highcharts.Axis}
  32620. */
  32621. /**
  32622. * Read only. The unique yAxis object associated
  32623. * with the series.
  32624. *
  32625. * @name Highcharts.Series#yAxis
  32626. * @type {Highcharts.Axis}
  32627. */
  32628. series[AXIS] = axis;
  32629. // mark dirty for redraw
  32630. axis.isDirty = true;
  32631. }
  32632. if (!axisOptions.isInternal) {
  32633. index++;
  32634. }
  32635. });
  32636. // The series needs an X and an Y axis
  32637. if (!series[AXIS] &&
  32638. series.optionalAxis !== AXIS) {
  32639. error(18, true, chart);
  32640. }
  32641. });
  32642. });
  32643. fireEvent(this, 'afterBindAxes');
  32644. };
  32645. /**
  32646. * For simple series types like line and column, the data values are
  32647. * held in arrays like xData and yData for quick lookup to find extremes
  32648. * and more. For multidimensional series like bubble and map, this can
  32649. * be extended with arrays like zData and valueData by adding to the
  32650. * `series.parallelArrays` array.
  32651. *
  32652. * @private
  32653. * @function Highcharts.Series#updateParallelArrays
  32654. */
  32655. Series.prototype.updateParallelArrays = function (point, i) {
  32656. var series = point.series,
  32657. args = arguments,
  32658. fn = isNumber(i) ?
  32659. // Insert the value in the given position
  32660. function (key) {
  32661. var val = key === 'y' && series.toYData ?
  32662. series.toYData(point) :
  32663. point[key];
  32664. series[key + 'Data'][i] = val;
  32665. } :
  32666. // Apply the method specified in i with the following
  32667. // arguments as arguments
  32668. function (key) {
  32669. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  32670. };
  32671. series.parallelArrays.forEach(fn);
  32672. };
  32673. /**
  32674. * Define hasData functions for series. These return true if there
  32675. * are data points on this series within the plot area.
  32676. *
  32677. * @private
  32678. * @function Highcharts.Series#hasData
  32679. * @return {boolean}
  32680. */
  32681. Series.prototype.hasData = function () {
  32682. return ((this.visible &&
  32683. typeof this.dataMax !== 'undefined' &&
  32684. typeof this.dataMin !== 'undefined') || ( // #3703
  32685. this.visible &&
  32686. this.yData &&
  32687. this.yData.length > 0) // #9758
  32688. );
  32689. };
  32690. /**
  32691. * Return an auto incremented x value based on the pointStart and
  32692. * pointInterval options. This is only used if an x value is not given
  32693. * for the point that calls autoIncrement.
  32694. *
  32695. * @private
  32696. * @function Highcharts.Series#autoIncrement
  32697. * @return {number}
  32698. */
  32699. Series.prototype.autoIncrement = function () {
  32700. var options = this.options,
  32701. xIncrement = this.xIncrement,
  32702. date,
  32703. pointInterval,
  32704. pointIntervalUnit = options.pointIntervalUnit,
  32705. time = this.chart.time;
  32706. xIncrement = pick(xIncrement, options.pointStart, 0);
  32707. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  32708. // Added code for pointInterval strings
  32709. if (pointIntervalUnit) {
  32710. date = new time.Date(xIncrement);
  32711. if (pointIntervalUnit === 'day') {
  32712. time.set('Date', date, time.get('Date', date) + pointInterval);
  32713. }
  32714. else if (pointIntervalUnit === 'month') {
  32715. time.set('Month', date, time.get('Month', date) + pointInterval);
  32716. }
  32717. else if (pointIntervalUnit === 'year') {
  32718. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  32719. }
  32720. pointInterval = date.getTime() - xIncrement;
  32721. }
  32722. this.xIncrement = xIncrement + pointInterval;
  32723. return xIncrement;
  32724. };
  32725. /**
  32726. * Internal function to set properties for series if data sorting is
  32727. * enabled.
  32728. *
  32729. * @private
  32730. * @function Highcharts.Series#setDataSortingOptions
  32731. */
  32732. Series.prototype.setDataSortingOptions = function () {
  32733. var options = this.options;
  32734. extend(this, {
  32735. requireSorting: false,
  32736. sorted: false,
  32737. enabledDataSorting: true,
  32738. allowDG: false
  32739. });
  32740. // To allow unsorted data for column series.
  32741. if (!defined(options.pointRange)) {
  32742. options.pointRange = 1;
  32743. }
  32744. };
  32745. /**
  32746. * Set the series options by merging from the options tree. Called
  32747. * internally on initializing and updating series. This function will
  32748. * not redraw the series. For API usage, use {@link Series#update}.
  32749. * @private
  32750. * @function Highcharts.Series#setOptions
  32751. *
  32752. * @param {Highcharts.SeriesOptionsType} itemOptions
  32753. * The series options.
  32754. *
  32755. * @return {Highcharts.SeriesOptionsType}
  32756. *
  32757. * @fires Highcharts.Series#event:afterSetOptions
  32758. */
  32759. Series.prototype.setOptions = function (itemOptions) {
  32760. var chart = this.chart,
  32761. chartOptions = chart.options,
  32762. plotOptions = chartOptions.plotOptions,
  32763. userOptions = chart.userOptions || {},
  32764. seriesUserOptions = merge(itemOptions),
  32765. options,
  32766. zones,
  32767. zone,
  32768. styledMode = chart.styledMode,
  32769. e = {
  32770. plotOptions: plotOptions,
  32771. userOptions: seriesUserOptions
  32772. };
  32773. fireEvent(this, 'setOptions', e);
  32774. // These may be modified by the event
  32775. var typeOptions = e.plotOptions[this.type],
  32776. userPlotOptions = (userOptions.plotOptions || {});
  32777. // use copy to prevent undetected changes (#9762)
  32778. /**
  32779. * Contains series options by the user without defaults.
  32780. * @name Highcharts.Series#userOptions
  32781. * @type {Highcharts.SeriesOptionsType}
  32782. */
  32783. this.userOptions = e.userOptions;
  32784. options = merge(typeOptions, plotOptions.series,
  32785. // #3881, chart instance plotOptions[type] should trump
  32786. // plotOptions.series
  32787. userOptions.plotOptions &&
  32788. userOptions.plotOptions[this.type], seriesUserOptions);
  32789. // The tooltip options are merged between global and series specific
  32790. // options. Importance order asscendingly:
  32791. // globals: (1)tooltip, (2)plotOptions.series,
  32792. // (3)plotOptions[this.type]
  32793. // init userOptions with possible later updates: 4-6 like 1-3 and
  32794. // (7)this series options
  32795. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  32796. defaultOptions.plotOptions.series &&
  32797. defaultOptions.plotOptions.series.tooltip, // 2
  32798. defaultOptions.plotOptions[this.type].tooltip, // 3
  32799. chartOptions.tooltip.userOptions, // 4
  32800. plotOptions.series &&
  32801. plotOptions.series.tooltip, // 5
  32802. plotOptions[this.type].tooltip, // 6
  32803. seriesUserOptions.tooltip // 7
  32804. );
  32805. // When shared tooltip, stickyTracking is true by default,
  32806. // unless user says otherwise.
  32807. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  32808. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  32809. true :
  32810. options.stickyTracking));
  32811. // Delete marker object if not allowed (#1125)
  32812. if (typeOptions.marker === null) {
  32813. delete options.marker;
  32814. }
  32815. // Handle color zones
  32816. this.zoneAxis = options.zoneAxis;
  32817. zones = this.zones = (options.zones || []).slice();
  32818. if ((options.negativeColor || options.negativeFillColor) &&
  32819. !options.zones) {
  32820. zone = {
  32821. value: options[this.zoneAxis + 'Threshold'] ||
  32822. options.threshold ||
  32823. 0,
  32824. className: 'highcharts-negative'
  32825. };
  32826. if (!styledMode) {
  32827. zone.color = options.negativeColor;
  32828. zone.fillColor = options.negativeFillColor;
  32829. }
  32830. zones.push(zone);
  32831. }
  32832. if (zones.length) { // Push one extra zone for the rest
  32833. if (defined(zones[zones.length - 1].value)) {
  32834. zones.push(styledMode ? {} : {
  32835. color: this.color,
  32836. fillColor: this.fillColor
  32837. });
  32838. }
  32839. }
  32840. fireEvent(this, 'afterSetOptions', { options: options });
  32841. return options;
  32842. };
  32843. /**
  32844. * Return series name in "Series {Number}" format or the one defined by
  32845. * a user. This method can be simply overridden as series name format
  32846. * can vary (e.g. technical indicators).
  32847. *
  32848. * @function Highcharts.Series#getName
  32849. *
  32850. * @return {string}
  32851. * The series name.
  32852. */
  32853. Series.prototype.getName = function () {
  32854. // #4119
  32855. return pick(this.options.name, 'Series ' + (this.index + 1));
  32856. };
  32857. /**
  32858. * @private
  32859. * @function Highcharts.Series#getCyclic
  32860. */
  32861. Series.prototype.getCyclic = function (prop, value, defaults) {
  32862. var i, chart = this.chart, userOptions = this.userOptions, indexName = prop + 'Index', counterName = prop + 'Counter', len = defaults ? defaults.length : pick(chart.options.chart[prop + 'Count'], chart[prop + 'Count']), setting;
  32863. if (!value) {
  32864. // Pick up either the colorIndex option, or the _colorIndex
  32865. // after Series.update()
  32866. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  32867. if (defined(setting)) { // after Series.update()
  32868. i = setting;
  32869. }
  32870. else {
  32871. // #6138
  32872. if (!chart.series.length) {
  32873. chart[counterName] = 0;
  32874. }
  32875. userOptions['_' + indexName] = i =
  32876. chart[counterName] % len;
  32877. chart[counterName] += 1;
  32878. }
  32879. if (defaults) {
  32880. value = defaults[i];
  32881. }
  32882. }
  32883. // Set the colorIndex
  32884. if (typeof i !== 'undefined') {
  32885. this[indexName] = i;
  32886. }
  32887. this[prop] = value;
  32888. };
  32889. /**
  32890. * Get the series' color based on either the options or pulled from
  32891. * global options.
  32892. *
  32893. * @private
  32894. * @function Highcharts.Series#getColor
  32895. */
  32896. Series.prototype.getColor = function () {
  32897. if (this.chart.styledMode) {
  32898. this.getCyclic('color');
  32899. }
  32900. else if (this.options.colorByPoint) {
  32901. this.color = palette.neutralColor20;
  32902. }
  32903. else {
  32904. this.getCyclic('color', this.options.color ||
  32905. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  32906. }
  32907. };
  32908. /**
  32909. * Get all points' instances created for this series.
  32910. *
  32911. * @private
  32912. * @function Highcharts.Series#getPointsCollection
  32913. * @return {Array<Highcharts.Point>}
  32914. */
  32915. Series.prototype.getPointsCollection = function () {
  32916. return (this.hasGroupedData ? this.points : this.data) || [];
  32917. };
  32918. /**
  32919. * Get the series' symbol based on either the options or pulled from
  32920. * global options.
  32921. *
  32922. * @private
  32923. * @function Highcharts.Series#getSymbol
  32924. * @return {void}
  32925. */
  32926. Series.prototype.getSymbol = function () {
  32927. var seriesMarkerOption = this.options.marker;
  32928. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  32929. };
  32930. /**
  32931. * Finds the index of an existing point that matches the given point
  32932. * options.
  32933. *
  32934. * @private
  32935. * @function Highcharts.Series#findPointIndex
  32936. * @param {Highcharts.PointOptionsObject} optionsObject
  32937. * The options of the point.
  32938. * @param {number} fromIndex
  32939. * The index to start searching from, used for optimizing
  32940. * series with required sorting.
  32941. * @returns {number|undefined}
  32942. * Returns the index of a matching point, or undefined if no
  32943. * match is found.
  32944. */
  32945. Series.prototype.findPointIndex = function (optionsObject, fromIndex) {
  32946. var id = optionsObject.id,
  32947. x = optionsObject.x,
  32948. oldData = this.points,
  32949. matchingPoint,
  32950. matchedById,
  32951. pointIndex,
  32952. matchKey,
  32953. dataSorting = this.options.dataSorting;
  32954. if (id) {
  32955. matchingPoint = this.chart.get(id);
  32956. }
  32957. else if (this.linkedParent || this.enabledDataSorting) {
  32958. matchKey = (dataSorting && dataSorting.matchByName) ?
  32959. 'name' : 'index';
  32960. matchingPoint = find(oldData, function (oldPoint) {
  32961. return !oldPoint.touched && oldPoint[matchKey] ===
  32962. optionsObject[matchKey];
  32963. });
  32964. // Add unmatched point as a new point
  32965. if (!matchingPoint) {
  32966. return void 0;
  32967. }
  32968. }
  32969. if (matchingPoint) {
  32970. pointIndex = matchingPoint && matchingPoint.index;
  32971. if (typeof pointIndex !== 'undefined') {
  32972. matchedById = true;
  32973. }
  32974. }
  32975. // Search for the same X in the existing data set
  32976. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  32977. pointIndex = this.xData.indexOf(x, fromIndex);
  32978. }
  32979. // Reduce pointIndex if data is cropped
  32980. if (pointIndex !== -1 &&
  32981. typeof pointIndex !== 'undefined' &&
  32982. this.cropped) {
  32983. pointIndex = (pointIndex >= this.cropStart) ?
  32984. pointIndex - this.cropStart : pointIndex;
  32985. }
  32986. if (!matchedById &&
  32987. oldData[pointIndex] && oldData[pointIndex].touched) {
  32988. pointIndex = void 0;
  32989. }
  32990. return pointIndex;
  32991. };
  32992. /**
  32993. * Internal function called from setData. If the point count is the same
  32994. * as is was, or if there are overlapping X values, just run
  32995. * Point.update which is cheaper, allows animation, and keeps references
  32996. * to points. This also allows adding or removing points if the X-es
  32997. * don't match.
  32998. *
  32999. * @private
  33000. * @function Highcharts.Series#updateData
  33001. */
  33002. Series.prototype.updateData = function (data, animation) {
  33003. var options = this.options,
  33004. dataSorting = options.dataSorting,
  33005. oldData = this.points,
  33006. pointsToAdd = [],
  33007. hasUpdatedByKey,
  33008. i,
  33009. point,
  33010. lastIndex,
  33011. requireSorting = this.requireSorting,
  33012. equalLength = data.length === oldData.length,
  33013. succeeded = true;
  33014. this.xIncrement = null;
  33015. // Iterate the new data
  33016. data.forEach(function (pointOptions, i) {
  33017. var id,
  33018. x,
  33019. pointIndex,
  33020. optionsObject = (defined(pointOptions) &&
  33021. this.pointClass.prototype.optionsToObject.call({ series: this },
  33022. pointOptions)) || {};
  33023. // Get the x of the new data point
  33024. x = optionsObject.x;
  33025. id = optionsObject.id;
  33026. if (id || isNumber(x)) {
  33027. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33028. // Matching X not found
  33029. // or used already due to ununique x values (#8995),
  33030. // add point (but later)
  33031. if (pointIndex === -1 ||
  33032. typeof pointIndex === 'undefined') {
  33033. pointsToAdd.push(pointOptions);
  33034. // Matching X found, update
  33035. }
  33036. else if (oldData[pointIndex] &&
  33037. pointOptions !== options.data[pointIndex]) {
  33038. oldData[pointIndex].update(pointOptions, false, null, false);
  33039. // Mark it touched, below we will remove all points that
  33040. // are not touched.
  33041. oldData[pointIndex].touched = true;
  33042. // Speed optimize by only searching after last known
  33043. // index. Performs ~20% bettor on large data sets.
  33044. if (requireSorting) {
  33045. lastIndex = pointIndex + 1;
  33046. }
  33047. // Point exists, no changes, don't remove it
  33048. }
  33049. else if (oldData[pointIndex]) {
  33050. oldData[pointIndex].touched = true;
  33051. }
  33052. // If the length is equal and some of the nodes had a
  33053. // match in the same position, we don't want to remove
  33054. // non-matches.
  33055. if (!equalLength ||
  33056. i !== pointIndex ||
  33057. (dataSorting && dataSorting.enabled) ||
  33058. this.hasDerivedData) {
  33059. hasUpdatedByKey = true;
  33060. }
  33061. }
  33062. else {
  33063. // Gather all points that are not matched
  33064. pointsToAdd.push(pointOptions);
  33065. }
  33066. }, this);
  33067. // Remove points that don't exist in the updated data set
  33068. if (hasUpdatedByKey) {
  33069. i = oldData.length;
  33070. while (i--) {
  33071. point = oldData[i];
  33072. if (point && !point.touched && point.remove) {
  33073. point.remove(false, animation);
  33074. }
  33075. }
  33076. // If we did not find keys (ids or x-values), and the length is the
  33077. // same, update one-to-one
  33078. }
  33079. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33080. data.forEach(function (point, i) {
  33081. // .update doesn't exist on a linked, hidden series (#3709)
  33082. // (#10187)
  33083. if (oldData[i].update && point !== oldData[i].y) {
  33084. oldData[i].update(point, false, null, false);
  33085. }
  33086. });
  33087. // Don't add new points since those configs are used above
  33088. pointsToAdd.length = 0;
  33089. // Did not succeed in updating data
  33090. }
  33091. else {
  33092. succeeded = false;
  33093. }
  33094. oldData.forEach(function (point) {
  33095. if (point) {
  33096. point.touched = false;
  33097. }
  33098. });
  33099. if (!succeeded) {
  33100. return false;
  33101. }
  33102. // Add new points
  33103. pointsToAdd.forEach(function (point) {
  33104. this.addPoint(point, false, null, null, false);
  33105. }, this);
  33106. if (this.xIncrement === null &&
  33107. this.xData &&
  33108. this.xData.length) {
  33109. this.xIncrement = arrayMax(this.xData);
  33110. this.autoIncrement();
  33111. }
  33112. return true;
  33113. };
  33114. /**
  33115. * Apply a new set of data to the series and optionally redraw it. The
  33116. * new data array is passed by reference (except in case of
  33117. * `updatePoints`), and may later be mutated when updating the chart
  33118. * data.
  33119. *
  33120. * Note the difference in behaviour when setting the same amount of
  33121. * points, or a different amount of points, as handled by the
  33122. * `updatePoints` parameter.
  33123. *
  33124. * @sample highcharts/members/series-setdata/
  33125. * Set new data from a button
  33126. * @sample highcharts/members/series-setdata-pie/
  33127. * Set data in a pie
  33128. * @sample stock/members/series-setdata/
  33129. * Set new data in Highcharts Stock
  33130. * @sample maps/members/series-setdata/
  33131. * Set new data in Highmaps
  33132. *
  33133. * @function Highcharts.Series#setData
  33134. *
  33135. * @param {Array<Highcharts.PointOptionsType>} data
  33136. * Takes an array of data in the same format as described under
  33137. * `series.{type}.data` for the given series type, for example a
  33138. * line series would take data in the form described under
  33139. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33140. *
  33141. * @param {boolean} [redraw=true]
  33142. * Whether to redraw the chart after the series is altered. If
  33143. * doing more operations on the chart, it is a good idea to set
  33144. * redraw to false and call {@link Chart#redraw} after.
  33145. *
  33146. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33147. * When the updated data is the same length as the existing data,
  33148. * points will be updated by default, and animation visualizes
  33149. * how the points are changed. Set false to disable animation, or
  33150. * a configuration object to set duration or easing.
  33151. *
  33152. * @param {boolean} [updatePoints=true]
  33153. * When this is true, points will be updated instead of replaced
  33154. * whenever possible. This occurs a) when the updated data is the
  33155. * same length as the existing data, b) when points are matched
  33156. * by their id's, or c) when points can be matched by X values.
  33157. * This allows updating with animation and performs better. In
  33158. * this case, the original array is not passed by reference. Set
  33159. * `false` to prevent.
  33160. */
  33161. Series.prototype.setData = function (data, redraw, animation, updatePoints) {
  33162. var series = this,
  33163. oldData = series.points,
  33164. oldDataLength = (oldData && oldData.length) || 0,
  33165. dataLength,
  33166. options = series.options,
  33167. chart = series.chart,
  33168. dataSorting = options.dataSorting,
  33169. firstPoint = null,
  33170. xAxis = series.xAxis,
  33171. i,
  33172. turboThreshold = options.turboThreshold,
  33173. pt,
  33174. xData = this.xData,
  33175. yData = this.yData,
  33176. pointArrayMap = series.pointArrayMap,
  33177. valueCount = pointArrayMap && pointArrayMap.length,
  33178. keys = options.keys,
  33179. indexOfX = 0,
  33180. indexOfY = 1,
  33181. updatedData;
  33182. data = data || [];
  33183. dataLength = data.length;
  33184. redraw = pick(redraw, true);
  33185. if (dataSorting && dataSorting.enabled) {
  33186. data = this.sortData(data);
  33187. }
  33188. // First try to run Point.update which is cheaper, allows animation,
  33189. // and keeps references to points.
  33190. if (updatePoints !== false &&
  33191. dataLength &&
  33192. oldDataLength &&
  33193. !series.cropped &&
  33194. !series.hasGroupedData &&
  33195. series.visible &&
  33196. // Soft updating has no benefit in boost, and causes JS error
  33197. // (#8355)
  33198. !series.isSeriesBoosting) {
  33199. updatedData = this.updateData(data, animation);
  33200. }
  33201. if (!updatedData) {
  33202. // Reset properties
  33203. series.xIncrement = null;
  33204. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33205. // Update parallel arrays
  33206. this.parallelArrays.forEach(function (key) {
  33207. series[key + 'Data'].length = 0;
  33208. });
  33209. // In turbo mode, only one- or twodimensional arrays of numbers
  33210. // are allowed. The first value is tested, and we assume that
  33211. // all the rest are defined the same way. Although the 'for'
  33212. // loops are similar, they are repeated inside each if-else
  33213. // conditional for max performance.
  33214. if (turboThreshold && dataLength > turboThreshold) {
  33215. firstPoint = series.getFirstValidPoint(data);
  33216. if (isNumber(firstPoint)) { // assume all points are numbers
  33217. for (i = 0; i < dataLength; i++) {
  33218. xData[i] = this.autoIncrement();
  33219. yData[i] = data[i];
  33220. }
  33221. // Assume all points are arrays when first point is
  33222. }
  33223. else if (isArray(firstPoint)) {
  33224. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33225. for (i = 0; i < dataLength; i++) {
  33226. pt = data[i];
  33227. xData[i] = pt[0];
  33228. yData[i] =
  33229. pt.slice(1, valueCount + 1);
  33230. }
  33231. }
  33232. else { // [x, y]
  33233. if (keys) {
  33234. indexOfX = keys.indexOf('x');
  33235. indexOfY = keys.indexOf('y');
  33236. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33237. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33238. }
  33239. for (i = 0; i < dataLength; i++) {
  33240. pt = data[i];
  33241. xData[i] = pt[indexOfX];
  33242. yData[i] = pt[indexOfY];
  33243. }
  33244. }
  33245. }
  33246. else {
  33247. // Highcharts expects configs to be numbers or arrays in
  33248. // turbo mode
  33249. error(12, false, chart);
  33250. }
  33251. }
  33252. else {
  33253. for (i = 0; i < dataLength; i++) {
  33254. // stray commas in oldIE:
  33255. if (typeof data[i] !== 'undefined') {
  33256. pt = { series: series };
  33257. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33258. series.updateParallelArrays(pt, i);
  33259. }
  33260. }
  33261. }
  33262. // Forgetting to cast strings to numbers is a common caveat when
  33263. // handling CSV or JSON
  33264. if (yData && isString(yData[0])) {
  33265. error(14, true, chart);
  33266. }
  33267. series.data = [];
  33268. series.options.data = series.userOptions.data = data;
  33269. // destroy old points
  33270. i = oldDataLength;
  33271. while (i--) {
  33272. if (oldData[i] && oldData[i].destroy) {
  33273. oldData[i].destroy();
  33274. }
  33275. }
  33276. // reset minRange (#878)
  33277. if (xAxis) {
  33278. xAxis.minRange = xAxis.userMinRange;
  33279. }
  33280. // redraw
  33281. series.isDirty = chart.isDirtyBox = true;
  33282. series.isDirtyData = !!oldData;
  33283. animation = false;
  33284. }
  33285. // Typically for pie series, points need to be processed and
  33286. // generated prior to rendering the legend
  33287. if (options.legendType === 'point') {
  33288. this.processData();
  33289. this.generatePoints();
  33290. }
  33291. if (redraw) {
  33292. chart.redraw(animation);
  33293. }
  33294. };
  33295. /**
  33296. * Internal function to sort series data
  33297. *
  33298. * @private
  33299. * @function Highcharts.Series#sortData
  33300. *
  33301. * @param {Array<Highcharts.PointOptionsType>} data
  33302. * Force data grouping.
  33303. *
  33304. * @return {Array<Highcharts.PointOptionsObject>}
  33305. */
  33306. Series.prototype.sortData = function (data) {
  33307. var series = this,
  33308. options = series.options,
  33309. dataSorting = options.dataSorting,
  33310. sortKey = dataSorting.sortKey || 'y',
  33311. sortedData,
  33312. getPointOptionsObject = function (series,
  33313. pointOptions) {
  33314. return (defined(pointOptions) &&
  33315. series.pointClass.prototype.optionsToObject.call({
  33316. series: series
  33317. },
  33318. pointOptions)) || {};
  33319. };
  33320. data.forEach(function (pointOptions, i) {
  33321. data[i] = getPointOptionsObject(series, pointOptions);
  33322. data[i].index = i;
  33323. }, this);
  33324. // Sorting
  33325. sortedData = data.concat().sort(function (a, b) {
  33326. var aValue = getNestedProperty(sortKey,
  33327. a);
  33328. var bValue = getNestedProperty(sortKey,
  33329. b);
  33330. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33331. });
  33332. // Set x value depending on the position in the array
  33333. sortedData.forEach(function (point, i) {
  33334. point.x = i;
  33335. }, this);
  33336. // Set the same x for linked series points if they don't have their
  33337. // own sorting
  33338. if (series.linkedSeries) {
  33339. series.linkedSeries.forEach(function (linkedSeries) {
  33340. var options = linkedSeries.options,
  33341. seriesData = options.data;
  33342. if ((!options.dataSorting ||
  33343. !options.dataSorting.enabled) &&
  33344. seriesData) {
  33345. seriesData.forEach(function (pointOptions, i) {
  33346. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33347. if (data[i]) {
  33348. seriesData[i].x = data[i].x;
  33349. seriesData[i].index = i;
  33350. }
  33351. });
  33352. linkedSeries.setData(seriesData, false);
  33353. }
  33354. });
  33355. }
  33356. return data;
  33357. };
  33358. /**
  33359. * Internal function to process the data by cropping away unused data
  33360. * points if the series is longer than the crop threshold. This saves
  33361. * computing time for large series.
  33362. *
  33363. * @private
  33364. * @function Highcharts.Series#getProcessedData
  33365. * @param {boolean} [forceExtremesFromAll]
  33366. * Force getting extremes of a total series data range.
  33367. * @return {Highcharts.SeriesProcessedDataObject}
  33368. */
  33369. Series.prototype.getProcessedData = function (forceExtremesFromAll) {
  33370. var series = this,
  33371. // copied during slice operation:
  33372. processedXData = series.xData,
  33373. processedYData = series.yData,
  33374. dataLength = processedXData.length,
  33375. croppedData,
  33376. cropStart = 0,
  33377. cropped,
  33378. distance,
  33379. closestPointRange,
  33380. xAxis = series.xAxis,
  33381. i, // loop variable
  33382. options = series.options,
  33383. cropThreshold = options.cropThreshold,
  33384. getExtremesFromAll = forceExtremesFromAll ||
  33385. series.getExtremesFromAll ||
  33386. options.getExtremesFromAll, // #4599
  33387. isCartesian = series.isCartesian,
  33388. xExtremes,
  33389. val2lin = xAxis && xAxis.val2lin,
  33390. isLog = !!(xAxis && xAxis.logarithmic),
  33391. throwOnUnsorted = series.requireSorting,
  33392. min,
  33393. max;
  33394. if (xAxis) {
  33395. // corrected for log axis (#3053)
  33396. xExtremes = xAxis.getExtremes();
  33397. min = xExtremes.min;
  33398. max = xExtremes.max;
  33399. }
  33400. // optionally filter out points outside the plot area
  33401. if (isCartesian &&
  33402. series.sorted &&
  33403. !getExtremesFromAll &&
  33404. (!cropThreshold ||
  33405. dataLength > cropThreshold ||
  33406. series.forceCrop)) {
  33407. // it's outside current extremes
  33408. if (processedXData[dataLength - 1] < min ||
  33409. processedXData[0] > max) {
  33410. processedXData = [];
  33411. processedYData = [];
  33412. // only crop if it's actually spilling out
  33413. }
  33414. else if (series.yData && (processedXData[0] < min ||
  33415. processedXData[dataLength - 1] > max)) {
  33416. croppedData = this.cropData(series.xData, series.yData, min, max);
  33417. processedXData = croppedData.xData;
  33418. processedYData = croppedData.yData;
  33419. cropStart = croppedData.start;
  33420. cropped = true;
  33421. }
  33422. }
  33423. // Find the closest distance between processed points
  33424. i = processedXData.length || 1;
  33425. while (--i) {
  33426. distance = (isLog ?
  33427. (val2lin(processedXData[i]) -
  33428. val2lin(processedXData[i - 1])) :
  33429. (processedXData[i] -
  33430. processedXData[i - 1]));
  33431. if (distance > 0 &&
  33432. (typeof closestPointRange === 'undefined' ||
  33433. distance < closestPointRange)) {
  33434. closestPointRange = distance;
  33435. // Unsorted data is not supported by the line tooltip, as well
  33436. // as data grouping and navigation in Stock charts (#725) and
  33437. // width calculation of columns (#1900)
  33438. }
  33439. else if (distance < 0 && throwOnUnsorted) {
  33440. error(15, false, series.chart);
  33441. throwOnUnsorted = false; // Only once
  33442. }
  33443. }
  33444. return {
  33445. xData: processedXData,
  33446. yData: processedYData,
  33447. cropped: cropped,
  33448. cropStart: cropStart,
  33449. closestPointRange: closestPointRange
  33450. };
  33451. };
  33452. /**
  33453. * Internal function to apply processed data.
  33454. * In Highcharts Stock, this function is extended to provide data grouping.
  33455. *
  33456. * @private
  33457. * @function Highcharts.Series#processData
  33458. * @param {boolean} [force]
  33459. * Force data grouping.
  33460. * @return {boolean|undefined}
  33461. */
  33462. Series.prototype.processData = function (force) {
  33463. var series = this,
  33464. xAxis = series.xAxis,
  33465. processedData;
  33466. // If the series data or axes haven't changed, don't go through
  33467. // this. Return false to pass the message on to override methods
  33468. // like in data grouping.
  33469. if (series.isCartesian &&
  33470. !series.isDirty &&
  33471. !xAxis.isDirty &&
  33472. !series.yAxis.isDirty &&
  33473. !force) {
  33474. return false;
  33475. }
  33476. processedData = series.getProcessedData();
  33477. // Record the properties
  33478. series.cropped = processedData.cropped; // undefined or true
  33479. series.cropStart = processedData.cropStart;
  33480. series.processedXData = processedData.xData;
  33481. series.processedYData = processedData.yData;
  33482. series.closestPointRange = series.basePointRange = processedData.closestPointRange;
  33483. };
  33484. /**
  33485. * Iterate over xData and crop values between min and max. Returns
  33486. * object containing crop start/end cropped xData with corresponding
  33487. * part of yData, dataMin and dataMax within the cropped range.
  33488. *
  33489. * @private
  33490. * @function Highcharts.Series#cropData
  33491. * @param {Array<number>} xData
  33492. * @param {Array<number>} yData
  33493. * @param {number} min
  33494. * @param {number} max
  33495. * @param {number} [cropShoulder]
  33496. * @return {Highcharts.SeriesCropDataObject}
  33497. */
  33498. Series.prototype.cropData = function (xData, yData, min, max, cropShoulder) {
  33499. var dataLength = xData.length,
  33500. cropStart = 0,
  33501. cropEnd = dataLength,
  33502. i,
  33503. j;
  33504. // line-type series need one point outside
  33505. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33506. // iterate up to find slice start
  33507. for (i = 0; i < dataLength; i++) {
  33508. if (xData[i] >= min) {
  33509. cropStart = Math.max(0, i - cropShoulder);
  33510. break;
  33511. }
  33512. }
  33513. // proceed to find slice end
  33514. for (j = i; j < dataLength; j++) {
  33515. if (xData[j] > max) {
  33516. cropEnd = j + cropShoulder;
  33517. break;
  33518. }
  33519. }
  33520. return {
  33521. xData: xData.slice(cropStart, cropEnd),
  33522. yData: yData.slice(cropStart, cropEnd),
  33523. start: cropStart,
  33524. end: cropEnd
  33525. };
  33526. };
  33527. /**
  33528. * Generate the data point after the data has been processed by cropping
  33529. * away unused points and optionally grouped in Highcharts Stock.
  33530. *
  33531. * @private
  33532. * @function Highcharts.Series#generatePoints
  33533. */
  33534. Series.prototype.generatePoints = function () {
  33535. var series = this,
  33536. options = series.options,
  33537. dataOptions = options.data,
  33538. data = series.data,
  33539. dataLength,
  33540. processedXData = series.processedXData,
  33541. processedYData = series.processedYData,
  33542. PointClass = series.pointClass,
  33543. processedDataLength = processedXData.length,
  33544. cropStart = series.cropStart || 0,
  33545. cursor,
  33546. hasGroupedData = series.hasGroupedData,
  33547. keys = options.keys,
  33548. point,
  33549. points = [],
  33550. i,
  33551. groupCropStartIndex = (options.dataGrouping &&
  33552. options.dataGrouping.groupAll ?
  33553. cropStart :
  33554. 0);
  33555. if (!data && !hasGroupedData) {
  33556. var arr = [];
  33557. arr.length = dataOptions.length;
  33558. data = series.data = arr;
  33559. }
  33560. if (keys && hasGroupedData) {
  33561. // grouped data has already applied keys (#6590)
  33562. series.options.keys = false;
  33563. }
  33564. for (i = 0; i < processedDataLength; i++) {
  33565. cursor = cropStart + i;
  33566. if (!hasGroupedData) {
  33567. point = data[cursor];
  33568. // #970:
  33569. if (!point &&
  33570. typeof dataOptions[cursor] !== 'undefined') {
  33571. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33572. }
  33573. }
  33574. else {
  33575. // splat the y data in case of ohlc data array
  33576. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33577. /**
  33578. * Highcharts Stock only. If a point object is created by data
  33579. * grouping, it doesn't reflect actual points in the raw
  33580. * data. In this case, the `dataGroup` property holds
  33581. * information that points back to the raw data.
  33582. *
  33583. * - `dataGroup.start` is the index of the first raw data
  33584. * point in the group.
  33585. *
  33586. * - `dataGroup.length` is the amount of points in the
  33587. * group.
  33588. *
  33589. * @product highstock
  33590. *
  33591. * @name Highcharts.Point#dataGroup
  33592. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33593. */
  33594. point.dataGroup = series.groupMap[groupCropStartIndex + i];
  33595. if (point.dataGroup.options) {
  33596. point.options = point.dataGroup.options;
  33597. extend(point, point.dataGroup.options);
  33598. // Collision of props and options (#9770)
  33599. delete point.dataLabels;
  33600. }
  33601. }
  33602. if (point) { // #6279
  33603. /**
  33604. * Contains the point's index in the `Series.points` array.
  33605. *
  33606. * @name Highcharts.Point#index
  33607. * @type {number}
  33608. * @readonly
  33609. */
  33610. // For faster access in Point.update
  33611. point.index = hasGroupedData ? (groupCropStartIndex + i) : cursor;
  33612. points[i] = point;
  33613. }
  33614. }
  33615. // restore keys options (#6590)
  33616. series.options.keys = keys;
  33617. // Hide cropped-away points - this only runs when the number of
  33618. // points is above cropThreshold, or when swithching view from
  33619. // non-grouped data to grouped data (#637)
  33620. if (data &&
  33621. (processedDataLength !== (dataLength = data.length) ||
  33622. hasGroupedData)) {
  33623. for (i = 0; i < dataLength; i++) {
  33624. // when has grouped data, clear all points
  33625. if (i === cropStart && !hasGroupedData) {
  33626. i += processedDataLength;
  33627. }
  33628. if (data[i]) {
  33629. data[i].destroyElements();
  33630. data[i].plotX = void 0; // #1003
  33631. }
  33632. }
  33633. }
  33634. /**
  33635. * Read only. An array containing those values converted to points.
  33636. * In case the series data length exceeds the `cropThreshold`, or if
  33637. * the data is grouped, `series.data` doesn't contain all the
  33638. * points. Also, in case a series is hidden, the `data` array may be
  33639. * empty. To access raw values, `series.options.data` will always be
  33640. * up to date. `Series.data` only contains the points that have been
  33641. * created on demand. To modify the data, use
  33642. * {@link Highcharts.Series#setData} or
  33643. * {@link Highcharts.Point#update}.
  33644. *
  33645. * @see Series.points
  33646. *
  33647. * @name Highcharts.Series#data
  33648. * @type {Array<Highcharts.Point>}
  33649. */
  33650. series.data = data;
  33651. /**
  33652. * An array containing all currently visible point objects. In case
  33653. * of cropping, the cropped-away points are not part of this array.
  33654. * The `series.points` array starts at `series.cropStart` compared
  33655. * to `series.data` and `series.options.data`. If however the series
  33656. * data is grouped, these can't be correlated one to one. To modify
  33657. * the data, use {@link Highcharts.Series#setData} or
  33658. * {@link Highcharts.Point#update}.
  33659. *
  33660. * @name Highcharts.Series#points
  33661. * @type {Array<Highcharts.Point>}
  33662. */
  33663. series.points = points;
  33664. fireEvent(this, 'afterGeneratePoints');
  33665. };
  33666. /**
  33667. * Get current X extremes for the visible data.
  33668. *
  33669. * @private
  33670. * @function Highcharts.Series#getXExtremes
  33671. *
  33672. * @param {Array<number>} xData
  33673. * The data to inspect. Defaults to the current data within the visible
  33674. * range.
  33675. *
  33676. * @return {Highcharts.RangeObject}
  33677. */
  33678. Series.prototype.getXExtremes = function (xData) {
  33679. return {
  33680. min: arrayMin(xData),
  33681. max: arrayMax(xData)
  33682. };
  33683. };
  33684. /**
  33685. * Calculate Y extremes for the visible data. The result is returned
  33686. * as an object with `dataMin` and `dataMax` properties.
  33687. *
  33688. * @private
  33689. * @function Highcharts.Series#getExtremes
  33690. *
  33691. * @param {Array<number>} [yData]
  33692. * The data to inspect. Defaults to the current data within the visible
  33693. * range.
  33694. * @param {boolean} [forceExtremesFromAll]
  33695. * Force getting extremes of a total series data range.
  33696. *
  33697. * @return {Highcharts.DataExtremesObject}
  33698. */
  33699. Series.prototype.getExtremes = function (yData, forceExtremesFromAll) {
  33700. var xAxis = this.xAxis,
  33701. yAxis = this.yAxis,
  33702. xData = this.processedXData || this.xData,
  33703. yDataLength,
  33704. activeYData = [],
  33705. activeCounter = 0,
  33706. // #2117, need to compensate for log X axis
  33707. xExtremes,
  33708. xMin = 0,
  33709. xMax = 0,
  33710. validValue,
  33711. withinRange,
  33712. // Handle X outside the viewed area. This does not work with
  33713. // non-sorted data like scatter (#7639).
  33714. shoulder = this.requireSorting ? this.cropShoulder : 0,
  33715. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  33716. x,
  33717. y,
  33718. i,
  33719. j;
  33720. yData = yData || this.stackedYData || this.processedYData || [];
  33721. yDataLength = yData.length;
  33722. if (xAxis) {
  33723. xExtremes = xAxis.getExtremes();
  33724. xMin = xExtremes.min;
  33725. xMax = xExtremes.max;
  33726. }
  33727. for (i = 0; i < yDataLength; i++) {
  33728. x = xData[i];
  33729. y = yData[i];
  33730. // For points within the visible range, including the first
  33731. // point outside the visible range (#7061), consider y extremes.
  33732. validValue = ((isNumber(y) || isArray(y)) &&
  33733. ((y.length || y > 0) || !positiveValuesOnly));
  33734. withinRange = (forceExtremesFromAll ||
  33735. this.getExtremesFromAll ||
  33736. this.options.getExtremesFromAll ||
  33737. this.cropped ||
  33738. !xAxis || // for colorAxis support
  33739. ((xData[i + shoulder] || x) >= xMin &&
  33740. (xData[i - shoulder] || x) <= xMax));
  33741. if (validValue && withinRange) {
  33742. j = y.length;
  33743. if (j) { // array, like ohlc or range data
  33744. while (j--) {
  33745. if (isNumber(y[j])) { // #7380, #11513
  33746. activeYData[activeCounter++] = y[j];
  33747. }
  33748. }
  33749. }
  33750. else {
  33751. activeYData[activeCounter++] = y;
  33752. }
  33753. }
  33754. }
  33755. var dataExtremes = {
  33756. dataMin: arrayMin(activeYData),
  33757. dataMax: arrayMax(activeYData)
  33758. };
  33759. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  33760. return dataExtremes;
  33761. };
  33762. /**
  33763. * Set the current data extremes as `dataMin` and `dataMax` on the
  33764. * Series item. Use this only when the series properties should be
  33765. * updated.
  33766. *
  33767. * @private
  33768. * @function Highcharts.Series#applyExtremes
  33769. */
  33770. Series.prototype.applyExtremes = function () {
  33771. var dataExtremes = this.getExtremes();
  33772. /**
  33773. * Contains the minimum value of the series' data point. Some series
  33774. * types like `networkgraph` do not support this property as they
  33775. * lack a `y`-value.
  33776. * @name Highcharts.Series#dataMin
  33777. * @type {number|undefined}
  33778. * @readonly
  33779. */
  33780. this.dataMin = dataExtremes.dataMin;
  33781. /**
  33782. * Contains the maximum value of the series' data point. Some series
  33783. * types like `networkgraph` do not support this property as they
  33784. * lack a `y`-value.
  33785. * @name Highcharts.Series#dataMax
  33786. * @type {number|undefined}
  33787. * @readonly
  33788. */
  33789. this.dataMax = dataExtremes.dataMax;
  33790. return dataExtremes;
  33791. };
  33792. /**
  33793. * Find and return the first non null point in the data
  33794. *
  33795. * @private
  33796. * @function Highcharts.Series.getFirstValidPoint
  33797. *
  33798. * @param {Array<Highcharts.PointOptionsType>} data
  33799. * Array of options for points
  33800. *
  33801. * @return {Highcharts.PointOptionsType}
  33802. */
  33803. Series.prototype.getFirstValidPoint = function (data) {
  33804. var firstPoint = null,
  33805. dataLength = data.length,
  33806. i = 0;
  33807. while (firstPoint === null && i < dataLength) {
  33808. firstPoint = data[i];
  33809. i++;
  33810. }
  33811. return firstPoint;
  33812. };
  33813. /**
  33814. * Translate data points from raw data values to chart specific
  33815. * positioning data needed later in the `drawPoints` and `drawGraph`
  33816. * functions. This function can be overridden in plugins and custom
  33817. * series type implementations.
  33818. *
  33819. * @function Highcharts.Series#translate
  33820. *
  33821. * @fires Highcharts.Series#events:translate
  33822. */
  33823. Series.prototype.translate = function () {
  33824. if (!this.processedXData) { // hidden series
  33825. this.processData();
  33826. }
  33827. this.generatePoints();
  33828. var series = this,
  33829. options = series.options,
  33830. stacking = options.stacking,
  33831. xAxis = series.xAxis,
  33832. categories = xAxis.categories,
  33833. enabledDataSorting = series.enabledDataSorting,
  33834. yAxis = series.yAxis,
  33835. points = series.points,
  33836. dataLength = points.length,
  33837. hasModifyValue = !!series.modifyValue,
  33838. i,
  33839. pointPlacement = series.pointPlacementToXValue(), // #7860
  33840. dynamicallyPlaced = Boolean(pointPlacement),
  33841. threshold = options.threshold,
  33842. stackThreshold = options.startFromThreshold ? threshold : 0,
  33843. plotX,
  33844. lastPlotX,
  33845. stackIndicator,
  33846. zoneAxis = this.zoneAxis || 'y',
  33847. closestPointRangePx = Number.MAX_VALUE;
  33848. /**
  33849. * Plotted coordinates need to be within a limited range. Drawing
  33850. * too far outside the viewport causes various rendering issues
  33851. * (#3201, #3923, #7555).
  33852. * @private
  33853. */
  33854. function limitedRange(val) {
  33855. return clamp(val, -1e5, 1e5);
  33856. }
  33857. // Translate each point
  33858. for (i = 0; i < dataLength; i++) {
  33859. var point = points[i],
  33860. xValue = point.x,
  33861. yValue = point.y,
  33862. yBottom = point.low,
  33863. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  33864. yValue <
  33865. (stackThreshold ? 0 : threshold) ?
  33866. '-' :
  33867. '') + series.stackKey],
  33868. pointStack = void 0,
  33869. stackValues = void 0;
  33870. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  33871. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  33872. point.isNull = true;
  33873. }
  33874. // Get the plotX translation
  33875. point.plotX = plotX = correctFloat(// #5236
  33876. limitedRange(xAxis.translate(// #3923
  33877. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  33878. );
  33879. // Calculate the bottom y value for stacked series
  33880. if (stacking &&
  33881. series.visible &&
  33882. stack &&
  33883. stack[xValue]) {
  33884. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  33885. if (!point.isNull) {
  33886. pointStack = stack[xValue];
  33887. stackValues =
  33888. pointStack.points[stackIndicator.key];
  33889. }
  33890. }
  33891. if (isArray(stackValues)) {
  33892. yBottom = stackValues[0];
  33893. yValue = stackValues[1];
  33894. if (yBottom === stackThreshold &&
  33895. stackIndicator.key ===
  33896. stack[xValue].base) {
  33897. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  33898. }
  33899. // #1200, #1232
  33900. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  33901. yBottom = null;
  33902. }
  33903. point.total = point.stackTotal = pointStack.total;
  33904. point.percentage =
  33905. pointStack.total &&
  33906. (point.y / pointStack.total * 100);
  33907. point.stackY = yValue;
  33908. // Place the stack label
  33909. // in case of variwide series (where widths of points are
  33910. // different in most cases), stack labels are positioned
  33911. // wrongly, so the call of the setOffset is omited here and
  33912. // labels are correctly positioned later, at the end of the
  33913. // variwide's translate function (#10962)
  33914. if (!series.irregularWidths) {
  33915. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  33916. }
  33917. }
  33918. // Set translated yBottom or remove it
  33919. point.yBottom = defined(yBottom) ?
  33920. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  33921. null;
  33922. // general hook, used for Highcharts Stock compare mode
  33923. if (hasModifyValue) {
  33924. yValue = series.modifyValue(yValue, point);
  33925. }
  33926. // Set the the plotY value, reset it for redraws
  33927. // #3201
  33928. point.plotY = void 0;
  33929. if (isNumber(yValue)) {
  33930. var translated = yAxis.translate(yValue,
  33931. false,
  33932. true,
  33933. false,
  33934. true);
  33935. if (typeof translated !== 'undefined') {
  33936. point.plotY = limitedRange(translated);
  33937. }
  33938. }
  33939. point.isInside = this.isPointInside(point);
  33940. // Set client related positions for mouse tracking
  33941. point.clientX = dynamicallyPlaced ?
  33942. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  33943. plotX; // #1514, #5383, #5518
  33944. // Negative points. For bubble charts, this means negative z
  33945. // values (#9728)
  33946. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  33947. threshold ||
  33948. 0);
  33949. // some API data
  33950. point.category = (categories &&
  33951. typeof categories[point.x] !== 'undefined' ?
  33952. categories[point.x] :
  33953. point.x);
  33954. // Determine auto enabling of markers (#3635, #5099)
  33955. if (!point.isNull && point.visible !== false) {
  33956. if (typeof lastPlotX !== 'undefined') {
  33957. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  33958. }
  33959. lastPlotX = plotX;
  33960. }
  33961. // Find point zone
  33962. point.zone = (this.zones.length && point.getZone());
  33963. // Animate new points with data sorting
  33964. if (!point.graphic && series.group && enabledDataSorting) {
  33965. point.isNew = true;
  33966. }
  33967. }
  33968. series.closestPointRangePx = closestPointRangePx;
  33969. fireEvent(this, 'afterTranslate');
  33970. };
  33971. /**
  33972. * Return the series points with null points filtered out.
  33973. *
  33974. * @function Highcharts.Series#getValidPoints
  33975. *
  33976. * @param {Array<Highcharts.Point>} [points]
  33977. * The points to inspect, defaults to {@link Series.points}.
  33978. *
  33979. * @param {boolean} [insideOnly=false]
  33980. * Whether to inspect only the points that are inside the visible view.
  33981. *
  33982. * @param {boolean} [allowNull=false]
  33983. * Whether to allow null points to pass as valid points.
  33984. *
  33985. * @return {Array<Highcharts.Point>}
  33986. * The valid points.
  33987. */
  33988. Series.prototype.getValidPoints = function (points, insideOnly, allowNull) {
  33989. var chart = this.chart;
  33990. // #3916, #5029, #5085
  33991. return (points || this.points || []).filter(function (point) {
  33992. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, { inverted: chart.inverted })) {
  33993. return false;
  33994. }
  33995. return point.visible !== false &&
  33996. (allowNull || !point.isNull);
  33997. });
  33998. };
  33999. /**
  34000. * Get the clipping for the series. Could be called for a series to
  34001. * initiate animating the clip or to set the final clip (only width
  34002. * and x).
  34003. *
  34004. * @private
  34005. * @function Highcharts.Series#getClip
  34006. *
  34007. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34008. * Initialize the animation.
  34009. *
  34010. * @param {boolean} [finalBox]
  34011. * Final size for the clip - end state for the animation.
  34012. *
  34013. * @return {Highcharts.Dictionary<number>}
  34014. */
  34015. Series.prototype.getClipBox = function (animation, finalBox) {
  34016. var series = this,
  34017. options = series.options,
  34018. chart = series.chart,
  34019. inverted = chart.inverted,
  34020. xAxis = series.xAxis,
  34021. yAxis = xAxis && series.yAxis,
  34022. clipBox,
  34023. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34024. if (animation && options.clip === false && yAxis) {
  34025. // support for not clipped series animation (#10450)
  34026. clipBox = inverted ? {
  34027. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34028. height: chart.chartWidth,
  34029. width: chart.chartHeight,
  34030. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34031. } : {
  34032. y: -yAxis.pos,
  34033. height: chart.chartHeight,
  34034. width: chart.chartWidth,
  34035. x: -xAxis.pos
  34036. };
  34037. // x and width will be changed later when setting for animation
  34038. // initial state in Series.setClip
  34039. }
  34040. else {
  34041. clipBox = series.clipBox || chart.clipBox;
  34042. if (finalBox) {
  34043. clipBox.width = chart.plotSizeX;
  34044. clipBox.x = (chart.scrollablePixelsX || 0) *
  34045. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34046. }
  34047. }
  34048. return !finalBox ? clipBox : {
  34049. width: clipBox.width,
  34050. x: clipBox.x
  34051. };
  34052. };
  34053. /**
  34054. * Get the shared clip key, creating it if it doesn't exist.
  34055. *
  34056. * @private
  34057. * @function Highcharts.Series#getSharedClipKey
  34058. */
  34059. Series.prototype.getSharedClipKey = function (animation) {
  34060. if (this.sharedClipKey) {
  34061. return this.sharedClipKey;
  34062. }
  34063. var sharedClipKey = [
  34064. animation && animation.duration,
  34065. animation && animation.easing,
  34066. animation && animation.defer,
  34067. this.getClipBox(animation).height,
  34068. this.options.xAxis,
  34069. this.options.yAxis
  34070. ].join(',');
  34071. if (this.options.clip !== false || animation) {
  34072. this.sharedClipKey = sharedClipKey;
  34073. }
  34074. return sharedClipKey;
  34075. };
  34076. /**
  34077. * Set the clipping for the series. For animated series it is called
  34078. * twice, first to initiate animating the clip then the second time
  34079. * without the animation to set the final clip.
  34080. *
  34081. * @private
  34082. * @function Highcharts.Series#setClip
  34083. */
  34084. Series.prototype.setClip = function (animation) {
  34085. var chart = this.chart,
  34086. options = this.options,
  34087. renderer = chart.renderer,
  34088. inverted = chart.inverted,
  34089. seriesClipBox = this.clipBox,
  34090. clipBox = this.getClipBox(animation),
  34091. sharedClipKey = this.getSharedClipKey(animation), // #4526
  34092. clipRect = chart.sharedClips[sharedClipKey],
  34093. markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34094. if (animation) {
  34095. clipBox.width = 0;
  34096. if (inverted) {
  34097. clipBox.x = chart.plotHeight +
  34098. (options.clip !== false ? 0 : chart.plotTop);
  34099. }
  34100. }
  34101. // If a clipping rectangle with the same properties is currently
  34102. // present in the chart, use that.
  34103. if (!clipRect) {
  34104. // When animation is set, prepare the initial positions
  34105. if (animation) {
  34106. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect =
  34107. renderer.clipRect(
  34108. // include the width of the first marker
  34109. inverted ? (chart.plotSizeX || 0) + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34110. }
  34111. chart.sharedClips[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34112. // Create hashmap for series indexes
  34113. clipRect.count = { length: 0 };
  34114. // When the series is rendered again before starting animating, in
  34115. // compliance to a responsive rule
  34116. }
  34117. else if (!chart.hasLoaded) {
  34118. clipRect.attr(clipBox);
  34119. }
  34120. if (animation) {
  34121. if (!clipRect.count[this.index]) {
  34122. clipRect.count[this.index] = true;
  34123. clipRect.count.length += 1;
  34124. }
  34125. }
  34126. if (options.clip !== false || animation) {
  34127. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34128. this.markerGroup.clip(markerClipRect);
  34129. }
  34130. // Remove the shared clipping rectangle when all series are shown
  34131. if (!animation) {
  34132. if (clipRect.count[this.index]) {
  34133. delete clipRect.count[this.index];
  34134. clipRect.count.length -= 1;
  34135. }
  34136. if (clipRect.count.length === 0) {
  34137. if (!seriesClipBox) {
  34138. chart.sharedClips[sharedClipKey] = clipRect.destroy();
  34139. }
  34140. if (markerClipRect) {
  34141. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect.destroy();
  34142. }
  34143. }
  34144. }
  34145. };
  34146. /**
  34147. * Animate in the series. Called internally twice. First with the `init`
  34148. * parameter set to true, which sets up the initial state of the
  34149. * animation. Then when ready, it is called with the `init` parameter
  34150. * undefined, in order to perform the actual animation. After the
  34151. * second run, the function is removed.
  34152. *
  34153. * @function Highcharts.Series#animate
  34154. *
  34155. * @param {boolean} [init]
  34156. * Initialize the animation.
  34157. */
  34158. Series.prototype.animate = function (init) {
  34159. var series = this,
  34160. chart = series.chart,
  34161. animation = animObject(series.options.animation),
  34162. sharedClipKey = this.sharedClipKey;
  34163. // Initialize the animation. Set up the clipping rectangle.
  34164. if (init) {
  34165. series.setClip(animation);
  34166. // Run the animation
  34167. }
  34168. else if (sharedClipKey) {
  34169. var clipRect = chart.sharedClips[sharedClipKey];
  34170. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34171. var finalBox = series.getClipBox(animation,
  34172. true);
  34173. if (clipRect) {
  34174. clipRect.animate(finalBox, animation);
  34175. }
  34176. if (markerClipRect) {
  34177. markerClipRect.animate({
  34178. width: finalBox.width + 99,
  34179. x: finalBox.x - (chart.inverted ? 0 : 99)
  34180. }, animation);
  34181. }
  34182. }
  34183. };
  34184. /**
  34185. * This runs after animation to land on the final plot clipping.
  34186. *
  34187. * @private
  34188. * @function Highcharts.Series#afterAnimate
  34189. *
  34190. * @fires Highcharts.Series#event:afterAnimate
  34191. */
  34192. Series.prototype.afterAnimate = function () {
  34193. this.setClip();
  34194. fireEvent(this, 'afterAnimate');
  34195. this.finishedAnimating = true;
  34196. };
  34197. /**
  34198. * Draw the markers for line-like series types, and columns or other
  34199. * graphical representation for {@link Point} objects for other series
  34200. * types. The resulting element is typically stored as
  34201. * {@link Point.graphic}, and is created on the first call and updated
  34202. * and moved on subsequent calls.
  34203. *
  34204. * @function Highcharts.Series#drawPoints
  34205. */
  34206. Series.prototype.drawPoints = function () {
  34207. var series = this,
  34208. points = series.points,
  34209. chart = series.chart,
  34210. i,
  34211. point,
  34212. graphic,
  34213. verb,
  34214. options = series.options,
  34215. seriesMarkerOptions = options.marker,
  34216. pointMarkerOptions,
  34217. hasPointMarker,
  34218. markerGroup = (series[series.specialGroup] ||
  34219. series.markerGroup),
  34220. xAxis = series.xAxis,
  34221. markerAttribs,
  34222. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34223. // Use larger or equal as radius is null in bubbles (#6321)
  34224. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34225. seriesMarkerOptions.radius));
  34226. if (seriesMarkerOptions.enabled !== false ||
  34227. series._hasPointMarkers) {
  34228. for (i = 0; i < points.length; i++) {
  34229. point = points[i];
  34230. graphic = point.graphic;
  34231. verb = graphic ? 'animate' : 'attr';
  34232. pointMarkerOptions = point.marker || {};
  34233. hasPointMarker = !!point.marker;
  34234. var shouldDrawMarker = ((globallyEnabled &&
  34235. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34236. // only draw the point if y is defined
  34237. if (shouldDrawMarker) {
  34238. // Shortcuts
  34239. var symbol = pick(pointMarkerOptions.symbol,
  34240. series.symbol);
  34241. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34242. // Set starting position for point sliding animation.
  34243. if (series.enabledDataSorting) {
  34244. point.startXPos = xAxis.reversed ?
  34245. -(markerAttribs.width || 0) :
  34246. xAxis.width;
  34247. }
  34248. var isInside = point.isInside !== false;
  34249. if (graphic) { // update
  34250. // Since the marker group isn't clipped, each
  34251. // individual marker must be toggled
  34252. graphic[isInside ? 'show' : 'hide'](isInside)
  34253. .animate(markerAttribs);
  34254. }
  34255. else if (isInside &&
  34256. ((markerAttribs.width || 0) > 0 || point.hasImage)) {
  34257. /**
  34258. * The graphic representation of the point.
  34259. * Typically this is a simple shape, like a `rect`
  34260. * for column charts or `path` for line markers, but
  34261. * for some complex series types like boxplot or 3D
  34262. * charts, the graphic may be a `g` element
  34263. * containing other shapes. The graphic is generated
  34264. * the first time {@link Series#drawPoints} runs,
  34265. * and updated and moved on subsequent runs.
  34266. *
  34267. * @name Point#graphic
  34268. * @type {SVGElement}
  34269. */
  34270. point.graphic = graphic = chart.renderer
  34271. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34272. pointMarkerOptions :
  34273. seriesMarkerOptions)
  34274. .add(markerGroup);
  34275. // Sliding animation for new points
  34276. if (series.enabledDataSorting &&
  34277. chart.hasRendered) {
  34278. graphic.attr({
  34279. x: point.startXPos
  34280. });
  34281. verb = 'animate';
  34282. }
  34283. }
  34284. if (graphic && verb === 'animate') { // update
  34285. // Since the marker group isn't clipped, each
  34286. // individual marker must be toggled
  34287. graphic[isInside ? 'show' : 'hide'](isInside)
  34288. .animate(markerAttribs);
  34289. }
  34290. // Presentational attributes
  34291. if (graphic && !chart.styledMode) {
  34292. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34293. }
  34294. if (graphic) {
  34295. graphic.addClass(point.getClassName(), true);
  34296. }
  34297. }
  34298. else if (graphic) {
  34299. point.graphic = graphic.destroy(); // #1269
  34300. }
  34301. }
  34302. }
  34303. };
  34304. /**
  34305. * Get non-presentational attributes for a point. Used internally for
  34306. * both styled mode and classic. Can be overridden for different series
  34307. * types.
  34308. *
  34309. * @see Series#pointAttribs
  34310. *
  34311. * @function Highcharts.Series#markerAttribs
  34312. *
  34313. * @param {Highcharts.Point} point
  34314. * The Point to inspect.
  34315. *
  34316. * @param {string} [state]
  34317. * The state, can be either `hover`, `select` or undefined.
  34318. *
  34319. * @return {Highcharts.SVGAttributes}
  34320. * A hash containing those attributes that are not settable from CSS.
  34321. */
  34322. Series.prototype.markerAttribs = function (point, state) {
  34323. var seriesOptions = this.options,
  34324. seriesMarkerOptions = seriesOptions.marker,
  34325. seriesStateOptions,
  34326. pointMarkerOptions = point.marker || {},
  34327. symbol = (pointMarkerOptions.symbol ||
  34328. seriesMarkerOptions.symbol),
  34329. pointStateOptions,
  34330. radius = pick(pointMarkerOptions.radius,
  34331. seriesMarkerOptions.radius),
  34332. attribs;
  34333. // Handle hover and select states
  34334. if (state) {
  34335. seriesStateOptions = seriesMarkerOptions.states[state];
  34336. pointStateOptions = pointMarkerOptions.states &&
  34337. pointMarkerOptions.states[state];
  34338. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34339. 0));
  34340. }
  34341. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34342. if (point.hasImage) {
  34343. radius = 0; // and subsequently width and height is not set
  34344. }
  34345. attribs = {
  34346. // Math.floor for #1843:
  34347. x: seriesOptions.crisp ?
  34348. Math.floor(point.plotX - radius) :
  34349. point.plotX - radius,
  34350. y: point.plotY - radius
  34351. };
  34352. if (radius) {
  34353. attribs.width = attribs.height = 2 * radius;
  34354. }
  34355. return attribs;
  34356. };
  34357. /**
  34358. * Internal function to get presentational attributes for each point.
  34359. * Unlike {@link Series#markerAttribs}, this function should return
  34360. * those attributes that can also be set in CSS. In styled mode,
  34361. * `pointAttribs` won't be called.
  34362. *
  34363. * @private
  34364. * @function Highcharts.Series#pointAttribs
  34365. *
  34366. * @param {Highcharts.Point} [point]
  34367. * The point instance to inspect.
  34368. *
  34369. * @param {string} [state]
  34370. * The point state, can be either `hover`, `select` or 'normal'. If
  34371. * undefined, normal state is assumed.
  34372. *
  34373. * @return {Highcharts.SVGAttributes}
  34374. * The presentational attributes to be set on the point.
  34375. */
  34376. Series.prototype.pointAttribs = function (point, state) {
  34377. var seriesMarkerOptions = this.options.marker,
  34378. seriesStateOptions,
  34379. pointOptions = point && point.options,
  34380. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34381. pointStateOptions,
  34382. color = this.color,
  34383. pointColorOption = pointOptions && pointOptions.color,
  34384. pointColor = point && point.color,
  34385. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34386. seriesMarkerOptions.lineWidth),
  34387. zoneColor = point && point.zone && point.zone.color,
  34388. fill,
  34389. stroke,
  34390. opacity = 1;
  34391. color = (pointColorOption ||
  34392. zoneColor ||
  34393. pointColor ||
  34394. color);
  34395. fill = (pointMarkerOptions.fillColor ||
  34396. seriesMarkerOptions.fillColor ||
  34397. color);
  34398. stroke = (pointMarkerOptions.lineColor ||
  34399. seriesMarkerOptions.lineColor ||
  34400. color);
  34401. // Handle hover and select states
  34402. state = state || 'normal';
  34403. if (state) {
  34404. seriesStateOptions = seriesMarkerOptions.states[state];
  34405. pointStateOptions = (pointMarkerOptions.states &&
  34406. pointMarkerOptions.states[state]) || {};
  34407. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34408. fill = (pointStateOptions.fillColor ||
  34409. seriesStateOptions.fillColor ||
  34410. fill);
  34411. stroke = (pointStateOptions.lineColor ||
  34412. seriesStateOptions.lineColor ||
  34413. stroke);
  34414. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34415. }
  34416. return {
  34417. 'stroke': stroke,
  34418. 'stroke-width': strokeWidth,
  34419. 'fill': fill,
  34420. 'opacity': opacity
  34421. };
  34422. };
  34423. /**
  34424. * Clear DOM objects and free up memory.
  34425. *
  34426. * @private
  34427. * @function Highcharts.Series#destroy
  34428. *
  34429. * @fires Highcharts.Series#event:destroy
  34430. */
  34431. Series.prototype.destroy = function (keepEventsForUpdate) {
  34432. var series = this,
  34433. chart = series.chart,
  34434. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34435. destroy,
  34436. i,
  34437. data = series.data || [],
  34438. point,
  34439. axis;
  34440. // add event hook
  34441. fireEvent(series, 'destroy');
  34442. // remove events
  34443. this.removeEvents(keepEventsForUpdate);
  34444. // erase from axes
  34445. (series.axisTypes || []).forEach(function (AXIS) {
  34446. axis = series[AXIS];
  34447. if (axis && axis.series) {
  34448. erase(axis.series, series);
  34449. axis.isDirty = axis.forceRedraw = true;
  34450. }
  34451. });
  34452. // remove legend items
  34453. if (series.legendItem) {
  34454. series.chart.legend.destroyItem(series);
  34455. }
  34456. // destroy all points with their elements
  34457. i = data.length;
  34458. while (i--) {
  34459. point = data[i];
  34460. if (point && point.destroy) {
  34461. point.destroy();
  34462. }
  34463. }
  34464. if (series.clips) {
  34465. series.clips.forEach(function (clip) { return clip.destroy(); });
  34466. }
  34467. // Clear the animation timeout if we are destroying the series
  34468. // during initial animation
  34469. U.clearTimeout(series.animationTimeout);
  34470. // Destroy all SVGElements associated to the series
  34471. objectEach(series, function (val, prop) {
  34472. // Survive provides a hook for not destroying
  34473. if (val instanceof SVGElement && !val.survive) {
  34474. // issue 134 workaround
  34475. destroy = issue134 && prop === 'group' ?
  34476. 'hide' :
  34477. 'destroy';
  34478. val[destroy]();
  34479. }
  34480. });
  34481. // remove from hoverSeries
  34482. if (chart.hoverSeries === series) {
  34483. chart.hoverSeries = void 0;
  34484. }
  34485. erase(chart.series, series);
  34486. chart.orderSeries();
  34487. // clear all members
  34488. objectEach(series, function (val, prop) {
  34489. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34490. delete series[prop];
  34491. }
  34492. });
  34493. };
  34494. /**
  34495. * Clip the graphs into zones for colors and styling.
  34496. *
  34497. * @private
  34498. * @function Highcharts.Series#applyZones
  34499. */
  34500. Series.prototype.applyZones = function () {
  34501. var series = this,
  34502. chart = this.chart,
  34503. renderer = chart.renderer,
  34504. zones = this.zones,
  34505. translatedFrom,
  34506. translatedTo,
  34507. clips = (this.clips || []),
  34508. clipAttr,
  34509. graph = this.graph,
  34510. area = this.area,
  34511. chartSizeMax = Math.max(chart.chartWidth,
  34512. chart.chartHeight),
  34513. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  34514. extremes,
  34515. reversed,
  34516. inverted = chart.inverted,
  34517. horiz,
  34518. pxRange,
  34519. pxPosMin,
  34520. pxPosMax,
  34521. ignoreZones = false,
  34522. zoneArea,
  34523. zoneGraph;
  34524. if (zones.length &&
  34525. (graph || area) &&
  34526. axis &&
  34527. typeof axis.min !== 'undefined') {
  34528. reversed = axis.reversed;
  34529. horiz = axis.horiz;
  34530. // The use of the Color Threshold assumes there are no gaps
  34531. // so it is safe to hide the original graph and area
  34532. // unless it is not waterfall series, then use showLine property
  34533. // to set lines between columns to be visible (#7862)
  34534. if (graph && !this.showLine) {
  34535. graph.hide();
  34536. }
  34537. if (area) {
  34538. area.hide();
  34539. }
  34540. // Create the clips
  34541. extremes = axis.getExtremes();
  34542. zones.forEach(function (threshold, i) {
  34543. translatedFrom = reversed ?
  34544. (horiz ? chart.plotWidth : 0) :
  34545. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  34546. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  34547. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  34548. if (ignoreZones) {
  34549. translatedFrom = translatedTo =
  34550. axis.toPixels(extremes.max);
  34551. }
  34552. pxRange = Math.abs(translatedFrom - translatedTo);
  34553. pxPosMin = Math.min(translatedFrom, translatedTo);
  34554. pxPosMax = Math.max(translatedFrom, translatedTo);
  34555. if (axis.isXAxis) {
  34556. clipAttr = {
  34557. x: inverted ? pxPosMax : pxPosMin,
  34558. y: 0,
  34559. width: pxRange,
  34560. height: chartSizeMax
  34561. };
  34562. if (!horiz) {
  34563. clipAttr.x = chart.plotHeight - clipAttr.x;
  34564. }
  34565. }
  34566. else {
  34567. clipAttr = {
  34568. x: 0,
  34569. y: inverted ? pxPosMax : pxPosMin,
  34570. width: chartSizeMax,
  34571. height: pxRange
  34572. };
  34573. if (horiz) {
  34574. clipAttr.y = chart.plotWidth - clipAttr.y;
  34575. }
  34576. }
  34577. // VML SUPPPORT
  34578. if (inverted && renderer.isVML) {
  34579. if (axis.isXAxis) {
  34580. clipAttr = {
  34581. x: 0,
  34582. y: reversed ? pxPosMin : pxPosMax,
  34583. height: clipAttr.width,
  34584. width: chart.chartWidth
  34585. };
  34586. }
  34587. else {
  34588. clipAttr = {
  34589. x: (clipAttr.y -
  34590. chart.plotLeft -
  34591. chart.spacingBox.x),
  34592. y: 0,
  34593. width: clipAttr.height,
  34594. height: chart.chartHeight
  34595. };
  34596. }
  34597. }
  34598. // END OF VML SUPPORT
  34599. if (clips[i]) {
  34600. clips[i].animate(clipAttr);
  34601. }
  34602. else {
  34603. clips[i] = renderer.clipRect(clipAttr);
  34604. }
  34605. // when no data, graph zone is not applied and after setData
  34606. // clip was ignored. As a result, it should be applied each
  34607. // time.
  34608. zoneArea = series['zone-area-' + i];
  34609. zoneGraph = series['zone-graph-' + i];
  34610. if (graph && zoneGraph) {
  34611. zoneGraph.clip(clips[i]);
  34612. }
  34613. if (area && zoneArea) {
  34614. zoneArea.clip(clips[i]);
  34615. }
  34616. // if this zone extends out of the axis, ignore the others
  34617. ignoreZones = threshold.value > extremes.max;
  34618. // Clear translatedTo for indicators
  34619. if (series.resetZones && translatedTo === 0) {
  34620. translatedTo = void 0;
  34621. }
  34622. });
  34623. this.clips = clips;
  34624. }
  34625. else if (series.visible) {
  34626. // If zones were removed, restore graph and area
  34627. if (graph) {
  34628. graph.show(true);
  34629. }
  34630. if (area) {
  34631. area.show(true);
  34632. }
  34633. }
  34634. };
  34635. /**
  34636. * Initialize and perform group inversion on series.group and
  34637. * series.markerGroup.
  34638. *
  34639. * @private
  34640. * @function Highcharts.Series#invertGroups
  34641. */
  34642. Series.prototype.invertGroups = function (inverted) {
  34643. var series = this,
  34644. chart = series.chart;
  34645. /**
  34646. * @private
  34647. */
  34648. function setInvert() {
  34649. ['group', 'markerGroup'].forEach(function (groupName) {
  34650. if (series[groupName]) {
  34651. // VML/HTML needs explicit attributes for flipping
  34652. if (chart.renderer.isVML) {
  34653. series[groupName].attr({
  34654. width: series.yAxis.len,
  34655. height: series.xAxis.len
  34656. });
  34657. }
  34658. series[groupName].width = series.yAxis.len;
  34659. series[groupName].height = series.xAxis.len;
  34660. // If inverted polar, don't invert series group
  34661. series[groupName].invert(series.isRadialSeries ? false : inverted);
  34662. }
  34663. });
  34664. }
  34665. // Pie, go away (#1736)
  34666. if (!series.xAxis) {
  34667. return;
  34668. }
  34669. // A fixed size is needed for inversion to work
  34670. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  34671. // Do it now
  34672. setInvert();
  34673. // On subsequent render and redraw, just do setInvert without
  34674. // setting up events again
  34675. series.invertGroups = setInvert;
  34676. };
  34677. /**
  34678. * General abstraction for creating plot groups like series.group,
  34679. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  34680. * the group will only be adjusted to the updated plot size.
  34681. *
  34682. * @private
  34683. * @function Highcharts.Series#plotGroup
  34684. */
  34685. Series.prototype.plotGroup = function (prop, name, visibility, zIndex, parent) {
  34686. var group = this[prop],
  34687. isNew = !group,
  34688. attrs = {
  34689. visibility: visibility,
  34690. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  34691. };
  34692. // Avoid setting undefined opacity, or in styled mode
  34693. if (typeof this.opacity !== 'undefined' &&
  34694. !this.chart.styledMode && this.state !== 'inactive' // #13719
  34695. ) {
  34696. attrs.opacity = this.opacity;
  34697. }
  34698. // Generate it on first call
  34699. if (isNew) {
  34700. this[prop] = group = this.chart.renderer
  34701. .g()
  34702. .add(parent);
  34703. }
  34704. // Add the class names, and replace existing ones as response to
  34705. // Series.update (#6660)
  34706. group.addClass(('highcharts-' + name +
  34707. ' highcharts-series-' + this.index +
  34708. ' highcharts-' + this.type + '-series ' +
  34709. (defined(this.colorIndex) ?
  34710. 'highcharts-color-' + this.colorIndex + ' ' :
  34711. '') +
  34712. (this.options.className || '') +
  34713. (group.hasClass('highcharts-tracker') ?
  34714. ' highcharts-tracker' :
  34715. '')), true);
  34716. // Place it on first and subsequent (redraw) calls
  34717. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  34718. return group;
  34719. };
  34720. /**
  34721. * Get the translation and scale for the plot area of this series.
  34722. *
  34723. * @function Highcharts.Series#getPlotBox
  34724. *
  34725. * @return {Highcharts.SeriesPlotBoxObject}
  34726. */
  34727. Series.prototype.getPlotBox = function () {
  34728. var chart = this.chart,
  34729. xAxis = this.xAxis,
  34730. yAxis = this.yAxis;
  34731. // Swap axes for inverted (#2339)
  34732. if (chart.inverted) {
  34733. xAxis = yAxis;
  34734. yAxis = this.xAxis;
  34735. }
  34736. return {
  34737. translateX: xAxis ? xAxis.left : chart.plotLeft,
  34738. translateY: yAxis ? yAxis.top : chart.plotTop,
  34739. scaleX: 1,
  34740. scaleY: 1
  34741. };
  34742. };
  34743. /**
  34744. * Removes the event handlers attached previously with addEvents.
  34745. * @private
  34746. * @function Highcharts.Series#removeEvents
  34747. */
  34748. Series.prototype.removeEvents = function (keepEventsForUpdate) {
  34749. var series = this;
  34750. if (!keepEventsForUpdate) {
  34751. // remove all events
  34752. removeEvent(series);
  34753. }
  34754. if (series.eventsToUnbind.length) {
  34755. // remove only internal events for proper update
  34756. // #12355 - solves problem with multiple destroy events
  34757. series.eventsToUnbind.forEach(function (unbind) {
  34758. unbind();
  34759. });
  34760. series.eventsToUnbind.length = 0;
  34761. }
  34762. };
  34763. /**
  34764. * Render the graph and markers. Called internally when first rendering
  34765. * and later when redrawing the chart. This function can be extended in
  34766. * plugins, but normally shouldn't be called directly.
  34767. *
  34768. * @function Highcharts.Series#render
  34769. *
  34770. * @fires Highcharts.Series#event:afterRender
  34771. */
  34772. Series.prototype.render = function () {
  34773. var series = this,
  34774. chart = series.chart,
  34775. group,
  34776. options = series.options,
  34777. animOptions = animObject(options.animation),
  34778. // Animation doesn't work in IE8 quirks when the group div is
  34779. // hidden, and looks bad in other oldIE
  34780. animDuration = (!series.finishedAnimating &&
  34781. chart.renderer.isSVG &&
  34782. animOptions.duration),
  34783. visibility = series.visible ?
  34784. 'inherit' : 'hidden', // #2597
  34785. zIndex = options.zIndex,
  34786. hasRendered = series.hasRendered,
  34787. chartSeriesGroup = chart.seriesGroup,
  34788. inverted = chart.inverted;
  34789. fireEvent(this, 'render');
  34790. // the group
  34791. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  34792. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  34793. // initiate the animation
  34794. if (animDuration && series.animate) {
  34795. series.animate(true);
  34796. }
  34797. // SVGRenderer needs to know this before drawing elements (#1089,
  34798. // #1795)
  34799. group.inverted = pick(series.invertible, series.isCartesian) ?
  34800. inverted : false;
  34801. // Draw the graph if any
  34802. if (series.drawGraph) {
  34803. series.drawGraph();
  34804. series.applyZones();
  34805. }
  34806. // Draw the points
  34807. if (series.visible) {
  34808. series.drawPoints();
  34809. }
  34810. /* series.points.forEach(function (point) {
  34811. if (point.redraw) {
  34812. point.redraw();
  34813. }
  34814. }); */
  34815. // Draw the data labels
  34816. if (series.drawDataLabels) {
  34817. series.drawDataLabels();
  34818. }
  34819. // In pie charts, slices are added to the DOM, but actual rendering
  34820. // is postponed until labels reserved their space
  34821. if (series.redrawPoints) {
  34822. series.redrawPoints();
  34823. }
  34824. // draw the mouse tracking area
  34825. if (series.drawTracker &&
  34826. series.options.enableMouseTracking !== false) {
  34827. series.drawTracker();
  34828. }
  34829. // Handle inverted series and tracker groups
  34830. series.invertGroups(inverted);
  34831. // Initial clipping, must be defined after inverting groups for VML.
  34832. // Applies to columns etc. (#3839).
  34833. if (options.clip !== false &&
  34834. !series.sharedClipKey &&
  34835. !hasRendered) {
  34836. group.clip(chart.clipRect);
  34837. }
  34838. // Run the animation
  34839. if (animDuration && series.animate) {
  34840. series.animate();
  34841. }
  34842. // Call the afterAnimate function on animation complete (but don't
  34843. // overwrite the animation.complete option which should be available
  34844. // to the user).
  34845. if (!hasRendered) {
  34846. // Additional time if defer is defined before afterAnimate
  34847. // will be triggered
  34848. if (animDuration && animOptions.defer) {
  34849. animDuration += animOptions.defer;
  34850. }
  34851. series.animationTimeout = syncTimeout(function () {
  34852. series.afterAnimate();
  34853. }, animDuration || 0);
  34854. }
  34855. // Means data is in accordance with what you see
  34856. series.isDirty = false;
  34857. // (See #322) series.isDirty = series.isDirtyData = false; // means
  34858. // data is in accordance with what you see
  34859. series.hasRendered = true;
  34860. fireEvent(series, 'afterRender');
  34861. };
  34862. /**
  34863. * Redraw the series. This function is called internally from
  34864. * `chart.redraw` and normally shouldn't be called directly.
  34865. * @private
  34866. * @function Highcharts.Series#redraw
  34867. */
  34868. Series.prototype.redraw = function () {
  34869. var series = this,
  34870. chart = series.chart,
  34871. // cache it here as it is set to false in render, but used after
  34872. wasDirty = series.isDirty || series.isDirtyData,
  34873. group = series.group,
  34874. xAxis = series.xAxis,
  34875. yAxis = series.yAxis;
  34876. // reposition on resize
  34877. if (group) {
  34878. if (chart.inverted) {
  34879. group.attr({
  34880. width: chart.plotWidth,
  34881. height: chart.plotHeight
  34882. });
  34883. }
  34884. group.animate({
  34885. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  34886. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  34887. });
  34888. }
  34889. series.translate();
  34890. series.render();
  34891. if (wasDirty) { // #3868, #3945
  34892. delete this.kdTree;
  34893. }
  34894. };
  34895. /**
  34896. * @private
  34897. * @function Highcharts.Series#searchPoint
  34898. */
  34899. Series.prototype.searchPoint = function (e, compareX) {
  34900. var series = this,
  34901. xAxis = series.xAxis,
  34902. yAxis = series.yAxis,
  34903. inverted = series.chart.inverted;
  34904. return this.searchKDTree({
  34905. clientX: inverted ?
  34906. xAxis.len - e.chartY + xAxis.pos :
  34907. e.chartX - xAxis.pos,
  34908. plotY: inverted ?
  34909. yAxis.len - e.chartX + yAxis.pos :
  34910. e.chartY - yAxis.pos
  34911. }, compareX, e);
  34912. };
  34913. /**
  34914. * Build the k-d-tree that is used by mouse and touch interaction to get
  34915. * the closest point. Line-like series typically have a one-dimensional
  34916. * tree where points are searched along the X axis, while scatter-like
  34917. * series typically search in two dimensions, X and Y.
  34918. *
  34919. * @private
  34920. * @function Highcharts.Series#buildKDTree
  34921. */
  34922. Series.prototype.buildKDTree = function (e) {
  34923. // Prevent multiple k-d-trees from being built simultaneously
  34924. // (#6235)
  34925. this.buildingKdTree = true;
  34926. var series = this,
  34927. dimensions = series.options.findNearestPointBy
  34928. .indexOf('y') > -1 ? 2 : 1;
  34929. /**
  34930. * Internal function
  34931. * @private
  34932. */
  34933. function _kdtree(points, depth, dimensions) {
  34934. var axis,
  34935. median,
  34936. length = points && points.length;
  34937. if (length) {
  34938. // alternate between the axis
  34939. axis = series.kdAxisArray[depth % dimensions];
  34940. // sort point array
  34941. points.sort(function (a, b) {
  34942. return a[axis] - b[axis];
  34943. });
  34944. median = Math.floor(length / 2);
  34945. // build and return nod
  34946. return {
  34947. point: points[median],
  34948. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  34949. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  34950. };
  34951. }
  34952. }
  34953. /**
  34954. * Start the recursive build process with a clone of the points
  34955. * array and null points filtered out. (#3873)
  34956. * @private
  34957. */
  34958. function startRecursive() {
  34959. series.kdTree = _kdtree(series.getValidPoints(null,
  34960. // For line-type series restrict to plot area, but
  34961. // column-type series not (#3916, #4511)
  34962. !series.directTouch), dimensions, dimensions);
  34963. series.buildingKdTree = false;
  34964. }
  34965. delete series.kdTree;
  34966. // For testing tooltips, don't build async. Also if touchstart, we
  34967. // may be dealing with click events on mobile, so don't delay
  34968. // (#6817).
  34969. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  34970. };
  34971. /**
  34972. * @private
  34973. * @function Highcharts.Series#searchKDTree
  34974. */
  34975. Series.prototype.searchKDTree = function (point, compareX, e) {
  34976. var series = this,
  34977. kdX = this.kdAxisArray[0],
  34978. kdY = this.kdAxisArray[1],
  34979. kdComparer = compareX ? 'distX' : 'dist',
  34980. kdDimensions = series.options.findNearestPointBy
  34981. .indexOf('y') > -1 ? 2 : 1;
  34982. /**
  34983. * Set the one and two dimensional distance on the point object.
  34984. * @private
  34985. */
  34986. function setDistance(p1, p2) {
  34987. var x = (defined(p1[kdX]) &&
  34988. defined(p2[kdX])) ?
  34989. Math.pow(p1[kdX] - p2[kdX], 2) :
  34990. null,
  34991. y = (defined(p1[kdY]) &&
  34992. defined(p2[kdY])) ?
  34993. Math.pow(p1[kdY] - p2[kdY], 2) :
  34994. null,
  34995. r = (x || 0) + (y || 0);
  34996. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  34997. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  34998. }
  34999. /**
  35000. * @private
  35001. */
  35002. function _search(search, tree, depth, dimensions) {
  35003. var point = tree.point,
  35004. axis = series.kdAxisArray[depth % dimensions],
  35005. tdist,
  35006. sideA,
  35007. sideB,
  35008. ret = point,
  35009. nPoint1,
  35010. nPoint2;
  35011. setDistance(search, point);
  35012. // Pick side based on distance to splitting point
  35013. tdist = search[axis] - point[axis];
  35014. sideA = tdist < 0 ? 'left' : 'right';
  35015. sideB = tdist < 0 ? 'right' : 'left';
  35016. // End of tree
  35017. if (tree[sideA]) {
  35018. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35019. ret = (nPoint1[kdComparer] <
  35020. ret[kdComparer] ?
  35021. nPoint1 :
  35022. point);
  35023. }
  35024. if (tree[sideB]) {
  35025. // compare distance to current best to splitting point to
  35026. // decide wether to check side B or not
  35027. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35028. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35029. ret = (nPoint2[kdComparer] <
  35030. ret[kdComparer] ?
  35031. nPoint2 :
  35032. ret);
  35033. }
  35034. }
  35035. return ret;
  35036. }
  35037. if (!this.kdTree && !this.buildingKdTree) {
  35038. this.buildKDTree(e);
  35039. }
  35040. if (this.kdTree) {
  35041. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35042. }
  35043. };
  35044. /**
  35045. * @private
  35046. * @function Highcharts.Series#pointPlacementToXValue
  35047. */
  35048. Series.prototype.pointPlacementToXValue = function () {
  35049. var _a = this,
  35050. _b = _a.options,
  35051. pointPlacement = _b.pointPlacement,
  35052. pointRange = _b.pointRange,
  35053. axis = _a.xAxis;
  35054. var factor = pointPlacement;
  35055. // Point placement is relative to each series pointRange (#5889)
  35056. if (factor === 'between') {
  35057. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35058. }
  35059. return isNumber(factor) ?
  35060. factor * (pointRange || axis.pointRange) :
  35061. 0;
  35062. };
  35063. /**
  35064. * @private
  35065. * @function Highcharts.Series#isPointInside
  35066. */
  35067. Series.prototype.isPointInside = function (point) {
  35068. var isInside = typeof point.plotY !== 'undefined' &&
  35069. typeof point.plotX !== 'undefined' &&
  35070. point.plotY >= 0 &&
  35071. point.plotY <= this.yAxis.len && // #3519
  35072. point.plotX >= 0 &&
  35073. point.plotX <= this.xAxis.len;
  35074. return isInside;
  35075. };
  35076. /**
  35077. * Draw the tracker object that sits above all data labels and markers to
  35078. * track mouse events on the graph or points. For the line type charts
  35079. * the tracker uses the same graphPath, but with a greater stroke width
  35080. * for better control.
  35081. * @private
  35082. */
  35083. Series.prototype.drawTracker = function () {
  35084. var series = this,
  35085. options = series.options,
  35086. trackByArea = options.trackByArea,
  35087. trackerPath = [].concat(trackByArea ?
  35088. series.areaPath :
  35089. series.graphPath),
  35090. // trackerPathLength = trackerPath.length,
  35091. chart = series.chart,
  35092. pointer = chart.pointer,
  35093. renderer = chart.renderer,
  35094. snap = chart.options.tooltip.snap,
  35095. tracker = series.tracker,
  35096. i,
  35097. onMouseOver = function (e) {
  35098. if (chart.hoverSeries !== series) {
  35099. series.onMouseOver();
  35100. }
  35101. },
  35102. /*
  35103. * Empirical lowest possible opacities for TRACKER_FILL for an
  35104. * element to stay invisible but clickable
  35105. * IE6: 0.002
  35106. * IE7: 0.002
  35107. * IE8: 0.002
  35108. * IE9: 0.00000000001 (unlimited)
  35109. * IE10: 0.0001 (exporting only)
  35110. * FF: 0.00000000001 (unlimited)
  35111. * Chrome: 0.000001
  35112. * Safari: 0.000001
  35113. * Opera: 0.00000000001 (unlimited)
  35114. */
  35115. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  35116. // Draw the tracker
  35117. if (tracker) {
  35118. tracker.attr({ d: trackerPath });
  35119. }
  35120. else if (series.graph) { // create
  35121. series.tracker = renderer.path(trackerPath)
  35122. .attr({
  35123. visibility: series.visible ? 'visible' : 'hidden',
  35124. zIndex: 2
  35125. })
  35126. .addClass(trackByArea ?
  35127. 'highcharts-tracker-area' :
  35128. 'highcharts-tracker-line')
  35129. .add(series.group);
  35130. if (!chart.styledMode) {
  35131. series.tracker.attr({
  35132. 'stroke-linecap': 'round',
  35133. 'stroke-linejoin': 'round',
  35134. stroke: TRACKER_FILL,
  35135. fill: trackByArea ? TRACKER_FILL : 'none',
  35136. 'stroke-width': series.graph.strokeWidth() +
  35137. (trackByArea ? 0 : 2 * snap)
  35138. });
  35139. }
  35140. // The tracker is added to the series group, which is clipped, but
  35141. // is covered by the marker group. So the marker group also needs to
  35142. // capture events.
  35143. [
  35144. series.tracker,
  35145. series.markerGroup,
  35146. series.dataLabelsGroup
  35147. ].forEach(function (tracker) {
  35148. if (tracker) {
  35149. tracker.addClass('highcharts-tracker')
  35150. .on('mouseover', onMouseOver)
  35151. .on('mouseout', function (e) {
  35152. pointer.onTrackerMouseOut(e);
  35153. });
  35154. if (options.cursor && !chart.styledMode) {
  35155. tracker.css({ cursor: options.cursor });
  35156. }
  35157. if (hasTouch) {
  35158. tracker.on('touchstart', onMouseOver);
  35159. }
  35160. }
  35161. });
  35162. }
  35163. fireEvent(this, 'afterDrawTracker');
  35164. };
  35165. /**
  35166. * Add a point to the series after render time. The point can be added at
  35167. * the end, or by giving it an X value, to the start or in the middle of the
  35168. * series.
  35169. *
  35170. * @sample highcharts/members/series-addpoint-append/
  35171. * Append point
  35172. * @sample highcharts/members/series-addpoint-append-and-shift/
  35173. * Append and shift
  35174. * @sample highcharts/members/series-addpoint-x-and-y/
  35175. * Both X and Y values given
  35176. * @sample highcharts/members/series-addpoint-pie/
  35177. * Append pie slice
  35178. * @sample stock/members/series-addpoint/
  35179. * Append 100 points in Highcharts Stock
  35180. * @sample stock/members/series-addpoint-shift/
  35181. * Append and shift in Highcharts Stock
  35182. * @sample maps/members/series-addpoint/
  35183. * Add a point in Highmaps
  35184. *
  35185. * @function Highcharts.Series#addPoint
  35186. *
  35187. * @param {Highcharts.PointOptionsType} options
  35188. * The point options. If options is a single number, a point with
  35189. * that y value is appended to the series. If it is an array, it will
  35190. * be interpreted as x and y values respectively. If it is an
  35191. * object, advanced options as outlined under `series.data` are
  35192. * applied.
  35193. *
  35194. * @param {boolean} [redraw=true]
  35195. * Whether to redraw the chart after the point is added. When adding
  35196. * more than one point, it is highly recommended that the redraw
  35197. * option be set to false, and instead {@link Chart#redraw} is
  35198. * explicitly called after the adding of points is finished.
  35199. * Otherwise, the chart will redraw after adding each point.
  35200. *
  35201. * @param {boolean} [shift=false]
  35202. * If true, a point is shifted off the start of the series as one is
  35203. * appended to the end.
  35204. *
  35205. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35206. * Whether to apply animation, and optionally animation
  35207. * configuration.
  35208. *
  35209. * @param {boolean} [withEvent=true]
  35210. * Used internally, whether to fire the series `addPoint` event.
  35211. *
  35212. * @fires Highcharts.Series#event:addPoint
  35213. */
  35214. Series.prototype.addPoint = function (options, redraw, shift, animation, withEvent) {
  35215. var series = this,
  35216. seriesOptions = series.options,
  35217. data = series.data,
  35218. chart = series.chart,
  35219. xAxis = series.xAxis,
  35220. names = xAxis && xAxis.hasNames && xAxis.names,
  35221. dataOptions = seriesOptions.data,
  35222. point,
  35223. xData = series.xData,
  35224. isInTheMiddle,
  35225. i,
  35226. x;
  35227. // Optional redraw, defaults to true
  35228. redraw = pick(redraw, true);
  35229. // Get options and push the point to xData, yData and series.options. In
  35230. // series.generatePoints the Point instance will be created on demand
  35231. // and pushed to the series.data array.
  35232. point = { series: series };
  35233. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35234. x = point.x;
  35235. // Get the insertion point
  35236. i = xData.length;
  35237. if (series.requireSorting && x < xData[i - 1]) {
  35238. isInTheMiddle = true;
  35239. while (i && xData[i - 1] > x) {
  35240. i--;
  35241. }
  35242. }
  35243. // Insert undefined item
  35244. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35245. // Update it
  35246. series.updateParallelArrays(point, i);
  35247. if (names && point.name) {
  35248. names[x] = point.name;
  35249. }
  35250. dataOptions.splice(i, 0, options);
  35251. if (isInTheMiddle) {
  35252. series.data.splice(i, 0, null);
  35253. series.processData();
  35254. }
  35255. // Generate points to be added to the legend (#1329)
  35256. if (seriesOptions.legendType === 'point') {
  35257. series.generatePoints();
  35258. }
  35259. // Shift the first point off the parallel arrays
  35260. if (shift) {
  35261. if (data[0] && data[0].remove) {
  35262. data[0].remove(false);
  35263. }
  35264. else {
  35265. data.shift();
  35266. series.updateParallelArrays(point, 'shift');
  35267. dataOptions.shift();
  35268. }
  35269. }
  35270. // Fire event
  35271. if (withEvent !== false) {
  35272. fireEvent(series, 'addPoint', { point: point });
  35273. }
  35274. // redraw
  35275. series.isDirty = true;
  35276. series.isDirtyData = true;
  35277. if (redraw) {
  35278. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35279. }
  35280. };
  35281. /**
  35282. * Remove a point from the series. Unlike the
  35283. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35284. * that is not instanciated because it is outside the view or subject to
  35285. * Highcharts Stock data grouping.
  35286. *
  35287. * @sample highcharts/members/series-removepoint/
  35288. * Remove cropped point
  35289. *
  35290. * @function Highcharts.Series#removePoint
  35291. *
  35292. * @param {number} i
  35293. * The index of the point in the {@link Highcharts.Series.data|data}
  35294. * array.
  35295. *
  35296. * @param {boolean} [redraw=true]
  35297. * Whether to redraw the chart after the point is added. When
  35298. * removing more than one point, it is highly recommended that the
  35299. * `redraw` option be set to `false`, and instead {@link
  35300. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35301. * points is finished.
  35302. *
  35303. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35304. * Whether and optionally how the series should be animated.
  35305. *
  35306. * @fires Highcharts.Point#event:remove
  35307. */
  35308. Series.prototype.removePoint = function (i, redraw, animation) {
  35309. var series = this,
  35310. data = series.data,
  35311. point = data[i],
  35312. points = series.points,
  35313. chart = series.chart,
  35314. remove = function () {
  35315. if (points && points.length === data.length) { // #4935
  35316. points.splice(i, 1);
  35317. }
  35318. data.splice(i, 1);
  35319. series.options.data.splice(i, 1);
  35320. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35321. if (point) {
  35322. point.destroy();
  35323. }
  35324. // redraw
  35325. series.isDirty = true;
  35326. series.isDirtyData = true;
  35327. if (redraw) {
  35328. chart.redraw();
  35329. }
  35330. };
  35331. setAnimation(animation, chart);
  35332. redraw = pick(redraw, true);
  35333. // Fire the event with a default handler of removing the point
  35334. if (point) {
  35335. point.firePointEvent('remove', null, remove);
  35336. }
  35337. else {
  35338. remove();
  35339. }
  35340. };
  35341. /**
  35342. * Remove a series and optionally redraw the chart.
  35343. *
  35344. * @sample highcharts/members/series-remove/
  35345. * Remove first series from a button
  35346. *
  35347. * @function Highcharts.Series#remove
  35348. *
  35349. * @param {boolean} [redraw=true]
  35350. * Whether to redraw the chart or wait for an explicit call to
  35351. * {@link Highcharts.Chart#redraw}.
  35352. *
  35353. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35354. * Whether to apply animation, and optionally animation
  35355. * configuration.
  35356. *
  35357. * @param {boolean} [withEvent=true]
  35358. * Used internally, whether to fire the series `remove` event.
  35359. *
  35360. * @fires Highcharts.Series#event:remove
  35361. */
  35362. Series.prototype.remove = function (redraw, animation, withEvent, keepEvents) {
  35363. var series = this,
  35364. chart = series.chart;
  35365. /**
  35366. * @private
  35367. */
  35368. function remove() {
  35369. // Destroy elements
  35370. series.destroy(keepEvents);
  35371. // Redraw
  35372. chart.isDirtyLegend = chart.isDirtyBox = true;
  35373. chart.linkSeries();
  35374. if (pick(redraw, true)) {
  35375. chart.redraw(animation);
  35376. }
  35377. }
  35378. // Fire the event with a default handler of removing the point
  35379. if (withEvent !== false) {
  35380. fireEvent(series, 'remove', null, remove);
  35381. }
  35382. else {
  35383. remove();
  35384. }
  35385. };
  35386. /**
  35387. * Update the series with a new set of options. For a clean and precise
  35388. * handling of new options, all methods and elements from the series are
  35389. * removed, and it is initialized from scratch. Therefore, this method is
  35390. * more performance expensive than some other utility methods like {@link
  35391. * Series#setData} or {@link Series#setVisible}.
  35392. *
  35393. * Note that `Series.update` may mutate the passed `data` options.
  35394. *
  35395. * @sample highcharts/members/series-update/
  35396. * Updating series options
  35397. * @sample maps/members/series-update/
  35398. * Update series options in Highmaps
  35399. *
  35400. * @function Highcharts.Series#update
  35401. *
  35402. * @param {Highcharts.SeriesOptionsType} options
  35403. * New options that will be merged with the series' existing options.
  35404. *
  35405. * @param {boolean} [redraw=true]
  35406. * Whether to redraw the chart after the series is altered. If doing
  35407. * more operations on the chart, it is a good idea to set redraw to
  35408. * false and call {@link Chart#redraw} after.
  35409. *
  35410. * @fires Highcharts.Series#event:update
  35411. * @fires Highcharts.Series#event:afterUpdate
  35412. */
  35413. Series.prototype.update = function (options, redraw) {
  35414. options = cleanRecursively(options, this.userOptions);
  35415. fireEvent(this, 'update', { options: options });
  35416. var series = this,
  35417. chart = series.chart,
  35418. // must use user options when changing type because series.options
  35419. // is merged in with type specific plotOptions
  35420. oldOptions = series.userOptions,
  35421. seriesOptions,
  35422. initialType = series.initialType || series.type,
  35423. plotOptions = chart.options.plotOptions,
  35424. newType = (options.type ||
  35425. oldOptions.type ||
  35426. chart.options.chart.type),
  35427. keepPoints = !(
  35428. // Indicators, histograms etc recalculate the data. It should be
  35429. // possible to omit this.
  35430. this.hasDerivedData ||
  35431. // New type requires new point classes
  35432. (newType && newType !== this.type) ||
  35433. // New options affecting how the data points are built
  35434. typeof options.pointStart !== 'undefined' ||
  35435. typeof options.pointInterval !== 'undefined' ||
  35436. // Changes to data grouping requires new points in new group
  35437. series.hasOptionChanged('dataGrouping') ||
  35438. series.hasOptionChanged('pointStart') ||
  35439. series.hasOptionChanged('pointInterval') ||
  35440. series.hasOptionChanged('pointIntervalUnit') ||
  35441. series.hasOptionChanged('keys')),
  35442. initialSeriesProto = seriesTypes[initialType].prototype,
  35443. n,
  35444. groups = [
  35445. 'group',
  35446. 'markerGroup',
  35447. 'dataLabelsGroup',
  35448. 'transformGroup'
  35449. ],
  35450. preserve = [
  35451. 'eventOptions',
  35452. 'navigatorSeries',
  35453. 'baseSeries'
  35454. ],
  35455. // Animation must be enabled when calling update before the initial
  35456. // animation has first run. This happens when calling update
  35457. // directly after chart initialization, or when applying responsive
  35458. // rules (#6912).
  35459. animation = series.finishedAnimating && { animation: false },
  35460. kinds = {};
  35461. newType = newType || initialType;
  35462. if (keepPoints) {
  35463. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels', 'clips', // #15420
  35464. // Networkgraph (#14397)
  35465. 'nodes', 'layout',
  35466. // Map specific, consider moving it to series-specific preserve-
  35467. // properties (#10617)
  35468. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35469. if (options.visible !== false) {
  35470. preserve.push('area', 'graph');
  35471. }
  35472. series.parallelArrays.forEach(function (key) {
  35473. preserve.push(key + 'Data');
  35474. });
  35475. if (options.data) {
  35476. // setData uses dataSorting options so we need to update them
  35477. // earlier
  35478. if (options.dataSorting) {
  35479. extend(series.options.dataSorting, options.dataSorting);
  35480. }
  35481. this.setData(options.data, false);
  35482. }
  35483. }
  35484. // Do the merge, with some forced options
  35485. options = merge(oldOptions, animation, {
  35486. // When oldOptions.index is null it should't be cleared.
  35487. // Otherwise navigator series will have wrong indexes (#10193).
  35488. index: typeof oldOptions.index === 'undefined' ?
  35489. series.index : oldOptions.index,
  35490. pointStart: pick(
  35491. // when updating from blank (#7933)
  35492. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  35493. // when updating after addPoint
  35494. series.xData[0])
  35495. }, (!keepPoints && { data: series.options.data }), options);
  35496. // Merge does not merge arrays, but replaces them. Since points were
  35497. // updated, `series.options.data` has correct merged options, use it:
  35498. if (keepPoints && options.data) {
  35499. options.data = series.options.data;
  35500. }
  35501. // Make sure preserved properties are not destroyed (#3094)
  35502. preserve = groups.concat(preserve);
  35503. preserve.forEach(function (prop) {
  35504. preserve[prop] = series[prop];
  35505. delete series[prop];
  35506. });
  35507. var casting = false;
  35508. if (seriesTypes[newType]) {
  35509. casting = newType !== series.type;
  35510. // Destroy the series and delete all properties, it will be
  35511. // reinserted within the `init` call below
  35512. series.remove(false, false, false, true);
  35513. if (casting) {
  35514. // Modern browsers including IE11
  35515. // @todo slow, consider alternatives mentioned:
  35516. // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
  35517. if (Object.setPrototypeOf) {
  35518. Object.setPrototypeOf(series, seriesTypes[newType].prototype);
  35519. // Legacy (IE < 11)
  35520. }
  35521. else {
  35522. var ownEvents = Object.hasOwnProperty.call(series, 'hcEvents') &&
  35523. series.hcEvents;
  35524. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35525. series[n] = void 0;
  35526. }
  35527. // Reinsert all methods and properties from the new type
  35528. // prototype (#2270, #3719).
  35529. extend(series, seriesTypes[newType].prototype);
  35530. // The events are tied to the prototype chain, don't copy if
  35531. // they're not the series' own
  35532. if (ownEvents) {
  35533. series.hcEvents = ownEvents;
  35534. }
  35535. else {
  35536. delete series.hcEvents;
  35537. }
  35538. }
  35539. }
  35540. }
  35541. else {
  35542. error(17, true, chart, { missingModuleFor: newType });
  35543. }
  35544. // Re-register groups (#3094) and other preserved properties
  35545. preserve.forEach(function (prop) {
  35546. series[prop] = preserve[prop];
  35547. });
  35548. series.init(chart, options);
  35549. // Remove particular elements of the points. Check `series.options`
  35550. // because we need to consider the options being set on plotOptions as
  35551. // well.
  35552. if (keepPoints && this.points) {
  35553. seriesOptions = series.options;
  35554. // What kind of elements to destroy
  35555. if (seriesOptions.visible === false) {
  35556. kinds.graphic = 1;
  35557. kinds.dataLabel = 1;
  35558. }
  35559. else if (!series._hasPointLabels) {
  35560. var marker = seriesOptions.marker,
  35561. dataLabels = seriesOptions.dataLabels;
  35562. if (marker && (marker.enabled === false ||
  35563. 'symbol' in marker // #10870
  35564. )) {
  35565. kinds.graphic = 1;
  35566. }
  35567. if (dataLabels &&
  35568. dataLabels.enabled === false) {
  35569. kinds.dataLabel = 1;
  35570. }
  35571. }
  35572. this.points.forEach(function (point) {
  35573. if (point && point.series) {
  35574. point.resolveColor();
  35575. // Destroy elements in order to recreate based on updated
  35576. // series options.
  35577. if (Object.keys(kinds).length) {
  35578. point.destroyElements(kinds);
  35579. }
  35580. if (seriesOptions.showInLegend === false &&
  35581. point.legendItem) {
  35582. chart.legend.destroyItem(point);
  35583. }
  35584. }
  35585. }, this);
  35586. }
  35587. series.initialType = initialType;
  35588. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35589. // #15383: Fire updatedData if the type has changed to keep linked
  35590. // series such as indicators updated
  35591. if (casting && series.linkedSeries.length) {
  35592. series.isDirtyData = true;
  35593. }
  35594. fireEvent(this, 'afterUpdate');
  35595. if (pick(redraw, true)) {
  35596. chart.redraw(keepPoints ? void 0 : false);
  35597. }
  35598. };
  35599. /**
  35600. * Used from within series.update
  35601. * @private
  35602. */
  35603. Series.prototype.setName = function (name) {
  35604. this.name = this.options.name = this.userOptions.name = name;
  35605. this.chart.isDirtyLegend = true;
  35606. };
  35607. /**
  35608. * Check if the option has changed.
  35609. * @private
  35610. */
  35611. Series.prototype.hasOptionChanged = function (optionName) {
  35612. var chart = this.chart,
  35613. option = this.options[optionName],
  35614. plotOptions = chart.options.plotOptions,
  35615. oldOption = this.userOptions[optionName];
  35616. if (oldOption) {
  35617. return option !== oldOption;
  35618. }
  35619. return option !==
  35620. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  35621. };
  35622. /**
  35623. * Runs on mouse over the series graphical items.
  35624. *
  35625. * @function Highcharts.Series#onMouseOver
  35626. * @fires Highcharts.Series#event:mouseOver
  35627. */
  35628. Series.prototype.onMouseOver = function () {
  35629. var series = this,
  35630. chart = series.chart,
  35631. hoverSeries = chart.hoverSeries,
  35632. pointer = chart.pointer;
  35633. pointer.setHoverChartIndex();
  35634. // set normal state to previous series
  35635. if (hoverSeries && hoverSeries !== series) {
  35636. hoverSeries.onMouseOut();
  35637. }
  35638. // trigger the event, but to save processing time,
  35639. // only if defined
  35640. if (series.options.events.mouseOver) {
  35641. fireEvent(series, 'mouseOver');
  35642. }
  35643. // hover this
  35644. series.setState('hover');
  35645. /**
  35646. * Contains the original hovered series.
  35647. *
  35648. * @name Highcharts.Chart#hoverSeries
  35649. * @type {Highcharts.Series|null}
  35650. */
  35651. chart.hoverSeries = series;
  35652. };
  35653. /**
  35654. * Runs on mouse out of the series graphical items.
  35655. *
  35656. * @function Highcharts.Series#onMouseOut
  35657. *
  35658. * @fires Highcharts.Series#event:mouseOut
  35659. */
  35660. Series.prototype.onMouseOut = function () {
  35661. // trigger the event only if listeners exist
  35662. var series = this,
  35663. options = series.options,
  35664. chart = series.chart,
  35665. tooltip = chart.tooltip,
  35666. hoverPoint = chart.hoverPoint;
  35667. // #182, set to null before the mouseOut event fires
  35668. chart.hoverSeries = null;
  35669. // trigger mouse out on the point, which must be in this series
  35670. if (hoverPoint) {
  35671. hoverPoint.onMouseOut();
  35672. }
  35673. // fire the mouse out event
  35674. if (series && options.events.mouseOut) {
  35675. fireEvent(series, 'mouseOut');
  35676. }
  35677. // hide the tooltip
  35678. if (tooltip &&
  35679. !series.stickyTracking &&
  35680. (!tooltip.shared || series.noSharedTooltip)) {
  35681. tooltip.hide();
  35682. }
  35683. // Reset all inactive states
  35684. chart.series.forEach(function (s) {
  35685. s.setState('', true);
  35686. });
  35687. };
  35688. /**
  35689. * Set the state of the series. Called internally on mouse interaction
  35690. * operations, but it can also be called directly to visually
  35691. * highlight a series.
  35692. *
  35693. * @function Highcharts.Series#setState
  35694. *
  35695. * @param {Highcharts.SeriesStateValue|""} [state]
  35696. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  35697. * or `''` (an empty string), `'normal'` or `undefined` to set to
  35698. * normal state.
  35699. * @param {boolean} [inherit]
  35700. * Determines if state should be inherited by points too.
  35701. */
  35702. Series.prototype.setState = function (state, inherit) {
  35703. var series = this,
  35704. options = series.options,
  35705. graph = series.graph,
  35706. inactiveOtherPoints = options.inactiveOtherPoints,
  35707. stateOptions = options.states,
  35708. lineWidth = options.lineWidth,
  35709. opacity = options.opacity,
  35710. // By default a quick animation to hover/inactive,
  35711. // slower to un-hover
  35712. stateAnimation = pick((stateOptions[state || 'normal'] &&
  35713. stateOptions[state || 'normal'].animation),
  35714. series.chart.options.chart.animation),
  35715. attribs,
  35716. i = 0;
  35717. state = state || '';
  35718. if (series.state !== state) {
  35719. // Toggle class names
  35720. [
  35721. series.group,
  35722. series.markerGroup,
  35723. series.dataLabelsGroup
  35724. ].forEach(function (group) {
  35725. if (group) {
  35726. // Old state
  35727. if (series.state) {
  35728. group.removeClass('highcharts-series-' + series.state);
  35729. }
  35730. // New state
  35731. if (state) {
  35732. group.addClass('highcharts-series-' + state);
  35733. }
  35734. }
  35735. });
  35736. series.state = state;
  35737. if (!series.chart.styledMode) {
  35738. if (stateOptions[state] &&
  35739. stateOptions[state].enabled === false) {
  35740. return;
  35741. }
  35742. if (state) {
  35743. lineWidth = (stateOptions[state].lineWidth ||
  35744. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  35745. opacity = pick(stateOptions[state].opacity, opacity);
  35746. }
  35747. if (graph && !graph.dashstyle) {
  35748. attribs = {
  35749. 'stroke-width': lineWidth
  35750. };
  35751. // Animate the graph stroke-width.
  35752. graph.animate(attribs, stateAnimation);
  35753. while (series['zone-graph-' + i]) {
  35754. series['zone-graph-' + i].animate(attribs, stateAnimation);
  35755. i = i + 1;
  35756. }
  35757. }
  35758. // For some types (pie, networkgraph, sankey) opacity is
  35759. // resolved on a point level
  35760. if (!inactiveOtherPoints) {
  35761. [
  35762. series.group,
  35763. series.markerGroup,
  35764. series.dataLabelsGroup,
  35765. series.labelBySeries
  35766. ].forEach(function (group) {
  35767. if (group) {
  35768. group.animate({
  35769. opacity: opacity
  35770. }, stateAnimation);
  35771. }
  35772. });
  35773. }
  35774. }
  35775. }
  35776. // Don't loop over points on a series that doesn't apply inactive state
  35777. // to siblings markers (e.g. line, column)
  35778. if (inherit && inactiveOtherPoints && series.points) {
  35779. series.setAllPointsToState(state || void 0);
  35780. }
  35781. };
  35782. /**
  35783. * Set the state for all points in the series.
  35784. *
  35785. * @function Highcharts.Series#setAllPointsToState
  35786. *
  35787. * @private
  35788. *
  35789. * @param {string} [state]
  35790. * Can be either `hover` or undefined to set to normal state.
  35791. */
  35792. Series.prototype.setAllPointsToState = function (state) {
  35793. this.points.forEach(function (point) {
  35794. if (point.setState) {
  35795. point.setState(state);
  35796. }
  35797. });
  35798. };
  35799. /**
  35800. * Show or hide the series.
  35801. *
  35802. * @function Highcharts.Series#setVisible
  35803. *
  35804. * @param {boolean} [visible]
  35805. * True to show the series, false to hide. If undefined, the visibility is
  35806. * toggled.
  35807. *
  35808. * @param {boolean} [redraw=true]
  35809. * Whether to redraw the chart after the series is altered. If doing more
  35810. * operations on the chart, it is a good idea to set redraw to false and
  35811. * call {@link Chart#redraw|chart.redraw()} after.
  35812. *
  35813. * @fires Highcharts.Series#event:hide
  35814. * @fires Highcharts.Series#event:show
  35815. */
  35816. Series.prototype.setVisible = function (vis, redraw) {
  35817. var series = this,
  35818. chart = series.chart,
  35819. legendItem = series.legendItem,
  35820. showOrHide,
  35821. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  35822. oldVisibility = series.visible;
  35823. // if called without an argument, toggle visibility
  35824. series.visible =
  35825. vis =
  35826. series.options.visible =
  35827. series.userOptions.visible =
  35828. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  35829. showOrHide = vis ? 'show' : 'hide';
  35830. // show or hide elements
  35831. [
  35832. 'group',
  35833. 'dataLabelsGroup',
  35834. 'markerGroup',
  35835. 'tracker',
  35836. 'tt'
  35837. ].forEach(function (key) {
  35838. if (series[key]) {
  35839. series[key][showOrHide]();
  35840. }
  35841. });
  35842. // hide tooltip (#1361)
  35843. if (chart.hoverSeries === series ||
  35844. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  35845. series.onMouseOut();
  35846. }
  35847. if (legendItem) {
  35848. chart.legend.colorizeItem(series, vis);
  35849. }
  35850. // rescale or adapt to resized chart
  35851. series.isDirty = true;
  35852. // in a stack, all other series are affected
  35853. if (series.options.stacking) {
  35854. chart.series.forEach(function (otherSeries) {
  35855. if (otherSeries.options.stacking && otherSeries.visible) {
  35856. otherSeries.isDirty = true;
  35857. }
  35858. });
  35859. }
  35860. // show or hide linked series
  35861. series.linkedSeries.forEach(function (otherSeries) {
  35862. otherSeries.setVisible(vis, false);
  35863. });
  35864. if (ignoreHiddenSeries) {
  35865. chart.isDirtyBox = true;
  35866. }
  35867. fireEvent(series, showOrHide);
  35868. if (redraw !== false) {
  35869. chart.redraw();
  35870. }
  35871. };
  35872. /**
  35873. * Show the series if hidden.
  35874. *
  35875. * @sample highcharts/members/series-hide/
  35876. * Toggle visibility from a button
  35877. *
  35878. * @function Highcharts.Series#show
  35879. * @fires Highcharts.Series#event:show
  35880. */
  35881. Series.prototype.show = function () {
  35882. this.setVisible(true);
  35883. };
  35884. /**
  35885. * Hide the series if visible. If the
  35886. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  35887. * option is true, the chart is redrawn without this series.
  35888. *
  35889. * @sample highcharts/members/series-hide/
  35890. * Toggle visibility from a button
  35891. *
  35892. * @function Highcharts.Series#hide
  35893. * @fires Highcharts.Series#event:hide
  35894. */
  35895. Series.prototype.hide = function () {
  35896. this.setVisible(false);
  35897. };
  35898. /**
  35899. * Select or unselect the series. This means its
  35900. * {@link Highcharts.Series.selected|selected}
  35901. * property is set, the checkbox in the legend is toggled and when selected,
  35902. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  35903. * function.
  35904. *
  35905. * @sample highcharts/members/series-select/
  35906. * Select a series from a button
  35907. *
  35908. * @function Highcharts.Series#select
  35909. *
  35910. * @param {boolean} [selected]
  35911. * True to select the series, false to unselect. If undefined, the selection
  35912. * state is toggled.
  35913. *
  35914. * @fires Highcharts.Series#event:select
  35915. * @fires Highcharts.Series#event:unselect
  35916. */
  35917. Series.prototype.select = function (selected) {
  35918. var series = this;
  35919. series.selected =
  35920. selected =
  35921. this.options.selected = (typeof selected === 'undefined' ?
  35922. !series.selected :
  35923. selected);
  35924. if (series.checkbox) {
  35925. series.checkbox.checked = selected;
  35926. }
  35927. fireEvent(series, selected ? 'select' : 'unselect');
  35928. };
  35929. /**
  35930. * Checks if a tooltip should be shown for a given point.
  35931. *
  35932. * @private
  35933. * @param {number} plotX
  35934. * @param {number} plotY
  35935. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  35936. * @return {boolean}
  35937. */
  35938. Series.prototype.shouldShowTooltip = function (plotX, plotY, options) {
  35939. if (options === void 0) { options = {}; }
  35940. options.series = this;
  35941. options.visiblePlotOnly = true;
  35942. return this.chart.isInsidePlot(plotX, plotY, options);
  35943. };
  35944. /**
  35945. * General options for all series types.
  35946. *
  35947. * @optionparent plotOptions.series
  35948. */
  35949. Series.defaultOptions = {
  35950. // base series options
  35951. /**
  35952. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  35953. * of a line graph. Round means that lines are rounded in the ends and
  35954. * bends.
  35955. *
  35956. * @type {Highcharts.SeriesLinecapValue}
  35957. * @default round
  35958. * @since 3.0.7
  35959. * @apioption plotOptions.line.linecap
  35960. */
  35961. /**
  35962. * Pixel width of the graph line.
  35963. *
  35964. * @see In styled mode, the line stroke-width can be set with the
  35965. * `.highcharts-graph` class name.
  35966. *
  35967. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  35968. * On all series
  35969. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  35970. * On one single series
  35971. *
  35972. * @product highcharts highstock
  35973. *
  35974. * @private
  35975. */
  35976. lineWidth: 2,
  35977. /**
  35978. * For some series, there is a limit that shuts down initial animation
  35979. * by default when the total number of points in the chart is too high.
  35980. * For example, for a column chart and its derivatives, animation does
  35981. * not run if there is more than 250 points totally. To disable this
  35982. * cap, set `animationLimit` to `Infinity`.
  35983. *
  35984. * @type {number}
  35985. * @apioption plotOptions.series.animationLimit
  35986. */
  35987. /**
  35988. * Allow this series' points to be selected by clicking on the graphic
  35989. * (columns, point markers, pie slices, map areas etc).
  35990. *
  35991. * The selected points can be handled by point select and unselect
  35992. * events, or collectively by the [getSelectedPoints
  35993. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  35994. *
  35995. * And alternative way of selecting points is through dragging.
  35996. *
  35997. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  35998. * Line
  35999. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  36000. * Column
  36001. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  36002. * Pie
  36003. * @sample {highcharts} highcharts/chart/events-selection-points/
  36004. * Select a range of points through a drag selection
  36005. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36006. * Map area
  36007. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36008. * Map bubble
  36009. *
  36010. * @since 1.2.0
  36011. *
  36012. * @private
  36013. */
  36014. allowPointSelect: false,
  36015. /**
  36016. * When true, each point or column edge is rounded to its nearest pixel
  36017. * in order to render sharp on screen. In some cases, when there are a
  36018. * lot of densely packed columns, this leads to visible difference
  36019. * in column widths or distance between columns. In these cases,
  36020. * setting `crisp` to `false` may look better, even though each column
  36021. * is rendered blurry.
  36022. *
  36023. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  36024. * Crisp is false
  36025. *
  36026. * @since 5.0.10
  36027. * @product highcharts highstock gantt
  36028. *
  36029. * @private
  36030. */
  36031. crisp: true,
  36032. /**
  36033. * If true, a checkbox is displayed next to the legend item to allow
  36034. * selecting the series. The state of the checkbox is determined by
  36035. * the `selected` option.
  36036. *
  36037. * @productdesc {highmaps}
  36038. * Note that if a `colorAxis` is defined, the color axis is represented
  36039. * in the legend, not the series.
  36040. *
  36041. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  36042. * Show select box
  36043. *
  36044. * @since 1.2.0
  36045. *
  36046. * @private
  36047. */
  36048. showCheckbox: false,
  36049. /**
  36050. * Enable or disable the initial animation when a series is displayed.
  36051. * The animation can also be set as a configuration object. Please
  36052. * note that this option only applies to the initial animation of the
  36053. * series itself. For other animations, see [chart.animation](
  36054. * #chart.animation) and the animation parameter under the API methods.
  36055. * The following properties are supported:
  36056. *
  36057. * - `defer`: The animation delay time in milliseconds.
  36058. *
  36059. * - `duration`: The duration of the animation in milliseconds.
  36060. *
  36061. * - `easing`: Can be a string reference to an easing function set on
  36062. * the `Math` object or a function. See the _Custom easing function_
  36063. * demo below.
  36064. *
  36065. * Due to poor performance, animation is disabled in old IE browsers
  36066. * for several chart types.
  36067. *
  36068. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  36069. * Animation disabled
  36070. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  36071. * Slower animation
  36072. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  36073. * Custom easing function
  36074. * @sample {highstock} stock/plotoptions/animation-slower/
  36075. * Slower animation
  36076. * @sample {highstock} stock/plotoptions/animation-easing/
  36077. * Custom easing function
  36078. * @sample {highmaps} maps/plotoptions/series-animation-true/
  36079. * Animation enabled on map series
  36080. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  36081. * Disabled on mapbubble series
  36082. *
  36083. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36084. * @default {highcharts} true
  36085. * @default {highstock} true
  36086. * @default {highmaps} false
  36087. *
  36088. * @private
  36089. */
  36090. animation: {
  36091. /** @internal */
  36092. duration: 1000
  36093. },
  36094. /**
  36095. * @default 0
  36096. * @type {number}
  36097. * @since 8.2.0
  36098. * @apioption plotOptions.series.animation.defer
  36099. */
  36100. /**
  36101. * An additional class name to apply to the series' graphical elements.
  36102. * This option does not replace default class names of the graphical
  36103. * element.
  36104. *
  36105. * @type {string}
  36106. * @since 5.0.0
  36107. * @apioption plotOptions.series.className
  36108. */
  36109. /**
  36110. * Disable this option to allow series rendering in the whole plotting
  36111. * area.
  36112. *
  36113. * **Note:** Clipping should be always enabled when
  36114. * [chart.zoomType](#chart.zoomType) is set
  36115. *
  36116. * @sample {highcharts} highcharts/plotoptions/series-clip/
  36117. * Disabled clipping
  36118. *
  36119. * @default true
  36120. * @type {boolean}
  36121. * @since 3.0.0
  36122. * @apioption plotOptions.series.clip
  36123. */
  36124. /**
  36125. * The main color of the series. In line type series it applies to the
  36126. * line and the point markers unless otherwise specified. In bar type
  36127. * series it applies to the bars unless a color is specified per point.
  36128. * The default value is pulled from the `options.colors` array.
  36129. *
  36130. * In styled mode, the color can be defined by the
  36131. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  36132. * color can be set with the `.highcharts-series`,
  36133. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  36134. * `.highcharts-series-{n}` class, or individual classes given by the
  36135. * `className` option.
  36136. *
  36137. * @productdesc {highmaps}
  36138. * In maps, the series color is rarely used, as most choropleth maps use
  36139. * the color to denote the value of each point. The series color can
  36140. * however be used in a map with multiple series holding categorized
  36141. * data.
  36142. *
  36143. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  36144. * General plot option
  36145. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  36146. * One specific series
  36147. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  36148. * Area color
  36149. * @sample {highcharts} highcharts/series/infographic/
  36150. * Pattern fill
  36151. * @sample {highmaps} maps/demo/category-map/
  36152. * Category map by multiple series
  36153. *
  36154. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36155. * @apioption plotOptions.series.color
  36156. */
  36157. /**
  36158. * Styled mode only. A specific color index to use for the series, so
  36159. * its graphic representations are given the class name
  36160. * `highcharts-color-{n}`.
  36161. *
  36162. * @type {number}
  36163. * @since 5.0.0
  36164. * @apioption plotOptions.series.colorIndex
  36165. */
  36166. /**
  36167. * Whether to connect a graph line across null points, or render a gap
  36168. * between the two points on either side of the null.
  36169. *
  36170. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  36171. * False by default
  36172. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  36173. * True
  36174. *
  36175. * @type {boolean}
  36176. * @default false
  36177. * @product highcharts highstock
  36178. * @apioption plotOptions.series.connectNulls
  36179. */
  36180. /**
  36181. * You can set the cursor to "pointer" if you have click events attached
  36182. * to the series, to signal to the user that the points and lines can
  36183. * be clicked.
  36184. *
  36185. * In styled mode, the series cursor can be set with the same classes
  36186. * as listed under [series.color](#plotOptions.series.color).
  36187. *
  36188. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  36189. * On line graph
  36190. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  36191. * On columns
  36192. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  36193. * On scatter markers
  36194. * @sample {highstock} stock/plotoptions/cursor/
  36195. * Pointer on a line graph
  36196. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36197. * Map area
  36198. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36199. * Map bubble
  36200. *
  36201. * @type {string|Highcharts.CursorValue}
  36202. * @apioption plotOptions.series.cursor
  36203. */
  36204. /**
  36205. * A reserved subspace to store options and values for customized
  36206. * functionality. Here you can add additional data for your own event
  36207. * callbacks and formatter callbacks.
  36208. *
  36209. * @sample {highcharts} highcharts/point/custom/
  36210. * Point and series with custom data
  36211. *
  36212. * @type {Highcharts.Dictionary<*>}
  36213. * @apioption plotOptions.series.custom
  36214. */
  36215. /**
  36216. * Name of the dash style to use for the graph, or for some series types
  36217. * the outline of each shape.
  36218. *
  36219. * In styled mode, the
  36220. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  36221. * can be set with the same classes as listed under
  36222. * [series.color](#plotOptions.series.color).
  36223. *
  36224. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  36225. * Possible values demonstrated
  36226. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  36227. * Chart suitable for printing in black and white
  36228. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  36229. * Possible values demonstrated
  36230. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  36231. * Possible values demonstrated
  36232. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  36233. * Dotted borders on a map
  36234. *
  36235. * @type {Highcharts.DashStyleValue}
  36236. * @default Solid
  36237. * @since 2.1
  36238. * @apioption plotOptions.series.dashStyle
  36239. */
  36240. /**
  36241. * A description of the series to add to the screen reader information
  36242. * about the series.
  36243. *
  36244. * @type {string}
  36245. * @since 5.0.0
  36246. * @requires modules/accessibility
  36247. * @apioption plotOptions.series.description
  36248. */
  36249. /**
  36250. * Options for the series data sorting.
  36251. *
  36252. * @type {Highcharts.DataSortingOptionsObject}
  36253. * @since 8.0.0
  36254. * @product highcharts highstock
  36255. * @apioption plotOptions.series.dataSorting
  36256. */
  36257. /**
  36258. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  36259. * #xAxis.reversed) to change the sorting order.
  36260. *
  36261. * @sample {highcharts} highcharts/datasorting/animation/
  36262. * Data sorting in scatter-3d
  36263. * @sample {highcharts} highcharts/datasorting/labels-animation/
  36264. * Axis labels animation
  36265. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  36266. * Dependent series sorting
  36267. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  36268. * Independent series sorting
  36269. *
  36270. * @type {boolean}
  36271. * @since 8.0.0
  36272. * @apioption plotOptions.series.dataSorting.enabled
  36273. */
  36274. /**
  36275. * Whether to allow matching points by name in an update. If this option
  36276. * is disabled, points will be matched by order.
  36277. *
  36278. * @sample {highcharts} highcharts/datasorting/match-by-name/
  36279. * Enabled match by name
  36280. *
  36281. * @type {boolean}
  36282. * @since 8.0.0
  36283. * @apioption plotOptions.series.dataSorting.matchByName
  36284. */
  36285. /**
  36286. * Determines what data value should be used to sort by.
  36287. *
  36288. * @sample {highcharts} highcharts/datasorting/sort-key/
  36289. * Sort key as `z` value
  36290. *
  36291. * @type {string}
  36292. * @since 8.0.0
  36293. * @default y
  36294. * @apioption plotOptions.series.dataSorting.sortKey
  36295. */
  36296. /**
  36297. * Enable or disable the mouse tracking for a specific series. This
  36298. * includes point tooltips and click events on graphs and points. For
  36299. * large datasets it improves performance.
  36300. *
  36301. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  36302. * No mouse tracking
  36303. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  36304. * No mouse tracking
  36305. *
  36306. * @type {boolean}
  36307. * @default true
  36308. * @apioption plotOptions.series.enableMouseTracking
  36309. */
  36310. /**
  36311. * Whether to use the Y extremes of the total chart width or only the
  36312. * zoomed area when zooming in on parts of the X axis. By default, the
  36313. * Y axis adjusts to the min and max of the visible data. Cartesian
  36314. * series only.
  36315. *
  36316. * @type {boolean}
  36317. * @default false
  36318. * @since 4.1.6
  36319. * @product highcharts highstock gantt
  36320. * @apioption plotOptions.series.getExtremesFromAll
  36321. */
  36322. /**
  36323. * An array specifying which option maps to which key in the data point
  36324. * array. This makes it convenient to work with unstructured data arrays
  36325. * from different sources.
  36326. *
  36327. * @see [series.data](#series.line.data)
  36328. *
  36329. * @sample {highcharts|highstock} highcharts/series/data-keys/
  36330. * An extended data array with keys
  36331. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  36332. * Nested keys used to access object properties
  36333. *
  36334. * @type {Array<string>}
  36335. * @since 4.1.6
  36336. * @apioption plotOptions.series.keys
  36337. */
  36338. /**
  36339. * The line cap used for line ends and line joins on the graph.
  36340. *
  36341. * @type {Highcharts.SeriesLinecapValue}
  36342. * @default round
  36343. * @product highcharts highstock
  36344. * @apioption plotOptions.series.linecap
  36345. */
  36346. /**
  36347. * The [id](#series.id) of another series to link to. Additionally,
  36348. * the value can be ":previous" to link to the previous series. When
  36349. * two series are linked, only the first one appears in the legend.
  36350. * Toggling the visibility of this also toggles the linked series.
  36351. *
  36352. * If master series uses data sorting and linked series does not have
  36353. * its own sorting definition, the linked series will be sorted in the
  36354. * same order as the master one.
  36355. *
  36356. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  36357. * Linked series
  36358. *
  36359. * @type {string}
  36360. * @since 3.0
  36361. * @product highcharts highstock gantt
  36362. * @apioption plotOptions.series.linkedTo
  36363. */
  36364. /**
  36365. * Options for the corresponding navigator series if `showInNavigator`
  36366. * is `true` for this series. Available options are the same as any
  36367. * series, documented at [plotOptions](#plotOptions.series) and
  36368. * [series](#series).
  36369. *
  36370. * These options are merged with options in [navigator.series](
  36371. * #navigator.series), and will take precedence if the same option is
  36372. * defined both places.
  36373. *
  36374. * @see [navigator.series](#navigator.series)
  36375. *
  36376. * @type {Highcharts.PlotSeriesOptions}
  36377. * @since 5.0.0
  36378. * @product highstock
  36379. * @apioption plotOptions.series.navigatorOptions
  36380. */
  36381. /**
  36382. * The color for the parts of the graph or points that are below the
  36383. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  36384. * precedence over the negative color. Using `negativeColor` is
  36385. * equivalent to applying a zone with value of 0.
  36386. *
  36387. * @see In styled mode, a negative color is applied by setting this option
  36388. * to `true` combined with the `.highcharts-negative` class name.
  36389. *
  36390. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  36391. * Spline, area and column
  36392. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  36393. * Arearange
  36394. * @sample {highcharts} highcharts/css/series-negative-color/
  36395. * Styled mode
  36396. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  36397. * Spline, area and column
  36398. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  36399. * Arearange
  36400. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  36401. * Spline, area and column
  36402. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  36403. * Arearange
  36404. *
  36405. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36406. * @since 3.0
  36407. * @apioption plotOptions.series.negativeColor
  36408. */
  36409. /**
  36410. * Same as
  36411. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  36412. * but for an individual series. Overrides the chart wide configuration.
  36413. *
  36414. * @type {Function}
  36415. * @since 5.0.12
  36416. * @apioption plotOptions.series.pointDescriptionFormatter
  36417. */
  36418. /**
  36419. * If no x values are given for the points in a series, `pointInterval`
  36420. * defines the interval of the x values. For example, if a series
  36421. * contains one value every decade starting from year 0, set
  36422. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  36423. * is set in milliseconds.
  36424. *
  36425. * It can be also be combined with `pointIntervalUnit` to draw irregular
  36426. * time intervals.
  36427. *
  36428. * Please note that this options applies to the _series data_, not the
  36429. * interval of the axis ticks, which is independent.
  36430. *
  36431. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36432. * Datetime X axis
  36433. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36434. * Using pointStart and pointInterval
  36435. *
  36436. * @type {number}
  36437. * @default 1
  36438. * @product highcharts highstock gantt
  36439. * @apioption plotOptions.series.pointInterval
  36440. */
  36441. /**
  36442. * On datetime series, this allows for setting the
  36443. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  36444. * units, `day`, `month` and `year`. A day is usually the same as 24
  36445. * hours, but `pointIntervalUnit` also takes the DST crossover into
  36446. * consideration when dealing with local time. Combine this option with
  36447. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  36448. *
  36449. * Please note that this options applies to the _series data_, not the
  36450. * interval of the axis ticks, which is independent.
  36451. *
  36452. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  36453. * One point a month
  36454. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  36455. * One point a month
  36456. *
  36457. * @type {string}
  36458. * @since 4.1.0
  36459. * @product highcharts highstock gantt
  36460. * @validvalue ["day", "month", "year"]
  36461. * @apioption plotOptions.series.pointIntervalUnit
  36462. */
  36463. /**
  36464. * Possible values: `"on"`, `"between"`, `number`.
  36465. *
  36466. * In a column chart, when pointPlacement is `"on"`, the point will not
  36467. * create any padding of the X axis. In a polar column chart this means
  36468. * that the first column points directly north. If the pointPlacement is
  36469. * `"between"`, the columns will be laid out between ticks. This is
  36470. * useful for example for visualising an amount between two points in
  36471. * time or in a certain sector of a polar chart.
  36472. *
  36473. * Since Highcharts 3.0.2, the point placement can also be numeric,
  36474. * where 0 is on the axis value, -0.5 is between this value and the
  36475. * previous, and 0.5 is between this value and the next. Unlike the
  36476. * textual options, numeric point placement options won't affect axis
  36477. * padding.
  36478. *
  36479. * Note that pointPlacement needs a [pointRange](
  36480. * #plotOptions.series.pointRange) to work. For column series this is
  36481. * computed, but for line-type series it needs to be set.
  36482. *
  36483. * For the `xrange` series type and gantt charts, if the Y axis is a
  36484. * category axis, the `pointPlacement` applies to the Y axis rather than
  36485. * the (typically datetime) X axis.
  36486. *
  36487. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  36488. * charts.
  36489. *
  36490. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  36491. *
  36492. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  36493. * Between in a column chart
  36494. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  36495. * Numeric placement for custom layout
  36496. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  36497. * Placement in heatmap
  36498. *
  36499. * @type {string|number}
  36500. * @since 2.3.0
  36501. * @product highcharts highstock gantt
  36502. * @apioption plotOptions.series.pointPlacement
  36503. */
  36504. /**
  36505. * If no x values are given for the points in a series, pointStart
  36506. * defines on what value to start. For example, if a series contains one
  36507. * yearly value starting from 1945, set pointStart to 1945.
  36508. *
  36509. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  36510. * Linear
  36511. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36512. * Datetime
  36513. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36514. * Using pointStart and pointInterval
  36515. *
  36516. * @type {number}
  36517. * @default 0
  36518. * @product highcharts highstock gantt
  36519. * @apioption plotOptions.series.pointStart
  36520. */
  36521. /**
  36522. * Whether to select the series initially. If `showCheckbox` is true,
  36523. * the checkbox next to the series name in the legend will be checked
  36524. * for a selected series.
  36525. *
  36526. * @sample {highcharts} highcharts/plotoptions/series-selected/
  36527. * One out of two series selected
  36528. *
  36529. * @type {boolean}
  36530. * @default false
  36531. * @since 1.2.0
  36532. * @apioption plotOptions.series.selected
  36533. */
  36534. /**
  36535. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  36536. * shadow can be an object configuration containing `color`, `offsetX`,
  36537. * `offsetY`, `opacity` and `width`.
  36538. *
  36539. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  36540. * Shadow enabled
  36541. *
  36542. * @type {boolean|Highcharts.ShadowOptionsObject}
  36543. * @default false
  36544. * @apioption plotOptions.series.shadow
  36545. */
  36546. /**
  36547. * Whether to display this particular series or series type in the
  36548. * legend. Standalone series are shown in legend by default, and linked
  36549. * series are not. Since v7.2.0 it is possible to show series that use
  36550. * colorAxis by setting this option to `true`.
  36551. *
  36552. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  36553. * One series in the legend, one hidden
  36554. *
  36555. * @type {boolean}
  36556. * @apioption plotOptions.series.showInLegend
  36557. */
  36558. /**
  36559. * Whether or not to show the series in the navigator. Takes precedence
  36560. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  36561. *
  36562. * @type {boolean}
  36563. * @since 5.0.0
  36564. * @product highstock
  36565. * @apioption plotOptions.series.showInNavigator
  36566. */
  36567. /**
  36568. * If set to `true`, the accessibility module will skip past the points
  36569. * in this series for keyboard navigation.
  36570. *
  36571. * @type {boolean}
  36572. * @since 5.0.12
  36573. * @apioption plotOptions.series.skipKeyboardNavigation
  36574. */
  36575. /**
  36576. * Whether to stack the values of each series on top of each other.
  36577. * Possible values are `undefined` to disable, `"normal"` to stack by
  36578. * value or `"percent"`.
  36579. *
  36580. * When stacking is enabled, data must be sorted
  36581. * in ascending X order.
  36582. *
  36583. * Some stacking options are related to specific series types. In the
  36584. * streamgraph series type, the stacking option is set to `"stream"`.
  36585. * The second one is `"overlap"`, which only applies to waterfall
  36586. * series.
  36587. *
  36588. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  36589. *
  36590. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  36591. * Line
  36592. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  36593. * Column
  36594. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  36595. * Bar
  36596. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  36597. * Area
  36598. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  36599. * Line
  36600. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  36601. * Column
  36602. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  36603. * Bar
  36604. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  36605. * Area
  36606. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  36607. * Waterfall with normal stacking
  36608. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  36609. * Waterfall with overlap stacking
  36610. * @sample {highstock} stock/plotoptions/stacking/
  36611. * Area
  36612. *
  36613. * @type {string}
  36614. * @product highcharts highstock
  36615. * @validvalue ["normal", "overlap", "percent", "stream"]
  36616. * @apioption plotOptions.series.stacking
  36617. */
  36618. /**
  36619. * Whether to apply steps to the line. Possible values are `left`,
  36620. * `center` and `right`.
  36621. *
  36622. * @sample {highcharts} highcharts/plotoptions/line-step/
  36623. * Different step line options
  36624. * @sample {highcharts} highcharts/plotoptions/area-step/
  36625. * Stepped, stacked area
  36626. * @sample {highstock} stock/plotoptions/line-step/
  36627. * Step line
  36628. *
  36629. * @type {string}
  36630. * @since 1.2.5
  36631. * @product highcharts highstock
  36632. * @validvalue ["left", "center", "right"]
  36633. * @apioption plotOptions.series.step
  36634. */
  36635. /**
  36636. * The threshold, also called zero level or base level. For line type
  36637. * series this is only used in conjunction with
  36638. * [negativeColor](#plotOptions.series.negativeColor).
  36639. *
  36640. * @see [softThreshold](#plotOptions.series.softThreshold).
  36641. *
  36642. * @type {number|null}
  36643. * @default 0
  36644. * @since 3.0
  36645. * @product highcharts highstock
  36646. * @apioption plotOptions.series.threshold
  36647. */
  36648. /**
  36649. * Set the initial visibility of the series.
  36650. *
  36651. * @sample {highcharts} highcharts/plotoptions/series-visible/
  36652. * Two series, one hidden and one visible
  36653. * @sample {highstock} stock/plotoptions/series-visibility/
  36654. * Hidden series
  36655. *
  36656. * @type {boolean}
  36657. * @default true
  36658. * @apioption plotOptions.series.visible
  36659. */
  36660. /**
  36661. * Defines the Axis on which the zones are applied.
  36662. *
  36663. * @see [zones](#plotOptions.series.zones)
  36664. *
  36665. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  36666. * Zones on the X-Axis
  36667. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  36668. * Zones on the X-Axis
  36669. *
  36670. * @type {string}
  36671. * @default y
  36672. * @since 4.1.0
  36673. * @product highcharts highstock
  36674. * @apioption plotOptions.series.zoneAxis
  36675. */
  36676. /**
  36677. * General event handlers for the series items. These event hooks can
  36678. * also be attached to the series at run time using the
  36679. * `Highcharts.addEvent` function.
  36680. *
  36681. * @declare Highcharts.SeriesEventsOptionsObject
  36682. *
  36683. * @private
  36684. */
  36685. events: {},
  36686. /**
  36687. * Fires after the series has finished its initial animation, or in case
  36688. * animation is disabled, immediately as the series is displayed.
  36689. *
  36690. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  36691. * Show label after animate
  36692. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  36693. * Show label after animate
  36694. *
  36695. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  36696. * @since 4.0
  36697. * @product highcharts highstock gantt
  36698. * @context Highcharts.Series
  36699. * @apioption plotOptions.series.events.afterAnimate
  36700. */
  36701. /**
  36702. * Fires when the checkbox next to the series' name in the legend is
  36703. * clicked. One parameter, `event`, is passed to the function. The state
  36704. * of the checkbox is found by `event.checked`. The checked item is
  36705. * found by `event.item`. Return `false` to prevent the default action
  36706. * which is to toggle the select state of the series.
  36707. *
  36708. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  36709. * Alert checkbox status
  36710. *
  36711. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  36712. * @since 1.2.0
  36713. * @context Highcharts.Series
  36714. * @apioption plotOptions.series.events.checkboxClick
  36715. */
  36716. /**
  36717. * Fires when the series is clicked. One parameter, `event`, is passed
  36718. * to the function, containing common event information. Additionally,
  36719. * `event.point` holds a pointer to the nearest point on the graph.
  36720. *
  36721. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  36722. * Alert click info
  36723. * @sample {highstock} stock/plotoptions/series-events-click/
  36724. * Alert click info
  36725. * @sample {highmaps} maps/plotoptions/series-events-click/
  36726. * Display click info in subtitle
  36727. *
  36728. * @type {Highcharts.SeriesClickCallbackFunction}
  36729. * @context Highcharts.Series
  36730. * @apioption plotOptions.series.events.click
  36731. */
  36732. /**
  36733. * Fires when the series is hidden after chart generation time, either
  36734. * by clicking the legend item or by calling `.hide()`.
  36735. *
  36736. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  36737. * Alert when the series is hidden by clicking the legend item
  36738. *
  36739. * @type {Highcharts.SeriesHideCallbackFunction}
  36740. * @since 1.2.0
  36741. * @context Highcharts.Series
  36742. * @apioption plotOptions.series.events.hide
  36743. */
  36744. /**
  36745. * Fires when the legend item belonging to the series is clicked. One
  36746. * parameter, `event`, is passed to the function. The default action
  36747. * is to toggle the visibility of the series. This can be prevented
  36748. * by returning `false` or calling `event.preventDefault()`.
  36749. *
  36750. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  36751. * Confirm hiding and showing
  36752. *
  36753. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  36754. * @context Highcharts.Series
  36755. * @apioption plotOptions.series.events.legendItemClick
  36756. */
  36757. /**
  36758. * Fires when the mouse leaves the graph. One parameter, `event`, is
  36759. * passed to the function, containing common event information. If the
  36760. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  36761. * doesn't happen before the mouse enters another graph or leaves the
  36762. * plot area.
  36763. *
  36764. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36765. * With sticky tracking by default
  36766. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36767. * Without sticky tracking
  36768. *
  36769. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  36770. * @context Highcharts.Series
  36771. * @apioption plotOptions.series.events.mouseOut
  36772. */
  36773. /**
  36774. * Fires when the mouse enters the graph. One parameter, `event`, is
  36775. * passed to the function, containing common event information.
  36776. *
  36777. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36778. * With sticky tracking by default
  36779. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36780. * Without sticky tracking
  36781. *
  36782. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  36783. * @context Highcharts.Series
  36784. * @apioption plotOptions.series.events.mouseOver
  36785. */
  36786. /**
  36787. * Fires when the series is shown after chart generation time, either
  36788. * by clicking the legend item or by calling `.show()`.
  36789. *
  36790. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  36791. * Alert when the series is shown by clicking the legend item.
  36792. *
  36793. * @type {Highcharts.SeriesShowCallbackFunction}
  36794. * @since 1.2.0
  36795. * @context Highcharts.Series
  36796. * @apioption plotOptions.series.events.show
  36797. */
  36798. /**
  36799. * Options for the point markers of line-like series. Properties like
  36800. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  36801. * of the markers. Other series types, like column series, don't have
  36802. * markers, but have visual options on the series level instead.
  36803. *
  36804. * In styled mode, the markers can be styled with the
  36805. * `.highcharts-point`, `.highcharts-point-hover` and
  36806. * `.highcharts-point-select` class names.
  36807. *
  36808. * @declare Highcharts.PointMarkerOptionsObject
  36809. *
  36810. * @private
  36811. */
  36812. marker: {
  36813. /**
  36814. * Enable or disable the point marker. If `undefined`, the markers
  36815. * are hidden when the data is dense, and shown for more widespread
  36816. * data points.
  36817. *
  36818. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  36819. * Disabled markers
  36820. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  36821. * Disabled in normal state but enabled on hover
  36822. * @sample {highstock} stock/plotoptions/series-marker/
  36823. * Enabled markers
  36824. *
  36825. * @type {boolean}
  36826. * @default {highcharts} undefined
  36827. * @default {highstock} false
  36828. * @apioption plotOptions.series.marker.enabled
  36829. */
  36830. /**
  36831. * The threshold for how dense the point markers should be before
  36832. * they are hidden, given that `enabled` is not defined. The number
  36833. * indicates the horizontal distance between the two closest points
  36834. * in the series, as multiples of the `marker.radius`. In other
  36835. * words, the default value of 2 means points are hidden if
  36836. * overlapping horizontally.
  36837. *
  36838. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  36839. * A higher threshold
  36840. *
  36841. * @since 6.0.5
  36842. */
  36843. enabledThreshold: 2,
  36844. /**
  36845. * The fill color of the point marker. When `undefined`, the series'
  36846. * or point's color is used.
  36847. *
  36848. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36849. * White fill
  36850. *
  36851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36852. * @apioption plotOptions.series.marker.fillColor
  36853. */
  36854. /**
  36855. * Image markers only. Set the image width explicitly. When using
  36856. * this option, a `width` must also be set.
  36857. *
  36858. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36859. * Fixed width and height
  36860. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36861. * Fixed width and height
  36862. *
  36863. * @type {number}
  36864. * @since 4.0.4
  36865. * @apioption plotOptions.series.marker.height
  36866. */
  36867. /**
  36868. * The color of the point marker's outline. When `undefined`, the
  36869. * series' or point's color is used.
  36870. *
  36871. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36872. * Inherit from series color (undefined)
  36873. *
  36874. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36875. */
  36876. lineColor: palette.backgroundColor,
  36877. /**
  36878. * The width of the point marker's outline.
  36879. *
  36880. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36881. * 2px blue marker
  36882. */
  36883. lineWidth: 0,
  36884. /**
  36885. * The radius of the point marker.
  36886. *
  36887. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  36888. * Bigger markers
  36889. *
  36890. * @default {highstock} 2
  36891. * @default {highcharts} 4
  36892. *
  36893. */
  36894. radius: 4,
  36895. /**
  36896. * A predefined shape or symbol for the marker. When undefined, the
  36897. * symbol is pulled from options.symbols. Other possible values are
  36898. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  36899. * `'triangle-down'`.
  36900. *
  36901. * Additionally, the URL to a graphic can be given on this form:
  36902. * `'url(graphic.png)'`. Note that for the image to be applied to
  36903. * exported charts, its URL needs to be accessible by the export
  36904. * server.
  36905. *
  36906. * Custom callbacks for symbol path generation can also be added to
  36907. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  36908. * used by its method name, as shown in the demo.
  36909. *
  36910. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  36911. * Predefined, graphic and custom markers
  36912. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  36913. * Predefined, graphic and custom markers
  36914. *
  36915. * @type {string}
  36916. * @apioption plotOptions.series.marker.symbol
  36917. */
  36918. /**
  36919. * Image markers only. Set the image width explicitly. When using
  36920. * this option, a `height` must also be set.
  36921. *
  36922. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36923. * Fixed width and height
  36924. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36925. * Fixed width and height
  36926. *
  36927. * @type {number}
  36928. * @since 4.0.4
  36929. * @apioption plotOptions.series.marker.width
  36930. */
  36931. /**
  36932. * States for a single point marker.
  36933. *
  36934. * @declare Highcharts.PointStatesOptionsObject
  36935. */
  36936. states: {
  36937. /**
  36938. * The normal state of a single point marker. Currently only
  36939. * used for setting animation when returning to normal state
  36940. * from hover.
  36941. *
  36942. * @declare Highcharts.PointStatesNormalOptionsObject
  36943. */
  36944. normal: {
  36945. /**
  36946. * Animation when returning to normal state after hovering.
  36947. *
  36948. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36949. */
  36950. animation: true
  36951. },
  36952. /**
  36953. * The hover state for a single point marker.
  36954. *
  36955. * @declare Highcharts.PointStatesHoverOptionsObject
  36956. */
  36957. hover: {
  36958. /**
  36959. * Animation when hovering over the marker.
  36960. *
  36961. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36962. */
  36963. animation: {
  36964. /** @internal */
  36965. duration: 50
  36966. },
  36967. /**
  36968. * Enable or disable the point marker.
  36969. *
  36970. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  36971. * Disabled hover state
  36972. */
  36973. enabled: true,
  36974. /**
  36975. * The fill color of the marker in hover state. When
  36976. * `undefined`, the series' or point's fillColor for normal
  36977. * state is used.
  36978. *
  36979. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36980. * @apioption plotOptions.series.marker.states.hover.fillColor
  36981. */
  36982. /**
  36983. * The color of the point marker's outline. When
  36984. * `undefined`, the series' or point's lineColor for normal
  36985. * state is used.
  36986. *
  36987. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  36988. * White fill color, black line color
  36989. *
  36990. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36991. * @apioption plotOptions.series.marker.states.hover.lineColor
  36992. */
  36993. /**
  36994. * The width of the point marker's outline. When
  36995. * `undefined`, the series' or point's lineWidth for normal
  36996. * state is used.
  36997. *
  36998. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  36999. * 3px line width
  37000. *
  37001. * @type {number}
  37002. * @apioption plotOptions.series.marker.states.hover.lineWidth
  37003. */
  37004. /**
  37005. * The radius of the point marker. In hover state, it
  37006. * defaults to the normal state's radius + 2 as per the
  37007. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  37008. * option.
  37009. *
  37010. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  37011. * 10px radius
  37012. *
  37013. * @type {number}
  37014. * @apioption plotOptions.series.marker.states.hover.radius
  37015. */
  37016. /**
  37017. * The number of pixels to increase the radius of the
  37018. * hovered point.
  37019. *
  37020. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37021. * 5 pixels greater radius on hover
  37022. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37023. * 5 pixels greater radius on hover
  37024. *
  37025. * @since 4.0.3
  37026. */
  37027. radiusPlus: 2,
  37028. /**
  37029. * The additional line width for a hovered point.
  37030. *
  37031. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37032. * 2 pixels wider on hover
  37033. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37034. * 2 pixels wider on hover
  37035. *
  37036. * @since 4.0.3
  37037. */
  37038. lineWidthPlus: 1
  37039. },
  37040. /**
  37041. * The appearance of the point marker when selected. In order to
  37042. * allow a point to be selected, set the
  37043. * `series.allowPointSelect` option to true.
  37044. *
  37045. * @declare Highcharts.PointStatesSelectOptionsObject
  37046. */
  37047. select: {
  37048. /**
  37049. * Enable or disable visible feedback for selection.
  37050. *
  37051. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  37052. * Disabled select state
  37053. *
  37054. * @type {boolean}
  37055. * @default true
  37056. * @apioption plotOptions.series.marker.states.select.enabled
  37057. */
  37058. /**
  37059. * The radius of the point marker. In hover state, it
  37060. * defaults to the normal state's radius + 2.
  37061. *
  37062. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  37063. * 10px radius for selected points
  37064. *
  37065. * @type {number}
  37066. * @apioption plotOptions.series.marker.states.select.radius
  37067. */
  37068. /**
  37069. * The fill color of the point marker.
  37070. *
  37071. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  37072. * Solid red discs for selected points
  37073. *
  37074. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37075. */
  37076. fillColor: palette.neutralColor20,
  37077. /**
  37078. * The color of the point marker's outline. When
  37079. * `undefined`, the series' or point's color is used.
  37080. *
  37081. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  37082. * Red line color for selected points
  37083. *
  37084. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37085. */
  37086. lineColor: palette.neutralColor100,
  37087. /**
  37088. * The width of the point marker's outline.
  37089. *
  37090. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  37091. * 3px line width for selected points
  37092. */
  37093. lineWidth: 2
  37094. }
  37095. }
  37096. },
  37097. /**
  37098. * Properties for each single point.
  37099. *
  37100. * @declare Highcharts.PlotSeriesPointOptions
  37101. *
  37102. * @private
  37103. */
  37104. point: {
  37105. /**
  37106. * Fires when a point is clicked. One parameter, `event`, is passed
  37107. * to the function, containing common event information.
  37108. *
  37109. * If the `series.allowPointSelect` option is true, the default
  37110. * action for the point's click event is to toggle the point's
  37111. * select state. Returning `false` cancels this action.
  37112. *
  37113. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  37114. * Click marker to alert values
  37115. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  37116. * Click column
  37117. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  37118. * Go to URL
  37119. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  37120. * Click marker to display values
  37121. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  37122. * Go to URL
  37123. *
  37124. * @type {Highcharts.PointClickCallbackFunction}
  37125. * @context Highcharts.Point
  37126. * @apioption plotOptions.series.point.events.click
  37127. */
  37128. /**
  37129. * Fires when the mouse leaves the area close to the point. One
  37130. * parameter, `event`, is passed to the function, containing common
  37131. * event information.
  37132. *
  37133. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37134. * Show values in the chart's corner on mouse over
  37135. *
  37136. * @type {Highcharts.PointMouseOutCallbackFunction}
  37137. * @context Highcharts.Point
  37138. * @apioption plotOptions.series.point.events.mouseOut
  37139. */
  37140. /**
  37141. * Fires when the mouse enters the area close to the point. One
  37142. * parameter, `event`, is passed to the function, containing common
  37143. * event information.
  37144. *
  37145. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37146. * Show values in the chart's corner on mouse over
  37147. *
  37148. * @type {Highcharts.PointMouseOverCallbackFunction}
  37149. * @context Highcharts.Point
  37150. * @apioption plotOptions.series.point.events.mouseOver
  37151. */
  37152. /**
  37153. * Fires when the point is removed using the `.remove()` method. One
  37154. * parameter, `event`, is passed to the function. Returning `false`
  37155. * cancels the operation.
  37156. *
  37157. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  37158. * Remove point and confirm
  37159. *
  37160. * @type {Highcharts.PointRemoveCallbackFunction}
  37161. * @since 1.2.0
  37162. * @context Highcharts.Point
  37163. * @apioption plotOptions.series.point.events.remove
  37164. */
  37165. /**
  37166. * Fires when the point is selected either programmatically or
  37167. * following a click on the point. One parameter, `event`, is passed
  37168. * to the function. Returning `false` cancels the operation.
  37169. *
  37170. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  37171. * Report the last selected point
  37172. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37173. * Report select and unselect
  37174. *
  37175. * @type {Highcharts.PointSelectCallbackFunction}
  37176. * @since 1.2.0
  37177. * @context Highcharts.Point
  37178. * @apioption plotOptions.series.point.events.select
  37179. */
  37180. /**
  37181. * Fires when the point is unselected either programmatically or
  37182. * following a click on the point. One parameter, `event`, is passed
  37183. * to the function.
  37184. * Returning `false` cancels the operation.
  37185. *
  37186. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  37187. * Report the last unselected point
  37188. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37189. * Report select and unselect
  37190. *
  37191. * @type {Highcharts.PointUnselectCallbackFunction}
  37192. * @since 1.2.0
  37193. * @context Highcharts.Point
  37194. * @apioption plotOptions.series.point.events.unselect
  37195. */
  37196. /**
  37197. * Fires when the point is updated programmatically through the
  37198. * `.update()` method. One parameter, `event`, is passed to the
  37199. * function. The new point options can be accessed through
  37200. * `event.options`. Returning `false` cancels the operation.
  37201. *
  37202. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  37203. * Confirm point updating
  37204. *
  37205. * @type {Highcharts.PointUpdateCallbackFunction}
  37206. * @since 1.2.0
  37207. * @context Highcharts.Point
  37208. * @apioption plotOptions.series.point.events.update
  37209. */
  37210. /**
  37211. * Events for each single point.
  37212. *
  37213. * @declare Highcharts.PointEventsOptionsObject
  37214. */
  37215. events: {}
  37216. },
  37217. /**
  37218. * Options for the series data labels, appearing next to each data
  37219. * point.
  37220. *
  37221. * Since v6.2.0, multiple data labels can be applied to each single
  37222. * point by defining them as an array of configs.
  37223. *
  37224. * In styled mode, the data labels can be styled with the
  37225. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  37226. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  37227. *
  37228. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  37229. * Data labels enabled
  37230. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  37231. * Multiple data labels on a bar series
  37232. * @sample {highcharts} highcharts/css/series-datalabels
  37233. * Style mode example
  37234. *
  37235. * @type {*|Array<*>}
  37236. * @product highcharts highstock highmaps gantt
  37237. *
  37238. * @private
  37239. */
  37240. dataLabels: {
  37241. /**
  37242. * Enable or disable the initial animation when a series is
  37243. * displayed for the `dataLabels`. The animation can also be set as
  37244. * a configuration object. Please note that this option only
  37245. * applies to the initial animation.
  37246. * For other animations, see [chart.animation](#chart.animation)
  37247. * and the animation parameter under the API methods.
  37248. * The following properties are supported:
  37249. *
  37250. * - `defer`: The animation delay time in milliseconds.
  37251. *
  37252. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  37253. * Animation defer settings
  37254. *
  37255. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37256. * @since 8.2.0
  37257. * @apioption plotOptions.series.dataLabels.animation
  37258. */
  37259. animation: {},
  37260. /**
  37261. * The animation delay time in milliseconds.
  37262. * Set to `0` renders dataLabel immediately.
  37263. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  37264. *
  37265. * @type {number}
  37266. * @since 8.2.0
  37267. * @apioption plotOptions.series.dataLabels.animation.defer
  37268. */
  37269. /**
  37270. * The alignment of the data label compared to the point. If
  37271. * `right`, the right side of the label should be touching the
  37272. * point. For points with an extent, like columns, the alignments
  37273. * also dictates how to align it inside the box, as given with the
  37274. * [inside](#plotOptions.column.dataLabels.inside)
  37275. * option. Can be one of `left`, `center` or `right`.
  37276. *
  37277. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  37278. * Left aligned
  37279. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37280. * Data labels inside the bar
  37281. *
  37282. * @type {Highcharts.AlignValue|null}
  37283. */
  37284. align: 'center',
  37285. /**
  37286. * Whether to allow data labels to overlap. To make the labels less
  37287. * sensitive for overlapping, the
  37288. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  37289. * can be set to 0.
  37290. *
  37291. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  37292. * Don't allow overlap
  37293. *
  37294. * @type {boolean}
  37295. * @default false
  37296. * @since 4.1.0
  37297. * @apioption plotOptions.series.dataLabels.allowOverlap
  37298. */
  37299. /**
  37300. * The background color or gradient for the data label.
  37301. *
  37302. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37303. * Data labels box options
  37304. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37305. * Data labels box options
  37306. *
  37307. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37308. * @since 2.2.1
  37309. * @apioption plotOptions.series.dataLabels.backgroundColor
  37310. */
  37311. /**
  37312. * The border color for the data label. Defaults to `undefined`.
  37313. *
  37314. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37315. * Data labels box options
  37316. *
  37317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37318. * @since 2.2.1
  37319. * @apioption plotOptions.series.dataLabels.borderColor
  37320. */
  37321. /**
  37322. * The border radius in pixels for the data label.
  37323. *
  37324. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37325. * Data labels box options
  37326. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37327. * Data labels box options
  37328. *
  37329. * @type {number}
  37330. * @default 0
  37331. * @since 2.2.1
  37332. * @apioption plotOptions.series.dataLabels.borderRadius
  37333. */
  37334. /**
  37335. * The border width in pixels for the data label.
  37336. *
  37337. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37338. * Data labels box options
  37339. *
  37340. * @type {number}
  37341. * @default 0
  37342. * @since 2.2.1
  37343. * @apioption plotOptions.series.dataLabels.borderWidth
  37344. */
  37345. /**
  37346. * A class name for the data label. Particularly in styled mode,
  37347. * this can be used to give each series' or point's data label
  37348. * unique styling. In addition to this option, a default color class
  37349. * name is added so that we can give the labels a contrast text
  37350. * shadow.
  37351. *
  37352. * @sample {highcharts} highcharts/css/data-label-contrast/
  37353. * Contrast text shadow
  37354. * @sample {highcharts} highcharts/css/series-datalabels/
  37355. * Styling by CSS
  37356. *
  37357. * @type {string}
  37358. * @since 5.0.0
  37359. * @apioption plotOptions.series.dataLabels.className
  37360. */
  37361. /**
  37362. * The text color for the data labels. Defaults to `undefined`. For
  37363. * certain series types, like column or map, the data labels can be
  37364. * drawn inside the points. In this case the data label will be
  37365. * drawn with maximum contrast by default. Additionally, it will be
  37366. * given a `text-outline` style with the opposite color, to further
  37367. * increase the contrast. This can be overridden by setting the
  37368. * `text-outline` style to `none` in the `dataLabels.style` option.
  37369. *
  37370. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  37371. * Red data labels
  37372. * @sample {highmaps} maps/demo/color-axis/
  37373. * White data labels
  37374. *
  37375. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37376. * @apioption plotOptions.series.dataLabels.color
  37377. */
  37378. /**
  37379. * Whether to hide data labels that are outside the plot area. By
  37380. * default, the data label is moved inside the plot area according
  37381. * to the
  37382. * [overflow](#plotOptions.series.dataLabels.overflow)
  37383. * option.
  37384. *
  37385. * @type {boolean}
  37386. * @default true
  37387. * @since 2.3.3
  37388. * @apioption plotOptions.series.dataLabels.crop
  37389. */
  37390. /**
  37391. * Whether to defer displaying the data labels until the initial
  37392. * series animation has finished. Setting to `false` renders the
  37393. * data label immediately. If set to `true` inherits the defer
  37394. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  37395. * If set to a number, a defer time is specified in milliseconds.
  37396. *
  37397. * @sample highcharts/plotoptions/animation-defer
  37398. * Set defer time
  37399. *
  37400. * @since 4.0.0
  37401. * @type {boolean|number}
  37402. * @product highcharts highstock gantt
  37403. */
  37404. defer: true,
  37405. /**
  37406. * Enable or disable the data labels.
  37407. *
  37408. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  37409. * Data labels enabled
  37410. * @sample {highmaps} maps/demo/color-axis/
  37411. * Data labels enabled
  37412. *
  37413. * @type {boolean}
  37414. * @default false
  37415. * @apioption plotOptions.series.dataLabels.enabled
  37416. */
  37417. /**
  37418. * A declarative filter to control of which data labels to display.
  37419. * The declarative filter is designed for use when callback
  37420. * functions are not available, like when the chart options require
  37421. * a pure JSON structure or for use with graphical editors. For
  37422. * programmatic control, use the `formatter` instead, and return
  37423. * `undefined` to disable a single data label.
  37424. *
  37425. * @example
  37426. * filter: {
  37427. * property: 'percentage',
  37428. * operator: '>',
  37429. * value: 4
  37430. * }
  37431. *
  37432. * @sample {highcharts} highcharts/demo/pie-monochrome
  37433. * Data labels filtered by percentage
  37434. *
  37435. * @declare Highcharts.DataLabelsFilterOptionsObject
  37436. * @since 6.0.3
  37437. * @apioption plotOptions.series.dataLabels.filter
  37438. */
  37439. /**
  37440. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  37441. * `==`, and `===`.
  37442. *
  37443. * @type {string}
  37444. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  37445. * @apioption plotOptions.series.dataLabels.filter.operator
  37446. */
  37447. /**
  37448. * The point property to filter by. Point options are passed
  37449. * directly to properties, additionally there are `y` value,
  37450. * `percentage` and others listed under {@link Highcharts.Point}
  37451. * members.
  37452. *
  37453. * @type {string}
  37454. * @apioption plotOptions.series.dataLabels.filter.property
  37455. */
  37456. /**
  37457. * The value to compare against.
  37458. *
  37459. * @type {number}
  37460. * @apioption plotOptions.series.dataLabels.filter.value
  37461. */
  37462. /**
  37463. * A
  37464. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  37465. * for the data label. Available variables are the same as for
  37466. * `formatter`.
  37467. *
  37468. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37469. * Add a unit
  37470. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37471. * Formatted value in the data label
  37472. *
  37473. * @type {string}
  37474. * @default y
  37475. * @default point.value
  37476. * @since 3.0
  37477. * @apioption plotOptions.series.dataLabels.format
  37478. */
  37479. // eslint-disable-next-line valid-jsdoc
  37480. /**
  37481. * Callback JavaScript function to format the data label. Note that
  37482. * if a `format` is defined, the format takes precedence and the
  37483. * formatter is ignored.
  37484. *
  37485. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37486. * Formatted value
  37487. *
  37488. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37489. */
  37490. formatter: function () {
  37491. var numberFormatter = this.series.chart.numberFormatter;
  37492. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  37493. },
  37494. /**
  37495. * For points with an extent, like columns or map areas, whether to
  37496. * align the data label inside the box or to the actual value point.
  37497. * Defaults to `false` in most cases, `true` in stacked columns.
  37498. *
  37499. * @type {boolean}
  37500. * @since 3.0
  37501. * @apioption plotOptions.series.dataLabels.inside
  37502. */
  37503. /**
  37504. * Format for points with the value of null. Works analogously to
  37505. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  37506. * be applied only to series which support displaying null points.
  37507. *
  37508. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37509. * Format data label and tooltip for null point.
  37510. *
  37511. * @type {boolean|string}
  37512. * @since 7.1.0
  37513. * @apioption plotOptions.series.dataLabels.nullFormat
  37514. */
  37515. /**
  37516. * Callback JavaScript function that defines formatting for points
  37517. * with the value of null. Works analogously to
  37518. * [formatter](#plotOptions.series.dataLabels.formatter).
  37519. * `nullPointFormatter` can be applied only to series which support
  37520. * displaying null points.
  37521. *
  37522. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37523. * Format data label and tooltip for null point.
  37524. *
  37525. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37526. * @since 7.1.0
  37527. * @apioption plotOptions.series.dataLabels.nullFormatter
  37528. */
  37529. /**
  37530. * How to handle data labels that flow outside the plot area. The
  37531. * default is `"justify"`, which aligns them inside the plot area.
  37532. * For columns and bars, this means it will be moved inside the bar.
  37533. * To display data labels outside the plot area, set `crop` to
  37534. * `false` and `overflow` to `"allow"`.
  37535. *
  37536. * @type {Highcharts.DataLabelsOverflowValue}
  37537. * @default justify
  37538. * @since 3.0.6
  37539. * @apioption plotOptions.series.dataLabels.overflow
  37540. */
  37541. /**
  37542. * When either the `borderWidth` or the `backgroundColor` is set,
  37543. * this is the padding within the box.
  37544. *
  37545. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37546. * Data labels box options
  37547. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37548. * Data labels box options
  37549. *
  37550. * @since 2.2.1
  37551. */
  37552. padding: 5,
  37553. /**
  37554. * Aligns data labels relative to points. If `center` alignment is
  37555. * not possible, it defaults to `right`.
  37556. *
  37557. * @type {Highcharts.AlignValue}
  37558. * @default center
  37559. * @apioption plotOptions.series.dataLabels.position
  37560. */
  37561. /**
  37562. * Text rotation in degrees. Note that due to a more complex
  37563. * structure, backgrounds, borders and padding will be lost on a
  37564. * rotated data label.
  37565. *
  37566. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37567. * Vertical labels
  37568. *
  37569. * @type {number}
  37570. * @default 0
  37571. * @apioption plotOptions.series.dataLabels.rotation
  37572. */
  37573. /**
  37574. * The shadow of the box. Works best with `borderWidth` or
  37575. * `backgroundColor`. Since 2.3 the shadow can be an object
  37576. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  37577. * and `width`.
  37578. *
  37579. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37580. * Data labels box options
  37581. *
  37582. * @type {boolean|Highcharts.ShadowOptionsObject}
  37583. * @default false
  37584. * @since 2.2.1
  37585. * @apioption plotOptions.series.dataLabels.shadow
  37586. */
  37587. /**
  37588. * The name of a symbol to use for the border around the label.
  37589. * Symbols are predefined functions on the Renderer object.
  37590. *
  37591. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  37592. * A callout for annotations
  37593. *
  37594. * @type {string}
  37595. * @default square
  37596. * @since 4.1.2
  37597. * @apioption plotOptions.series.dataLabels.shape
  37598. */
  37599. /**
  37600. * Styles for the label. The default `color` setting is
  37601. * `"contrast"`, which is a pseudo color that Highcharts picks up
  37602. * and applies the maximum contrast to the underlying point item,
  37603. * for example the bar in a bar chart.
  37604. *
  37605. * The `textOutline` is a pseudo property that applies an outline of
  37606. * the given width with the given color, which by default is the
  37607. * maximum contrast to the text. So a bright text color will result
  37608. * in a black text outline for maximum readability on a mixed
  37609. * background. In some cases, especially with grayscale text, the
  37610. * text outline doesn't work well, in which cases it can be disabled
  37611. * by setting it to `"none"`. When `useHTML` is true, the
  37612. * `textOutline` will not be picked up. In this, case, the same
  37613. * effect can be acheived through the `text-shadow` CSS property.
  37614. *
  37615. * For some series types, where each point has an extent, like for
  37616. * example tree maps, the data label may overflow the point. There
  37617. * are two strategies for handling overflow. By default, the text
  37618. * will wrap to multiple lines. The other strategy is to set
  37619. * `style.textOverflow` to `ellipsis`, which will keep the text on
  37620. * one line plus it will break inside long words.
  37621. *
  37622. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  37623. * Bold labels
  37624. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  37625. * Long labels truncated with an ellipsis in a pie
  37626. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  37627. * Long labels are wrapped in a pie
  37628. * @sample {highmaps} maps/demo/color-axis/
  37629. * Bold labels
  37630. *
  37631. * @type {Highcharts.CSSObject}
  37632. * @since 4.1.0
  37633. * @apioption plotOptions.series.dataLabels.style
  37634. */
  37635. style: {
  37636. /** @internal */
  37637. fontSize: '11px',
  37638. /** @internal */
  37639. fontWeight: 'bold',
  37640. /** @internal */
  37641. color: 'contrast',
  37642. /** @internal */
  37643. textOutline: '1px contrast'
  37644. },
  37645. /**
  37646. * Options for a label text which should follow marker's shape.
  37647. * Border and background are disabled for a label that follows a
  37648. * path.
  37649. *
  37650. * **Note:** Only SVG-based renderer supports this option. Setting
  37651. * `useHTML` to true will disable this option.
  37652. *
  37653. * @declare Highcharts.DataLabelsTextPathOptionsObject
  37654. * @since 7.1.0
  37655. * @apioption plotOptions.series.dataLabels.textPath
  37656. */
  37657. /**
  37658. * Presentation attributes for the text path.
  37659. *
  37660. * @type {Highcharts.SVGAttributes}
  37661. * @since 7.1.0
  37662. * @apioption plotOptions.series.dataLabels.textPath.attributes
  37663. */
  37664. /**
  37665. * Enable or disable `textPath` option for link's or marker's data
  37666. * labels.
  37667. *
  37668. * @type {boolean}
  37669. * @since 7.1.0
  37670. * @apioption plotOptions.series.dataLabels.textPath.enabled
  37671. */
  37672. /**
  37673. * Whether to
  37674. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  37675. * to render the labels.
  37676. *
  37677. * @type {boolean}
  37678. * @default false
  37679. * @apioption plotOptions.series.dataLabels.useHTML
  37680. */
  37681. /**
  37682. * The vertical alignment of a data label. Can be one of `top`,
  37683. * `middle` or `bottom`. The default value depends on the data, for
  37684. * instance in a column chart, the label is above positive values
  37685. * and below negative values.
  37686. *
  37687. * @type {Highcharts.VerticalAlignValue|null}
  37688. * @since 2.3.3
  37689. */
  37690. verticalAlign: 'bottom',
  37691. /**
  37692. * The x position offset of the label relative to the point in
  37693. * pixels.
  37694. *
  37695. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37696. * Vertical and positioned
  37697. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37698. * Data labels inside the bar
  37699. */
  37700. x: 0,
  37701. /**
  37702. * The Z index of the data labels. The default Z index puts it above
  37703. * the series. Use a Z index of 2 to display it behind the series.
  37704. *
  37705. * @type {number}
  37706. * @default 6
  37707. * @since 2.3.5
  37708. * @apioption plotOptions.series.dataLabels.z
  37709. */
  37710. /**
  37711. * The y position offset of the label relative to the point in
  37712. * pixels.
  37713. *
  37714. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37715. * Vertical and positioned
  37716. */
  37717. y: 0
  37718. },
  37719. /**
  37720. * When the series contains less points than the crop threshold, all
  37721. * points are drawn, even if the points fall outside the visible plot
  37722. * area at the current zoom. The advantage of drawing all points
  37723. * (including markers and columns), is that animation is performed on
  37724. * updates. On the other hand, when the series contains more points than
  37725. * the crop threshold, the series data is cropped to only contain points
  37726. * that fall within the plot area. The advantage of cropping away
  37727. * invisible points is to increase performance on large series.
  37728. *
  37729. * @since 2.2
  37730. * @product highcharts highstock
  37731. *
  37732. * @private
  37733. */
  37734. cropThreshold: 300,
  37735. /**
  37736. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  37737. *
  37738. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  37739. *
  37740. * @since 7.1.0
  37741. *
  37742. * @private
  37743. */
  37744. opacity: 1,
  37745. /**
  37746. * The width of each point on the x axis. For example in a column chart
  37747. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  37748. * * 1000 milliseconds). This is normally computed automatically, but
  37749. * this option can be used to override the automatic value.
  37750. *
  37751. * @product highstock
  37752. *
  37753. * @private
  37754. */
  37755. pointRange: 0,
  37756. /**
  37757. * When this is true, the series will not cause the Y axis to cross
  37758. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  37759. * unless the data actually crosses the plane.
  37760. *
  37761. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  37762. * 3 will make the Y axis show negative values according to the
  37763. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  37764. * at 0.
  37765. *
  37766. * @since 4.1.9
  37767. * @product highcharts highstock
  37768. *
  37769. * @private
  37770. */
  37771. softThreshold: true,
  37772. /**
  37773. * @declare Highcharts.SeriesStatesOptionsObject
  37774. *
  37775. * @private
  37776. */
  37777. states: {
  37778. /**
  37779. * The normal state of a series, or for point items in column, pie
  37780. * and similar series. Currently only used for setting animation
  37781. * when returning to normal state from hover.
  37782. *
  37783. * @declare Highcharts.SeriesStatesNormalOptionsObject
  37784. */
  37785. normal: {
  37786. /**
  37787. * Animation when returning to normal state after hovering.
  37788. *
  37789. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37790. */
  37791. animation: true
  37792. },
  37793. /**
  37794. * Options for the hovered series. These settings override the
  37795. * normal state options when a series is moused over or touched.
  37796. *
  37797. * @declare Highcharts.SeriesStatesHoverOptionsObject
  37798. */
  37799. hover: {
  37800. /**
  37801. * Enable separate styles for the hovered series to visualize
  37802. * that the user hovers either the series itself or the legend.
  37803. *
  37804. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  37805. * Line
  37806. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  37807. * Column
  37808. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  37809. * Pie
  37810. *
  37811. * @type {boolean}
  37812. * @default true
  37813. * @since 1.2
  37814. * @apioption plotOptions.series.states.hover.enabled
  37815. */
  37816. /**
  37817. * Animation setting for hovering the graph in line-type series.
  37818. *
  37819. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37820. * @since 5.0.8
  37821. * @product highcharts highstock
  37822. */
  37823. animation: {
  37824. /**
  37825. * The duration of the hover animation in milliseconds. By
  37826. * default the hover state animates quickly in, and slowly
  37827. * back to normal.
  37828. *
  37829. * @internal
  37830. */
  37831. duration: 50
  37832. },
  37833. /**
  37834. * Pixel width of the graph line. By default this property is
  37835. * undefined, and the `lineWidthPlus` property dictates how much
  37836. * to increase the linewidth from normal state.
  37837. *
  37838. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  37839. * 5px line on hover
  37840. *
  37841. * @type {number}
  37842. * @product highcharts highstock
  37843. * @apioption plotOptions.series.states.hover.lineWidth
  37844. */
  37845. /**
  37846. * The additional line width for the graph of a hovered series.
  37847. *
  37848. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37849. * 5 pixels wider
  37850. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37851. * 5 pixels wider
  37852. *
  37853. * @since 4.0.3
  37854. * @product highcharts highstock
  37855. */
  37856. lineWidthPlus: 1,
  37857. /**
  37858. * In Highcharts 1.0, the appearance of all markers belonging
  37859. * to the hovered series. For settings on the hover state of the
  37860. * individual point, see
  37861. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  37862. *
  37863. * @deprecated
  37864. *
  37865. * @extends plotOptions.series.marker
  37866. * @excluding states
  37867. * @product highcharts highstock
  37868. */
  37869. marker: {
  37870. // lineWidth: base + 1,
  37871. // radius: base + 1
  37872. },
  37873. /**
  37874. * Options for the halo appearing around the hovered point in
  37875. * line-type series as well as outside the hovered slice in pie
  37876. * charts. By default the halo is filled by the current point or
  37877. * series color with an opacity of 0.25\. The halo can be
  37878. * disabled by setting the `halo` option to `null`.
  37879. *
  37880. * In styled mode, the halo is styled with the
  37881. * `.highcharts-halo` class, with colors inherited from
  37882. * `.highcharts-color-{n}`.
  37883. *
  37884. * @sample {highcharts} highcharts/plotoptions/halo/
  37885. * Halo options
  37886. * @sample {highstock} highcharts/plotoptions/halo/
  37887. * Halo options
  37888. *
  37889. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  37890. * @type {null|*}
  37891. * @since 4.0
  37892. * @product highcharts highstock
  37893. */
  37894. halo: {
  37895. /**
  37896. * A collection of SVG attributes to override the appearance
  37897. * of the halo, for example `fill`, `stroke` and
  37898. * `stroke-width`.
  37899. *
  37900. * @type {Highcharts.SVGAttributes}
  37901. * @since 4.0
  37902. * @product highcharts highstock
  37903. * @apioption plotOptions.series.states.hover.halo.attributes
  37904. */
  37905. /**
  37906. * The pixel size of the halo. For point markers this is the
  37907. * radius of the halo. For pie slices it is the width of the
  37908. * halo outside the slice. For bubbles it defaults to 5 and
  37909. * is the width of the halo outside the bubble.
  37910. *
  37911. * @since 4.0
  37912. * @product highcharts highstock
  37913. */
  37914. size: 10,
  37915. /**
  37916. * Opacity for the halo unless a specific fill is overridden
  37917. * using the `attributes` setting. Note that Highcharts is
  37918. * only able to apply opacity to colors of hex or rgb(a)
  37919. * formats.
  37920. *
  37921. * @since 4.0
  37922. * @product highcharts highstock
  37923. */
  37924. opacity: 0.25
  37925. }
  37926. },
  37927. /**
  37928. * Specific options for point in selected states, after being
  37929. * selected by
  37930. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  37931. * or programmatically.
  37932. *
  37933. * @sample maps/plotoptions/series-allowpointselect/
  37934. * Allow point select demo
  37935. *
  37936. * @declare Highcharts.SeriesStatesSelectOptionsObject
  37937. * @extends plotOptions.series.states.hover
  37938. * @excluding brightness
  37939. */
  37940. select: {
  37941. animation: {
  37942. /** @internal */
  37943. duration: 0
  37944. }
  37945. },
  37946. /**
  37947. * The opposite state of a hover for series.
  37948. *
  37949. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37950. * Disabled inactive state
  37951. *
  37952. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  37953. */
  37954. inactive: {
  37955. /**
  37956. * Enable or disable the inactive state for a series
  37957. *
  37958. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37959. * Disabled inactive state
  37960. *
  37961. * @type {boolean}
  37962. * @default true
  37963. * @apioption plotOptions.series.states.inactive.enabled
  37964. */
  37965. /**
  37966. * The animation for entering the inactive state.
  37967. *
  37968. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37969. */
  37970. animation: {
  37971. /** @internal */
  37972. duration: 50
  37973. },
  37974. /**
  37975. * Opacity of series elements (dataLabels, line, area).
  37976. *
  37977. * @type {number}
  37978. */
  37979. opacity: 0.2
  37980. }
  37981. },
  37982. /**
  37983. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  37984. * series isn't triggered until the mouse moves over another series, or
  37985. * out of the plot area. When false, the `mouseOut` event on a series is
  37986. * triggered when the mouse leaves the area around the series' graph or
  37987. * markers. This also implies the tooltip when not shared. When
  37988. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  37989. * will be hidden when moving the mouse between series. Defaults to true
  37990. * for line and area type series, but to false for columns, pies etc.
  37991. *
  37992. * **Note:** The boost module will force this option because of
  37993. * technical limitations.
  37994. *
  37995. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  37996. * True by default
  37997. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  37998. * False
  37999. *
  38000. * @default {highcharts} true
  38001. * @default {highstock} true
  38002. * @default {highmaps} false
  38003. * @since 2.0
  38004. *
  38005. * @private
  38006. */
  38007. stickyTracking: true,
  38008. /**
  38009. * A configuration object for the tooltip rendering of each single
  38010. * series. Properties are inherited from [tooltip](#tooltip), but only
  38011. * the following properties can be defined on a series level.
  38012. *
  38013. * @declare Highcharts.SeriesTooltipOptionsObject
  38014. * @since 2.3
  38015. * @extends tooltip
  38016. * @excluding animation, backgroundColor, borderColor, borderRadius,
  38017. * borderWidth, className, crosshairs, enabled, formatter,
  38018. * headerShape, hideDelay, outside, padding, positioner,
  38019. * shadow, shape, shared, snap, split, stickOnContact,
  38020. * style, useHTML
  38021. * @apioption plotOptions.series.tooltip
  38022. */
  38023. /**
  38024. * When a series contains a data array that is longer than this, only
  38025. * one dimensional arrays of numbers, or two dimensional arrays with
  38026. * x and y values are allowed. Also, only the first point is tested,
  38027. * and the rest are assumed to be the same format. This saves expensive
  38028. * data checking and indexing in long series. Set it to `0` disable.
  38029. *
  38030. * Note:
  38031. * In boost mode turbo threshold is forced. Only array of numbers or
  38032. * two dimensional arrays are allowed.
  38033. *
  38034. * @since 2.2
  38035. * @product highcharts highstock gantt
  38036. *
  38037. * @private
  38038. */
  38039. turboThreshold: 1000,
  38040. /**
  38041. * An array defining zones within a series. Zones can be applied to the
  38042. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  38043. * option. The zone definitions have to be in ascending order regarding
  38044. * to the value.
  38045. *
  38046. * In styled mode, the color zones are styled with the
  38047. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  38048. * option
  38049. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  38050. *
  38051. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  38052. *
  38053. * @sample {highcharts} highcharts/series/color-zones-simple/
  38054. * Color zones
  38055. * @sample {highstock} highcharts/series/color-zones-simple/
  38056. * Color zones
  38057. *
  38058. * @declare Highcharts.SeriesZonesOptionsObject
  38059. * @type {Array<*>}
  38060. * @since 4.1.0
  38061. * @product highcharts highstock
  38062. * @apioption plotOptions.series.zones
  38063. */
  38064. /**
  38065. * Styled mode only. A custom class name for the zone.
  38066. *
  38067. * @sample highcharts/css/color-zones/
  38068. * Zones styled by class name
  38069. *
  38070. * @type {string}
  38071. * @since 5.0.0
  38072. * @apioption plotOptions.series.zones.className
  38073. */
  38074. /**
  38075. * Defines the color of the series.
  38076. *
  38077. * @see [series color](#plotOptions.series.color)
  38078. *
  38079. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38080. * @since 4.1.0
  38081. * @product highcharts highstock
  38082. * @apioption plotOptions.series.zones.color
  38083. */
  38084. /**
  38085. * A name for the dash style to use for the graph.
  38086. *
  38087. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  38088. *
  38089. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  38090. * Dashed line indicates prognosis
  38091. *
  38092. * @type {Highcharts.DashStyleValue}
  38093. * @since 4.1.0
  38094. * @product highcharts highstock
  38095. * @apioption plotOptions.series.zones.dashStyle
  38096. */
  38097. /**
  38098. * Defines the fill color for the series (in area type series)
  38099. *
  38100. * @see [fillColor](#plotOptions.area.fillColor)
  38101. *
  38102. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38103. * @since 4.1.0
  38104. * @product highcharts highstock
  38105. * @apioption plotOptions.series.zones.fillColor
  38106. */
  38107. /**
  38108. * The value up to where the zone extends, if undefined the zones
  38109. * stretches to the last value in the series.
  38110. *
  38111. * @type {number}
  38112. * @since 4.1.0
  38113. * @product highcharts highstock
  38114. * @apioption plotOptions.series.zones.value
  38115. */
  38116. /**
  38117. * When using dual or multiple color axes, this number defines which
  38118. * colorAxis the particular series is connected to. It refers to
  38119. * either the
  38120. * {@link #colorAxis.id|axis id}
  38121. * or the index of the axis in the colorAxis array, with 0 being the
  38122. * first. Set this option to false to prevent a series from connecting
  38123. * to the default color axis.
  38124. *
  38125. * Since v7.2.0 the option can also be an axis id or an axis index
  38126. * instead of a boolean flag.
  38127. *
  38128. * @sample highcharts/coloraxis/coloraxis-with-pie/
  38129. * Color axis with pie series
  38130. * @sample highcharts/coloraxis/multiple-coloraxis/
  38131. * Multiple color axis
  38132. *
  38133. * @type {number|string|boolean}
  38134. * @default 0
  38135. * @product highcharts highstock highmaps
  38136. * @apioption plotOptions.series.colorAxis
  38137. */
  38138. /**
  38139. * Determines what data value should be used to calculate point color
  38140. * if `colorAxis` is used. Requires to set `min` and `max` if some
  38141. * custom point property is used or if approximation for data grouping
  38142. * is set to `'sum'`.
  38143. *
  38144. * @sample highcharts/coloraxis/custom-color-key/
  38145. * Custom color key
  38146. * @sample highcharts/coloraxis/changed-default-color-key/
  38147. * Changed default color key
  38148. *
  38149. * @type {string}
  38150. * @default y
  38151. * @since 7.2.0
  38152. * @product highcharts highstock highmaps
  38153. * @apioption plotOptions.series.colorKey
  38154. */
  38155. /**
  38156. * Determines whether the series should look for the nearest point
  38157. * in both dimensions or just the x-dimension when hovering the series.
  38158. * Defaults to `'xy'` for scatter series and `'x'` for most other
  38159. * series. If the data has duplicate x-values, it is recommended to
  38160. * set this to `'xy'` to allow hovering over all points.
  38161. *
  38162. * Applies only to series types using nearest neighbor search (not
  38163. * direct hover) for tooltip.
  38164. *
  38165. * @sample {highcharts} highcharts/series/findnearestpointby/
  38166. * Different hover behaviors
  38167. * @sample {highstock} highcharts/series/findnearestpointby/
  38168. * Different hover behaviors
  38169. * @sample {highmaps} highcharts/series/findnearestpointby/
  38170. * Different hover behaviors
  38171. *
  38172. * @since 5.0.10
  38173. * @validvalue ["x", "xy"]
  38174. *
  38175. * @private
  38176. */
  38177. findNearestPointBy: 'x'
  38178. };
  38179. return Series;
  38180. }());
  38181. extend(Series.prototype, {
  38182. axisTypes: ['xAxis', 'yAxis'],
  38183. coll: 'series',
  38184. colorCounter: 0,
  38185. cropShoulder: 1,
  38186. directTouch: false,
  38187. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  38188. isCartesian: true,
  38189. kdAxisArray: ['clientX', 'plotY'],
  38190. // each point's x and y values are stored in this.xData and this.yData:
  38191. parallelArrays: ['x', 'y'],
  38192. pointClass: Point,
  38193. requireSorting: true,
  38194. // requires the data to be sorted:
  38195. sorted: true
  38196. });
  38197. /* *
  38198. *
  38199. * Registry
  38200. *
  38201. * */
  38202. SeriesRegistry.series = Series;
  38203. /* *
  38204. *
  38205. * Default Export
  38206. *
  38207. * */
  38208. /* *
  38209. *
  38210. * API Declarations
  38211. *
  38212. * */
  38213. /**
  38214. * This is a placeholder type of the possible series options for
  38215. * [Highcharts](../highcharts/series), [Highcharts Stock](../highstock/series),
  38216. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  38217. *
  38218. * In TypeScript is this dynamically generated to reference all possible types
  38219. * of series options.
  38220. *
  38221. * @ignore-declaration
  38222. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  38223. */
  38224. /**
  38225. * Options for `dataSorting`.
  38226. *
  38227. * @interface Highcharts.DataSortingOptionsObject
  38228. * @since 8.0.0
  38229. */ /**
  38230. * Enable or disable data sorting for the series.
  38231. * @name Highcharts.DataSortingOptionsObject#enabled
  38232. * @type {boolean|undefined}
  38233. */ /**
  38234. * Whether to allow matching points by name in an update.
  38235. * @name Highcharts.DataSortingOptionsObject#matchByName
  38236. * @type {boolean|undefined}
  38237. */ /**
  38238. * Determines what data value should be used to sort by.
  38239. * @name Highcharts.DataSortingOptionsObject#sortKey
  38240. * @type {string|undefined}
  38241. */
  38242. /**
  38243. * Function callback when a series has been animated.
  38244. *
  38245. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  38246. *
  38247. * @param {Highcharts.Series} this
  38248. * The series where the event occured.
  38249. *
  38250. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  38251. * Event arguments.
  38252. */
  38253. /**
  38254. * Event information regarding completed animation of a series.
  38255. *
  38256. * @interface Highcharts.SeriesAfterAnimateEventObject
  38257. */ /**
  38258. * Animated series.
  38259. * @name Highcharts.SeriesAfterAnimateEventObject#target
  38260. * @type {Highcharts.Series}
  38261. */ /**
  38262. * Event type.
  38263. * @name Highcharts.SeriesAfterAnimateEventObject#type
  38264. * @type {"afterAnimate"}
  38265. */
  38266. /**
  38267. * Function callback when the checkbox next to the series' name in the legend is
  38268. * clicked.
  38269. *
  38270. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  38271. *
  38272. * @param {Highcharts.Series} this
  38273. * The series where the event occured.
  38274. *
  38275. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  38276. * Event arguments.
  38277. */
  38278. /**
  38279. * Event information regarding check of a series box.
  38280. *
  38281. * @interface Highcharts.SeriesCheckboxClickEventObject
  38282. */ /**
  38283. * Whether the box has been checked.
  38284. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  38285. * @type {boolean}
  38286. */ /**
  38287. * Related series.
  38288. * @name Highcharts.SeriesCheckboxClickEventObject#item
  38289. * @type {Highcharts.Series}
  38290. */ /**
  38291. * Related series.
  38292. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38293. * @type {Highcharts.Series}
  38294. */ /**
  38295. * Event type.
  38296. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38297. * @type {"checkboxClick"}
  38298. */
  38299. /**
  38300. * Function callback when a series is clicked. Return false to cancel toogle
  38301. * actions.
  38302. *
  38303. * @callback Highcharts.SeriesClickCallbackFunction
  38304. *
  38305. * @param {Highcharts.Series} this
  38306. * The series where the event occured.
  38307. *
  38308. * @param {Highcharts.SeriesClickEventObject} event
  38309. * Event arguments.
  38310. */
  38311. /**
  38312. * Common information for a click event on a series.
  38313. *
  38314. * @interface Highcharts.SeriesClickEventObject
  38315. * @extends global.Event
  38316. */ /**
  38317. * Nearest point on the graph.
  38318. * @name Highcharts.SeriesClickEventObject#point
  38319. * @type {Highcharts.Point}
  38320. */
  38321. /**
  38322. * Gets fired when the series is hidden after chart generation time, either by
  38323. * clicking the legend item or by calling `.hide()`.
  38324. *
  38325. * @callback Highcharts.SeriesHideCallbackFunction
  38326. *
  38327. * @param {Highcharts.Series} this
  38328. * The series where the event occured.
  38329. *
  38330. * @param {global.Event} event
  38331. * The event that occured.
  38332. */
  38333. /**
  38334. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  38335. * graph.
  38336. *
  38337. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  38338. */
  38339. /**
  38340. * Gets fired when the legend item belonging to the series is clicked. The
  38341. * default action is to toggle the visibility of the series. This can be
  38342. * prevented by returning `false` or calling `event.preventDefault()`.
  38343. *
  38344. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  38345. *
  38346. * @param {Highcharts.Series} this
  38347. * The series where the event occured.
  38348. *
  38349. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  38350. * The event that occured.
  38351. */
  38352. /**
  38353. * Information about the event.
  38354. *
  38355. * @interface Highcharts.SeriesLegendItemClickEventObject
  38356. */ /**
  38357. * Related browser event.
  38358. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  38359. * @type {global.PointerEvent}
  38360. */ /**
  38361. * Prevent the default action of toggle the visibility of the series.
  38362. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  38363. * @type {Function}
  38364. */ /**
  38365. * Related series.
  38366. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38367. * @type {Highcharts.Series}
  38368. */ /**
  38369. * Event type.
  38370. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38371. * @type {"checkboxClick"}
  38372. */
  38373. /**
  38374. * Gets fired when the mouse leaves the graph.
  38375. *
  38376. * @callback Highcharts.SeriesMouseOutCallbackFunction
  38377. *
  38378. * @param {Highcharts.Series} this
  38379. * Series where the event occured.
  38380. *
  38381. * @param {global.PointerEvent} event
  38382. * Event that occured.
  38383. */
  38384. /**
  38385. * Gets fired when the mouse enters the graph.
  38386. *
  38387. * @callback Highcharts.SeriesMouseOverCallbackFunction
  38388. *
  38389. * @param {Highcharts.Series} this
  38390. * Series where the event occured.
  38391. *
  38392. * @param {global.PointerEvent} event
  38393. * Event that occured.
  38394. */
  38395. /**
  38396. * Translation and scale for the plot area of a series.
  38397. *
  38398. * @interface Highcharts.SeriesPlotBoxObject
  38399. */ /**
  38400. * @name Highcharts.SeriesPlotBoxObject#scaleX
  38401. * @type {number}
  38402. */ /**
  38403. * @name Highcharts.SeriesPlotBoxObject#scaleY
  38404. * @type {number}
  38405. */ /**
  38406. * @name Highcharts.SeriesPlotBoxObject#translateX
  38407. * @type {number}
  38408. */ /**
  38409. * @name Highcharts.SeriesPlotBoxObject#translateY
  38410. * @type {number}
  38411. */
  38412. /**
  38413. * Gets fired when the series is shown after chart generation time, either by
  38414. * clicking the legend item or by calling `.show()`.
  38415. *
  38416. * @callback Highcharts.SeriesShowCallbackFunction
  38417. *
  38418. * @param {Highcharts.Series} this
  38419. * Series where the event occured.
  38420. *
  38421. * @param {global.Event} event
  38422. * Event that occured.
  38423. */
  38424. /**
  38425. * Possible key values for the series state options.
  38426. *
  38427. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  38428. */
  38429. ''; // detach doclets above
  38430. /* *
  38431. *
  38432. * API Options
  38433. *
  38434. * */
  38435. /**
  38436. * Series options for specific data and the data itself. In TypeScript you
  38437. * have to cast the series options to specific series types, to get all
  38438. * possible options for a series.
  38439. *
  38440. * @example
  38441. * // TypeScript example
  38442. * Highcharts.chart('container', {
  38443. * series: [{
  38444. * color: '#06C',
  38445. * data: [[0, 1], [2, 3]]
  38446. * } as Highcharts.SeriesLineOptions ]
  38447. * });
  38448. *
  38449. * @type {Array<*>}
  38450. * @apioption series
  38451. */
  38452. /**
  38453. * An id for the series. This can be used after render time to get a pointer
  38454. * to the series object through `chart.get()`.
  38455. *
  38456. * @sample {highcharts} highcharts/plotoptions/series-id/
  38457. * Get series by id
  38458. *
  38459. * @type {string}
  38460. * @since 1.2.0
  38461. * @apioption series.id
  38462. */
  38463. /**
  38464. * The index of the series in the chart, affecting the internal index in the
  38465. * `chart.series` array, the visible Z index as well as the order in the
  38466. * legend.
  38467. *
  38468. * @type {number}
  38469. * @since 2.3.0
  38470. * @apioption series.index
  38471. */
  38472. /**
  38473. * The sequential index of the series in the legend.
  38474. *
  38475. * @see [legend.reversed](#legend.reversed),
  38476. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  38477. *
  38478. * @sample {highcharts|highstock} highcharts/series/legendindex/
  38479. * Legend in opposite order
  38480. *
  38481. * @type {number}
  38482. * @apioption series.legendIndex
  38483. */
  38484. /**
  38485. * The name of the series as shown in the legend, tooltip etc.
  38486. *
  38487. * @sample {highcharts} highcharts/series/name/
  38488. * Series name
  38489. * @sample {highmaps} maps/demo/category-map/
  38490. * Series name
  38491. *
  38492. * @type {string}
  38493. * @apioption series.name
  38494. */
  38495. /**
  38496. * This option allows grouping series in a stacked chart. The stack option
  38497. * can be a string or anything else, as long as the grouped series' stack
  38498. * options match each other after conversion into a string.
  38499. *
  38500. * @sample {highcharts} highcharts/series/stack/
  38501. * Stacked and grouped columns
  38502. *
  38503. * @type {number|string}
  38504. * @since 2.1
  38505. * @product highcharts highstock
  38506. * @apioption series.stack
  38507. */
  38508. /**
  38509. * The type of series, for example `line` or `column`. By default, the
  38510. * series type is inherited from [chart.type](#chart.type), so unless the
  38511. * chart is a combination of series types, there is no need to set it on the
  38512. * series level.
  38513. *
  38514. * @sample {highcharts} highcharts/series/type/
  38515. * Line and column in the same chart
  38516. * @sample highcharts/series/type-dynamic/
  38517. * Dynamic types with button selector
  38518. * @sample {highmaps} maps/demo/mapline-mappoint/
  38519. * Multiple types in the same map
  38520. *
  38521. * @type {string}
  38522. * @apioption series.type
  38523. */
  38524. /**
  38525. * When using dual or multiple x axes, this number defines which xAxis the
  38526. * particular series is connected to. It refers to either the
  38527. * {@link #xAxis.id|axis id}
  38528. * or the index of the axis in the xAxis array, with 0 being the first.
  38529. *
  38530. * @type {number|string}
  38531. * @default 0
  38532. * @product highcharts highstock
  38533. * @apioption series.xAxis
  38534. */
  38535. /**
  38536. * When using dual or multiple y axes, this number defines which yAxis the
  38537. * particular series is connected to. It refers to either the
  38538. * {@link #yAxis.id|axis id}
  38539. * or the index of the axis in the yAxis array, with 0 being the first.
  38540. *
  38541. * @sample {highcharts} highcharts/series/yaxis/
  38542. * Apply the column series to the secondary Y axis
  38543. *
  38544. * @type {number|string}
  38545. * @default 0
  38546. * @product highcharts highstock
  38547. * @apioption series.yAxis
  38548. */
  38549. /**
  38550. * Define the visual z index of the series.
  38551. *
  38552. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  38553. * With no z index, the series defined last are on top
  38554. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  38555. * With a z index, the series with the highest z index is on top
  38556. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  38557. * With no z index, the series defined last are on top
  38558. * @sample {highstock} highcharts/plotoptions/series-zindex/
  38559. * With a z index, the series with the highest z index is on top
  38560. *
  38561. * @type {number}
  38562. * @product highcharts highstock
  38563. * @apioption series.zIndex
  38564. */
  38565. ''; // include precedent doclets in transpilat
  38566. return Series;
  38567. });
  38568. _registerModule(_modules, 'Extensions/ScrollablePlotArea.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Series, H, U) {
  38569. /* *
  38570. *
  38571. * (c) 2010-2021 Torstein Honsi
  38572. *
  38573. * License: www.highcharts.com/license
  38574. *
  38575. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38576. *
  38577. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  38578. * horizontally on mobile devices. Supports left and right side axes.
  38579. */
  38580. /*
  38581. WIP on vertical scrollable plot area (#9378). To do:
  38582. - Bottom axis positioning
  38583. - Test with Gantt
  38584. - Look for size optimizing the code
  38585. - API and demos
  38586. */
  38587. var stop = A.stop;
  38588. var addEvent = U.addEvent,
  38589. createElement = U.createElement,
  38590. merge = U.merge,
  38591. pick = U.pick;
  38592. /**
  38593. * Options for a scrollable plot area. This feature provides a minimum size for
  38594. * the plot area of the chart. If the size gets smaller than this, typically
  38595. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  38596. * provides smooth scrolling for the contents of the plot area, whereas the
  38597. * title, legend and unaffected axes are fixed.
  38598. *
  38599. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  38600. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  38601. * option is set.
  38602. *
  38603. * @sample highcharts/chart/scrollable-plotarea
  38604. * Scrollable plot area
  38605. * @sample highcharts/chart/scrollable-plotarea-vertical
  38606. * Vertically scrollable plot area
  38607. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  38608. * Gantt chart with vertically scrollable plot area
  38609. *
  38610. * @since 6.1.0
  38611. * @product highcharts gantt
  38612. * @apioption chart.scrollablePlotArea
  38613. */
  38614. /**
  38615. * The minimum height for the plot area. If it gets smaller than this, the plot
  38616. * area will become scrollable.
  38617. *
  38618. * @type {number}
  38619. * @apioption chart.scrollablePlotArea.minHeight
  38620. */
  38621. /**
  38622. * The minimum width for the plot area. If it gets smaller than this, the plot
  38623. * area will become scrollable.
  38624. *
  38625. * @type {number}
  38626. * @apioption chart.scrollablePlotArea.minWidth
  38627. */
  38628. /**
  38629. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38630. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  38631. * Typically we would use 1 if the chart has right aligned Y axes.
  38632. *
  38633. * @type {number}
  38634. * @apioption chart.scrollablePlotArea.scrollPositionX
  38635. */
  38636. /**
  38637. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38638. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  38639. *
  38640. * @type {number}
  38641. * @apioption chart.scrollablePlotArea.scrollPositionY
  38642. */
  38643. /**
  38644. * The opacity of mask applied on one of the sides of the plot
  38645. * area.
  38646. *
  38647. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  38648. * Disabled opacity for the mask
  38649. *
  38650. * @type {number}
  38651. * @default 0.85
  38652. * @since 7.1.1
  38653. * @apioption chart.scrollablePlotArea.opacity
  38654. */
  38655. ''; // detach API doclets
  38656. /* eslint-disable no-invalid-this, valid-jsdoc */
  38657. addEvent(Chart, 'afterSetChartSize', function (e) {
  38658. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  38659. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  38660. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  38661. scrollablePixelsX,
  38662. scrollablePixelsY,
  38663. corrections;
  38664. if (!this.renderer.forExport) {
  38665. // The amount of pixels to scroll, the difference between chart
  38666. // width and scrollable width
  38667. if (scrollableMinWidth) {
  38668. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  38669. if (scrollablePixelsX) {
  38670. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38671. this.plotBox.width = this.plotWidth += scrollablePixelsX;
  38672. if (this.inverted) {
  38673. this.clipBox.height += scrollablePixelsX;
  38674. }
  38675. else {
  38676. this.clipBox.width += scrollablePixelsX;
  38677. }
  38678. corrections = {
  38679. // Corrections for right side
  38680. 1: { name: 'right', value: scrollablePixelsX }
  38681. };
  38682. }
  38683. // Currently we can only do either X or Y
  38684. }
  38685. else if (scrollableMinHeight) {
  38686. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  38687. if (scrollablePixelsY) {
  38688. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38689. this.plotBox.height = this.plotHeight += scrollablePixelsY;
  38690. if (this.inverted) {
  38691. this.clipBox.width += scrollablePixelsY;
  38692. }
  38693. else {
  38694. this.clipBox.height += scrollablePixelsY;
  38695. }
  38696. corrections = {
  38697. 2: { name: 'bottom', value: scrollablePixelsY }
  38698. };
  38699. }
  38700. }
  38701. if (corrections && !e.skipAxes) {
  38702. this.axes.forEach(function (axis) {
  38703. // For right and bottom axes, only fix the plot line length
  38704. if (corrections[axis.side]) {
  38705. // Get the plot lines right in getPlotLinePath,
  38706. // temporarily set it to the adjusted plot width.
  38707. axis.getPlotLinePath = function () {
  38708. var marginName = corrections[axis.side].name,
  38709. correctionValue = corrections[axis.side].value,
  38710. // axis.right or axis.bottom
  38711. margin = this[marginName],
  38712. path;
  38713. // Temporarily adjust
  38714. this[marginName] = margin - correctionValue;
  38715. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  38716. // Reset
  38717. this[marginName] = margin;
  38718. return path;
  38719. };
  38720. }
  38721. else {
  38722. // Apply the corrected plotWidth
  38723. axis.setAxisSize();
  38724. axis.setAxisTranslation();
  38725. }
  38726. });
  38727. }
  38728. }
  38729. });
  38730. addEvent(Chart, 'render', function () {
  38731. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  38732. if (this.setUpScrolling) {
  38733. this.setUpScrolling();
  38734. }
  38735. this.applyFixed();
  38736. }
  38737. else if (this.fixedDiv) { // Has been in scrollable mode
  38738. this.applyFixed();
  38739. }
  38740. });
  38741. /**
  38742. * @private
  38743. * @function Highcharts.Chart#setUpScrolling
  38744. * @return {void}
  38745. */
  38746. Chart.prototype.setUpScrolling = function () {
  38747. var _this = this;
  38748. var css = {
  38749. WebkitOverflowScrolling: 'touch',
  38750. overflowX: 'hidden',
  38751. overflowY: 'hidden'
  38752. };
  38753. if (this.scrollablePixelsX) {
  38754. css.overflowX = 'auto';
  38755. }
  38756. if (this.scrollablePixelsY) {
  38757. css.overflowY = 'auto';
  38758. }
  38759. // Insert a container with position relative
  38760. // that scrolling and fixed container renders to (#10555)
  38761. this.scrollingParent = createElement('div', {
  38762. className: 'highcharts-scrolling-parent'
  38763. }, {
  38764. position: 'relative'
  38765. }, this.renderTo);
  38766. // Add the necessary divs to provide scrolling
  38767. this.scrollingContainer = createElement('div', {
  38768. 'className': 'highcharts-scrolling'
  38769. }, css, this.scrollingParent);
  38770. // On scroll, reset the chart position because it applies to the scrolled
  38771. // container
  38772. addEvent(this.scrollingContainer, 'scroll', function () {
  38773. if (_this.pointer) {
  38774. delete _this.pointer.chartPosition;
  38775. }
  38776. });
  38777. this.innerContainer = createElement('div', {
  38778. 'className': 'highcharts-inner-container'
  38779. }, null, this.scrollingContainer);
  38780. // Now move the container inside
  38781. this.innerContainer.appendChild(this.container);
  38782. // Don't run again
  38783. this.setUpScrolling = null;
  38784. };
  38785. /**
  38786. * These elements are moved over to the fixed renderer and stay fixed when the
  38787. * user scrolls the chart
  38788. * @private
  38789. */
  38790. Chart.prototype.moveFixedElements = function () {
  38791. var container = this.container,
  38792. fixedRenderer = this.fixedRenderer,
  38793. fixedSelectors = [
  38794. '.highcharts-contextbutton',
  38795. '.highcharts-credits',
  38796. '.highcharts-legend',
  38797. '.highcharts-legend-checkbox',
  38798. '.highcharts-navigator-series',
  38799. '.highcharts-navigator-xaxis',
  38800. '.highcharts-navigator-yaxis',
  38801. '.highcharts-navigator',
  38802. '.highcharts-reset-zoom',
  38803. '.highcharts-drillup-button',
  38804. '.highcharts-scrollbar',
  38805. '.highcharts-subtitle',
  38806. '.highcharts-title'
  38807. ],
  38808. axisClass;
  38809. if (this.scrollablePixelsX && !this.inverted) {
  38810. axisClass = '.highcharts-yaxis';
  38811. }
  38812. else if (this.scrollablePixelsX && this.inverted) {
  38813. axisClass = '.highcharts-xaxis';
  38814. }
  38815. else if (this.scrollablePixelsY && !this.inverted) {
  38816. axisClass = '.highcharts-xaxis';
  38817. }
  38818. else if (this.scrollablePixelsY && this.inverted) {
  38819. axisClass = '.highcharts-yaxis';
  38820. }
  38821. if (axisClass) {
  38822. fixedSelectors.push(axisClass + ":not(.highcharts-radial-axis)", axisClass + "-labels:not(.highcharts-radial-axis-labels)");
  38823. }
  38824. fixedSelectors.forEach(function (className) {
  38825. [].forEach.call(container.querySelectorAll(className), function (elem) {
  38826. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  38827. fixedRenderer.box :
  38828. fixedRenderer.box.parentNode).appendChild(elem);
  38829. elem.style.pointerEvents = 'auto';
  38830. });
  38831. });
  38832. };
  38833. /**
  38834. * @private
  38835. * @function Highcharts.Chart#applyFixed
  38836. * @return {void}
  38837. */
  38838. Chart.prototype.applyFixed = function () {
  38839. var fixedRenderer,
  38840. scrollableWidth,
  38841. scrollableHeight,
  38842. firstTime = !this.fixedDiv,
  38843. chartOptions = this.options.chart,
  38844. scrollableOptions = chartOptions.scrollablePlotArea;
  38845. // First render
  38846. if (firstTime) {
  38847. this.fixedDiv = createElement('div', {
  38848. className: 'highcharts-fixed'
  38849. }, {
  38850. position: 'absolute',
  38851. overflow: 'hidden',
  38852. pointerEvents: 'none',
  38853. zIndex: (chartOptions.style && chartOptions.style.zIndex || 0) + 2,
  38854. top: 0
  38855. }, null, true);
  38856. if (this.scrollingContainer) {
  38857. this.scrollingContainer.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  38858. }
  38859. this.renderTo.style.overflow = 'visible';
  38860. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, this.options.chart.style);
  38861. // Mask
  38862. this.scrollableMask = fixedRenderer
  38863. .path()
  38864. .attr({
  38865. fill: this.options.chart.backgroundColor || '#fff',
  38866. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  38867. zIndex: -1
  38868. })
  38869. .addClass('highcharts-scrollable-mask')
  38870. .add();
  38871. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  38872. addEvent(this, 'afterDrilldown', this.moveFixedElements);
  38873. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  38874. }
  38875. else {
  38876. // Set the size of the fixed renderer to the visible width
  38877. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  38878. }
  38879. if (this.scrollableDirty || firstTime) {
  38880. this.scrollableDirty = false;
  38881. this.moveFixedElements();
  38882. }
  38883. // Increase the size of the scrollable renderer and background
  38884. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  38885. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  38886. stop(this.container);
  38887. this.container.style.width = scrollableWidth + 'px';
  38888. this.container.style.height = scrollableHeight + 'px';
  38889. this.renderer.boxWrapper.attr({
  38890. width: scrollableWidth,
  38891. height: scrollableHeight,
  38892. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  38893. });
  38894. this.chartBackground.attr({
  38895. width: scrollableWidth,
  38896. height: scrollableHeight
  38897. });
  38898. this.scrollingContainer.style.height = this.chartHeight + 'px';
  38899. // Set scroll position
  38900. if (firstTime) {
  38901. if (scrollableOptions.scrollPositionX) {
  38902. this.scrollingContainer.scrollLeft =
  38903. this.scrollablePixelsX *
  38904. scrollableOptions.scrollPositionX;
  38905. }
  38906. if (scrollableOptions.scrollPositionY) {
  38907. this.scrollingContainer.scrollTop =
  38908. this.scrollablePixelsY *
  38909. scrollableOptions.scrollPositionY;
  38910. }
  38911. }
  38912. // Mask behind the left and right side
  38913. var axisOffset = this.axisOffset,
  38914. maskTop = this.plotTop - axisOffset[0] - 1,
  38915. maskLeft = this.plotLeft - axisOffset[3] - 1,
  38916. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  38917. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  38918. maskPlotRight = this.plotLeft + this.plotWidth -
  38919. (this.scrollablePixelsX || 0),
  38920. maskPlotBottom = this.plotTop + this.plotHeight -
  38921. (this.scrollablePixelsY || 0),
  38922. d;
  38923. if (this.scrollablePixelsX) {
  38924. d = [
  38925. // Left side
  38926. ['M', 0, maskTop],
  38927. ['L', this.plotLeft - 1, maskTop],
  38928. ['L', this.plotLeft - 1, maskBottom],
  38929. ['L', 0, maskBottom],
  38930. ['Z'],
  38931. // Right side
  38932. ['M', maskPlotRight, maskTop],
  38933. ['L', this.chartWidth, maskTop],
  38934. ['L', this.chartWidth, maskBottom],
  38935. ['L', maskPlotRight, maskBottom],
  38936. ['Z']
  38937. ];
  38938. }
  38939. else if (this.scrollablePixelsY) {
  38940. d = [
  38941. // Top side
  38942. ['M', maskLeft, 0],
  38943. ['L', maskLeft, this.plotTop - 1],
  38944. ['L', maskRight, this.plotTop - 1],
  38945. ['L', maskRight, 0],
  38946. ['Z'],
  38947. // Bottom side
  38948. ['M', maskLeft, maskPlotBottom],
  38949. ['L', maskLeft, this.chartHeight],
  38950. ['L', maskRight, this.chartHeight],
  38951. ['L', maskRight, maskPlotBottom],
  38952. ['Z']
  38953. ];
  38954. }
  38955. else {
  38956. d = [['M', 0, 0]];
  38957. }
  38958. if (this.redrawTrigger !== 'adjustHeight') {
  38959. this.scrollableMask.attr({ d: d });
  38960. }
  38961. };
  38962. addEvent(Axis, 'afterInit', function () {
  38963. this.chart.scrollableDirty = true;
  38964. });
  38965. addEvent(Series, 'show', function () {
  38966. this.chart.scrollableDirty = true;
  38967. });
  38968. });
  38969. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  38970. /* *
  38971. *
  38972. * (c) 2010-2021 Torstein Honsi
  38973. *
  38974. * License: www.highcharts.com/license
  38975. *
  38976. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38977. *
  38978. * */
  38979. var getDeferredAnimation = A.getDeferredAnimation;
  38980. var addEvent = U.addEvent,
  38981. destroyObjectProperties = U.destroyObjectProperties,
  38982. fireEvent = U.fireEvent,
  38983. isNumber = U.isNumber,
  38984. objectEach = U.objectEach,
  38985. pick = U.pick;
  38986. /* eslint-disable valid-jsdoc */
  38987. /**
  38988. * Adds stacking support to axes.
  38989. * @private
  38990. * @class
  38991. */
  38992. var StackingAxisAdditions = /** @class */ (function () {
  38993. /* *
  38994. *
  38995. * Constructors
  38996. *
  38997. * */
  38998. function StackingAxisAdditions(axis) {
  38999. this.oldStacks = {};
  39000. this.stacks = {};
  39001. this.stacksTouched = 0;
  39002. this.axis = axis;
  39003. }
  39004. /* *
  39005. *
  39006. * Functions
  39007. *
  39008. * */
  39009. /**
  39010. * Build the stacks from top down
  39011. * @private
  39012. */
  39013. StackingAxisAdditions.prototype.buildStacks = function () {
  39014. var stacking = this;
  39015. var axis = stacking.axis;
  39016. var axisSeries = axis.series;
  39017. var reversedStacks = axis.options.reversedStacks;
  39018. var len = axisSeries.length;
  39019. var actualSeries,
  39020. i;
  39021. if (!axis.isXAxis) {
  39022. stacking.usePercentage = false;
  39023. i = len;
  39024. while (i--) {
  39025. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  39026. actualSeries.setStackedPoints();
  39027. actualSeries.setGroupedPoints();
  39028. }
  39029. // Loop up again to compute percent and stream stack
  39030. for (i = 0; i < len; i++) {
  39031. axisSeries[i].modifyStacks();
  39032. }
  39033. fireEvent(axis, 'afterBuildStacks');
  39034. }
  39035. };
  39036. /**
  39037. * @private
  39038. */
  39039. StackingAxisAdditions.prototype.cleanStacks = function () {
  39040. var stacking = this;
  39041. var axis = stacking.axis;
  39042. var stacks;
  39043. if (!axis.isXAxis) {
  39044. if (stacking.oldStacks) {
  39045. stacks = stacking.stacks = stacking.oldStacks;
  39046. }
  39047. // reset stacks
  39048. objectEach(stacks, function (type) {
  39049. objectEach(type, function (stack) {
  39050. stack.cumulative = stack.total;
  39051. });
  39052. });
  39053. }
  39054. };
  39055. /**
  39056. * Set all the stacks to initial states and destroy unused ones.
  39057. * @private
  39058. */
  39059. StackingAxisAdditions.prototype.resetStacks = function () {
  39060. var _this = this;
  39061. var _a = this,
  39062. axis = _a.axis,
  39063. stacks = _a.stacks;
  39064. if (!axis.isXAxis) {
  39065. objectEach(stacks, function (type) {
  39066. objectEach(type, function (stack, x) {
  39067. // Clean up memory after point deletion (#1044, #4320)
  39068. if (isNumber(stack.touched) &&
  39069. stack.touched < _this.stacksTouched) {
  39070. stack.destroy();
  39071. delete type[x];
  39072. // Reset stacks
  39073. }
  39074. else {
  39075. stack.total = null;
  39076. stack.cumulative = null;
  39077. }
  39078. });
  39079. });
  39080. }
  39081. };
  39082. /**
  39083. * @private
  39084. */
  39085. StackingAxisAdditions.prototype.renderStackTotals = function () {
  39086. var stacking = this;
  39087. var axis = stacking.axis;
  39088. var chart = axis.chart;
  39089. var renderer = chart.renderer;
  39090. var stacks = stacking.stacks;
  39091. var stackLabelsAnim = axis.options.stackLabels && axis.options.stackLabels.animation;
  39092. var animationConfig = getDeferredAnimation(chart,
  39093. stackLabelsAnim || false);
  39094. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  39095. renderer
  39096. .g('stack-labels')
  39097. .attr({
  39098. visibility: 'visible',
  39099. zIndex: 6,
  39100. opacity: 0
  39101. })
  39102. .add());
  39103. // plotLeft/Top will change when y axis gets wider so we need to
  39104. // translate the stackTotalGroup at every render call. See bug #506
  39105. // and #516
  39106. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  39107. // Render each stack total
  39108. objectEach(stacks, function (type) {
  39109. objectEach(type, function (stack) {
  39110. stack.render(stackTotalGroup);
  39111. });
  39112. });
  39113. stackTotalGroup.animate({
  39114. opacity: 1
  39115. }, animationConfig);
  39116. };
  39117. return StackingAxisAdditions;
  39118. }());
  39119. /**
  39120. * Axis with stacking support.
  39121. * @private
  39122. * @class
  39123. */
  39124. var StackingAxis = /** @class */ (function () {
  39125. function StackingAxis() {
  39126. }
  39127. /* *
  39128. *
  39129. * Static Functions
  39130. *
  39131. * */
  39132. /**
  39133. * Extends axis with stacking support.
  39134. * @private
  39135. */
  39136. StackingAxis.compose = function (AxisClass) {
  39137. var axisProto = AxisClass.prototype;
  39138. addEvent(AxisClass, 'init', StackingAxis.onInit);
  39139. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  39140. };
  39141. /**
  39142. * @private
  39143. */
  39144. StackingAxis.onDestroy = function () {
  39145. var stacking = this.stacking;
  39146. if (!stacking) {
  39147. return;
  39148. }
  39149. var stacks = stacking.stacks;
  39150. // Destroy each stack total
  39151. objectEach(stacks, function (stack, stackKey) {
  39152. destroyObjectProperties(stack);
  39153. stacks[stackKey] = null;
  39154. });
  39155. if (stacking &&
  39156. stacking.stackTotalGroup) {
  39157. stacking.stackTotalGroup.destroy();
  39158. }
  39159. };
  39160. /**
  39161. * @private
  39162. */
  39163. StackingAxis.onInit = function () {
  39164. var axis = this;
  39165. if (!axis.stacking) {
  39166. axis.stacking = new StackingAxisAdditions(axis);
  39167. }
  39168. };
  39169. return StackingAxis;
  39170. }());
  39171. return StackingAxis;
  39172. });
  39173. _registerModule(_modules, 'Extensions/Stacking.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Axis/StackingAxis.js'], _modules['Core/Utilities.js']], function (Axis, Chart, F, H, Series, StackingAxis, U) {
  39174. /* *
  39175. *
  39176. * (c) 2010-2021 Torstein Honsi
  39177. *
  39178. * License: www.highcharts.com/license
  39179. *
  39180. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39181. *
  39182. * */
  39183. var format = F.format;
  39184. var correctFloat = U.correctFloat,
  39185. defined = U.defined,
  39186. destroyObjectProperties = U.destroyObjectProperties,
  39187. isArray = U.isArray,
  39188. isNumber = U.isNumber,
  39189. objectEach = U.objectEach,
  39190. pick = U.pick;
  39191. /**
  39192. * Stack of data points
  39193. *
  39194. * @product highcharts
  39195. *
  39196. * @interface Highcharts.StackItemObject
  39197. */ /**
  39198. * Alignment settings
  39199. * @name Highcharts.StackItemObject#alignOptions
  39200. * @type {Highcharts.AlignObject}
  39201. */ /**
  39202. * Related axis
  39203. * @name Highcharts.StackItemObject#axis
  39204. * @type {Highcharts.Axis}
  39205. */ /**
  39206. * Cumulative value of the stacked data points
  39207. * @name Highcharts.StackItemObject#cumulative
  39208. * @type {number}
  39209. */ /**
  39210. * True if on the negative side
  39211. * @name Highcharts.StackItemObject#isNegative
  39212. * @type {boolean}
  39213. */ /**
  39214. * Related SVG element
  39215. * @name Highcharts.StackItemObject#label
  39216. * @type {Highcharts.SVGElement}
  39217. */ /**
  39218. * Related stack options
  39219. * @name Highcharts.StackItemObject#options
  39220. * @type {Highcharts.YAxisStackLabelsOptions}
  39221. */ /**
  39222. * Total value of the stacked data points
  39223. * @name Highcharts.StackItemObject#total
  39224. * @type {number}
  39225. */ /**
  39226. * Shared x value of the stack
  39227. * @name Highcharts.StackItemObject#x
  39228. * @type {number}
  39229. */
  39230. ''; // detached doclets above
  39231. /* eslint-disable no-invalid-this, valid-jsdoc */
  39232. /**
  39233. * The class for stacks. Each stack, on a specific X value and either negative
  39234. * or positive, has its own stack item.
  39235. *
  39236. * @private
  39237. * @class
  39238. * @name Highcharts.StackItem
  39239. * @param {Highcharts.Axis} axis
  39240. * @param {Highcharts.YAxisStackLabelsOptions} options
  39241. * @param {boolean} isNegative
  39242. * @param {number} x
  39243. * @param {Highcharts.OptionsStackingValue} [stackOption]
  39244. */
  39245. var StackItem = /** @class */ (function () {
  39246. function StackItem(axis, options, isNegative, x, stackOption) {
  39247. var inverted = axis.chart.inverted;
  39248. this.axis = axis;
  39249. // Tells if the stack is negative
  39250. this.isNegative = isNegative;
  39251. // Save the options to be able to style the label
  39252. this.options = options = options || {};
  39253. // Save the x value to be able to position the label later
  39254. this.x = x;
  39255. // Initialize total value
  39256. this.total = null;
  39257. // This will keep each points' extremes stored by series.index and point
  39258. // index
  39259. this.points = {};
  39260. this.hasValidPoints = false;
  39261. // Save the stack option on the series configuration object,
  39262. // and whether to treat it as percent
  39263. this.stack = stackOption;
  39264. this.leftCliff = 0;
  39265. this.rightCliff = 0;
  39266. // The align options and text align varies on whether the stack is
  39267. // negative and if the chart is inverted or not.
  39268. // First test the user supplied value, then use the dynamic.
  39269. this.alignOptions = {
  39270. align: options.align ||
  39271. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  39272. verticalAlign: options.verticalAlign ||
  39273. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  39274. y: options.y,
  39275. x: options.x
  39276. };
  39277. this.textAlign = options.textAlign ||
  39278. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  39279. }
  39280. /**
  39281. * @private
  39282. * @function Highcharts.StackItem#destroy
  39283. */
  39284. StackItem.prototype.destroy = function () {
  39285. destroyObjectProperties(this, this.axis);
  39286. };
  39287. /**
  39288. * Renders the stack total label and adds it to the stack label group.
  39289. *
  39290. * @private
  39291. * @function Highcharts.StackItem#render
  39292. * @param {Highcharts.SVGElement} group
  39293. */
  39294. StackItem.prototype.render = function (group) {
  39295. var chart = this.axis.chart,
  39296. options = this.options,
  39297. formatOption = options.format,
  39298. attr = {},
  39299. str = formatOption ? // format the text in the label
  39300. format(formatOption,
  39301. this,
  39302. chart) :
  39303. options.formatter.call(this);
  39304. // Change the text to reflect the new total and set visibility to hidden
  39305. // in case the serie is hidden
  39306. if (this.label) {
  39307. this.label.attr({ text: str, visibility: 'hidden' });
  39308. }
  39309. else {
  39310. // Create new label
  39311. this.label = chart.renderer
  39312. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  39313. attr = {
  39314. r: options.borderRadius || 0,
  39315. text: str,
  39316. rotation: options.rotation,
  39317. padding: pick(options.padding, 5),
  39318. visibility: 'hidden' // hidden until setOffset is called
  39319. };
  39320. if (!chart.styledMode) {
  39321. attr.fill = options.backgroundColor;
  39322. attr.stroke = options.borderColor;
  39323. attr['stroke-width'] = options.borderWidth;
  39324. this.label.css(options.style);
  39325. }
  39326. this.label.attr(attr);
  39327. if (!this.label.added) {
  39328. this.label.add(group); // add to the labels-group
  39329. }
  39330. }
  39331. // Rank it higher than data labels (#8742)
  39332. this.label.labelrank = chart.plotSizeY;
  39333. };
  39334. /**
  39335. * Sets the offset that the stack has from the x value and repositions the
  39336. * label.
  39337. *
  39338. * @private
  39339. * @function Highcarts.StackItem#setOffset
  39340. * @param {number} xOffset
  39341. * @param {number} xWidth
  39342. * @param {number} [boxBottom]
  39343. * @param {number} [boxTop]
  39344. * @param {number} [defaultX]
  39345. */
  39346. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  39347. var stackItem = this,
  39348. axis = stackItem.axis,
  39349. chart = axis.chart,
  39350. // stack value translated mapped to chart coordinates
  39351. y = axis.translate(axis.stacking.usePercentage ?
  39352. 100 :
  39353. (boxTop ?
  39354. boxTop :
  39355. stackItem.total), 0, 0, 0, 1),
  39356. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  39357. // stack height:
  39358. h = defined(y) && Math.abs(y - yZero),
  39359. // x position:
  39360. x = pick(defaultX,
  39361. chart.xAxis[0].translate(stackItem.x)) +
  39362. xOffset,
  39363. stackBox = defined(y) && stackItem.getStackBox(chart,
  39364. stackItem,
  39365. x,
  39366. y,
  39367. xWidth,
  39368. h,
  39369. axis),
  39370. label = stackItem.label,
  39371. isNegative = stackItem.isNegative,
  39372. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  39373. textAlign = stackItem.textAlign,
  39374. visible;
  39375. if (label && stackBox) {
  39376. var bBox = label.getBBox(),
  39377. padding = label.padding,
  39378. boxOffsetX = void 0,
  39379. boxOffsetY = void 0;
  39380. if (textAlign === 'left') {
  39381. boxOffsetX = chart.inverted ? -padding : padding;
  39382. }
  39383. else if (textAlign === 'right') {
  39384. boxOffsetX = bBox.width;
  39385. }
  39386. else {
  39387. if (chart.inverted && textAlign === 'center') {
  39388. boxOffsetX = bBox.width / 2;
  39389. }
  39390. else {
  39391. boxOffsetX = chart.inverted ?
  39392. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  39393. }
  39394. }
  39395. boxOffsetY = chart.inverted ?
  39396. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  39397. // Reset alignOptions property after justify #12337
  39398. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  39399. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  39400. // Set the stackBox position
  39401. stackBox.x -= boxOffsetX;
  39402. stackBox.y -= boxOffsetY;
  39403. // Align the label to the box
  39404. label.align(stackItem.alignOptions, null, stackBox);
  39405. // Check if label is inside the plotArea #12294
  39406. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  39407. label.show();
  39408. }
  39409. else {
  39410. // Move label away to avoid the overlapping issues
  39411. label.alignAttr.y = -9999;
  39412. isJustify = false;
  39413. }
  39414. if (isJustify) {
  39415. // Justify stackLabel into the stackBox
  39416. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  39417. }
  39418. label.attr({
  39419. x: label.alignAttr.x,
  39420. y: label.alignAttr.y
  39421. });
  39422. if (pick(!isJustify && stackItem.options.crop, true)) {
  39423. visible =
  39424. isNumber(label.x) &&
  39425. isNumber(label.y) &&
  39426. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  39427. chart.isInsidePlot(label.x + padding, label.y);
  39428. if (!visible) {
  39429. label.hide();
  39430. }
  39431. }
  39432. }
  39433. };
  39434. /**
  39435. * @private
  39436. * @function Highcharts.StackItem#getStackBox
  39437. *
  39438. * @param {Highcharts.Chart} chart
  39439. *
  39440. * @param {Highcharts.StackItem} stackItem
  39441. *
  39442. * @param {number} x
  39443. *
  39444. * @param {number} y
  39445. *
  39446. * @param {number} xWidth
  39447. *
  39448. * @param {number} h
  39449. *
  39450. * @param {Highcharts.Axis} axis
  39451. *
  39452. * @return {Highcharts.BBoxObject}
  39453. */
  39454. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  39455. var reversed = stackItem.axis.reversed,
  39456. inverted = chart.inverted,
  39457. axisPos = axis.height + axis.pos -
  39458. (inverted ? chart.plotLeft : chart.plotTop),
  39459. neg = (stackItem.isNegative && !reversed) ||
  39460. (!stackItem.isNegative && reversed); // #4056
  39461. return {
  39462. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  39463. x + chart.xAxis[0].transB - chart.plotLeft,
  39464. y: inverted ?
  39465. axis.height - x - xWidth :
  39466. (neg ?
  39467. (axisPos - y - h) :
  39468. axisPos - y),
  39469. width: inverted ? h : xWidth,
  39470. height: inverted ? xWidth : h
  39471. };
  39472. };
  39473. return StackItem;
  39474. }());
  39475. /**
  39476. * Generate stacks for each series and calculate stacks total values
  39477. *
  39478. * @private
  39479. * @function Highcharts.Chart#getStacks
  39480. */
  39481. Chart.prototype.getStacks = function () {
  39482. var chart = this,
  39483. inverted = chart.inverted;
  39484. // reset stacks for each yAxis
  39485. chart.yAxis.forEach(function (axis) {
  39486. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  39487. axis.stacking.oldStacks = axis.stacking.stacks;
  39488. }
  39489. });
  39490. chart.series.forEach(function (series) {
  39491. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  39492. if (series.options.stacking &&
  39493. (series.visible === true ||
  39494. chart.options.chart.ignoreHiddenSeries === false)) {
  39495. series.stackKey = [
  39496. series.type,
  39497. pick(series.options.stack, ''),
  39498. inverted ? xAxisOptions.top : xAxisOptions.left,
  39499. inverted ? xAxisOptions.height : xAxisOptions.width
  39500. ].join(',');
  39501. }
  39502. });
  39503. };
  39504. // Stacking methods defined on the Axis prototype
  39505. StackingAxis.compose(Axis);
  39506. // Stacking methods defined for Series prototype
  39507. /**
  39508. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  39509. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  39510. * to handle grouping of points within the same category.
  39511. *
  39512. * @private
  39513. * @function Highcharts.Series#setStackedPoints
  39514. * @return {void}
  39515. */
  39516. Series.prototype.setGroupedPoints = function () {
  39517. var stacking = this.yAxis.stacking;
  39518. if (this.options.centerInCategory &&
  39519. (this.is('column') || this.is('columnrange')) &&
  39520. // With stacking enabled, we already have stacks that we can compute
  39521. // from
  39522. !this.options.stacking &&
  39523. // With only one series, we don't need to consider centerInCategory
  39524. this.chart.series.length > 1) {
  39525. Series.prototype.setStackedPoints.call(this, 'group');
  39526. // After updating, if we now have proper stacks, we must delete the group
  39527. // pseudo stacks (#14986)
  39528. }
  39529. else if (stacking) {
  39530. objectEach(stacking.stacks, function (type, key) {
  39531. if (key.slice(-5) === 'group') {
  39532. objectEach(type, function (stack) { return stack.destroy(); });
  39533. delete stacking.stacks[key];
  39534. }
  39535. });
  39536. }
  39537. };
  39538. /**
  39539. * Adds series' points value to corresponding stack
  39540. *
  39541. * @private
  39542. * @function Highcharts.Series#setStackedPoints
  39543. */
  39544. Series.prototype.setStackedPoints = function (stackingParam) {
  39545. var stacking = stackingParam || this.options.stacking;
  39546. if (!stacking || (this.visible !== true &&
  39547. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  39548. return;
  39549. }
  39550. var series = this, xData = series.processedXData, yData = series.processedYData, stackedYData = [], yDataLength = yData.length, seriesOptions = series.options, threshold = seriesOptions.threshold, stackThreshold = pick(seriesOptions.startFromThreshold && threshold, 0), stackOption = seriesOptions.stack, stackKey = stackingParam ? series.type + "," + stacking : series.stackKey, negKey = '-' + stackKey, negStacks = series.negStacks, yAxis = series.yAxis, stacks = yAxis.stacking.stacks, oldStacks = yAxis.stacking.oldStacks, stackIndicator, isNegative, stack, other, key, pointKey, i, x, y;
  39551. yAxis.stacking.stacksTouched += 1;
  39552. // loop over the non-null y values and read them into a local array
  39553. for (i = 0; i < yDataLength; i++) {
  39554. x = xData[i];
  39555. y = yData[i];
  39556. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  39557. pointKey = stackIndicator.key;
  39558. // Read stacked values into a stack based on the x value,
  39559. // the sign of y and the stack key. Stacking is also handled for null
  39560. // values (#739)
  39561. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  39562. key = isNegative ? negKey : stackKey;
  39563. // Create empty object for this stack if it doesn't exist yet
  39564. if (!stacks[key]) {
  39565. stacks[key] =
  39566. {};
  39567. }
  39568. // Initialize StackItem for this x
  39569. if (!stacks[key][x]) {
  39570. if (oldStacks[key] &&
  39571. oldStacks[key][x]) {
  39572. stacks[key][x] = oldStacks[key][x];
  39573. stacks[key][x].total = null;
  39574. }
  39575. else {
  39576. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  39577. }
  39578. }
  39579. // If the StackItem doesn't exist, create it first
  39580. stack = stacks[key][x];
  39581. if (y !== null) {
  39582. stack.points[pointKey] = stack.points[series.index] =
  39583. [pick(stack.cumulative, stackThreshold)];
  39584. // Record the base of the stack
  39585. if (!defined(stack.cumulative)) {
  39586. stack.base = pointKey;
  39587. }
  39588. stack.touched = yAxis.stacking.stacksTouched;
  39589. // In area charts, if there are multiple points on the same X value,
  39590. // let the area fill the full span of those points
  39591. if (stackIndicator.index > 0 && series.singleStacks === false) {
  39592. stack.points[pointKey][0] =
  39593. stack.points[series.index + ',' + x + ',0'][0];
  39594. }
  39595. // When updating to null, reset the point stack (#7493)
  39596. }
  39597. else {
  39598. stack.points[pointKey] = stack.points[series.index] =
  39599. null;
  39600. }
  39601. // Add value to the stack total
  39602. if (stacking === 'percent') {
  39603. // Percent stacked column, totals are the same for the positive and
  39604. // negative stacks
  39605. other = isNegative ? stackKey : negKey;
  39606. if (negStacks && stacks[other] && stacks[other][x]) {
  39607. other = stacks[other][x];
  39608. stack.total = other.total =
  39609. Math.max(other.total, stack.total) +
  39610. Math.abs(y) ||
  39611. 0;
  39612. // Percent stacked areas
  39613. }
  39614. else {
  39615. stack.total =
  39616. correctFloat(stack.total + (Math.abs(y) || 0));
  39617. }
  39618. }
  39619. else if (stacking === 'group') {
  39620. if (isArray(y)) {
  39621. y = y[0];
  39622. }
  39623. // In this stack, the total is the number of valid points
  39624. if (y !== null) {
  39625. stack.total = (stack.total || 0) + 1;
  39626. }
  39627. }
  39628. else {
  39629. stack.total = correctFloat(stack.total + (y || 0));
  39630. }
  39631. if (stacking === 'group') {
  39632. // This point's index within the stack, pushed to stack.points[1]
  39633. stack.cumulative = (stack.total || 1) - 1;
  39634. }
  39635. else {
  39636. stack.cumulative =
  39637. pick(stack.cumulative, stackThreshold) + (y || 0);
  39638. }
  39639. if (y !== null) {
  39640. stack.points[pointKey].push(stack.cumulative);
  39641. stackedYData[i] = stack.cumulative;
  39642. stack.hasValidPoints = true;
  39643. }
  39644. }
  39645. if (stacking === 'percent') {
  39646. yAxis.stacking.usePercentage = true;
  39647. }
  39648. if (stacking !== 'group') {
  39649. this.stackedYData = stackedYData; // To be used in getExtremes
  39650. }
  39651. // Reset old stacks
  39652. yAxis.stacking.oldStacks = {};
  39653. };
  39654. /**
  39655. * Iterate over all stacks and compute the absolute values to percent
  39656. *
  39657. * @private
  39658. * @function Highcharts.Series#modifyStacks
  39659. */
  39660. Series.prototype.modifyStacks = function () {
  39661. var series = this,
  39662. yAxis = series.yAxis,
  39663. stackKey = series.stackKey,
  39664. stacks = yAxis.stacking.stacks,
  39665. processedXData = series.processedXData,
  39666. stackIndicator,
  39667. stacking = series.options.stacking;
  39668. if (series[stacking + 'Stacker']) { // Modifier function exists
  39669. [stackKey, '-' + stackKey].forEach(function (key) {
  39670. var i = processedXData.length,
  39671. x,
  39672. stack,
  39673. pointExtremes;
  39674. while (i--) {
  39675. x = processedXData[i];
  39676. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  39677. stack = stacks[key] && stacks[key][x];
  39678. pointExtremes =
  39679. stack && stack.points[stackIndicator.key];
  39680. if (pointExtremes) {
  39681. series[stacking + 'Stacker'](pointExtremes, stack, i);
  39682. }
  39683. }
  39684. });
  39685. }
  39686. };
  39687. /**
  39688. * Modifier function for percent stacks. Blows up the stack to 100%.
  39689. *
  39690. * @private
  39691. * @function Highcharts.Series#percentStacker
  39692. */
  39693. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  39694. var totalFactor = stack.total ? 100 / stack.total : 0;
  39695. // Y bottom value
  39696. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  39697. // Y value
  39698. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  39699. this.stackedYData[i] = pointExtremes[1];
  39700. };
  39701. /**
  39702. * Get stack indicator, according to it's x-value, to determine points with the
  39703. * same x-value
  39704. *
  39705. * @private
  39706. * @function Highcharts.Series#getStackIndicator
  39707. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  39708. * @param {number} x
  39709. * @param {number} index
  39710. * @param {string} [key]
  39711. * @return {Highcharts.StackItemIndicatorObject}
  39712. */
  39713. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  39714. // Update stack indicator, when:
  39715. // first point in a stack || x changed || stack type (negative vs positive)
  39716. // changed:
  39717. if (!defined(stackIndicator) ||
  39718. stackIndicator.x !== x ||
  39719. (key && stackIndicator.key !== key)) {
  39720. stackIndicator = {
  39721. x: x,
  39722. index: 0,
  39723. key: key
  39724. };
  39725. }
  39726. else {
  39727. (stackIndicator).index++;
  39728. }
  39729. stackIndicator.key =
  39730. [index, x, stackIndicator.index].join(',');
  39731. return stackIndicator;
  39732. };
  39733. H.StackItem = StackItem;
  39734. return H.StackItem;
  39735. });
  39736. _registerModule(_modules, 'Series/Line/LineSeries.js', [_modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (palette, Series, SeriesRegistry, U) {
  39737. /* *
  39738. *
  39739. * (c) 2010-2021 Torstein Honsi
  39740. *
  39741. * License: www.highcharts.com/license
  39742. *
  39743. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39744. *
  39745. * */
  39746. var __extends = (this && this.__extends) || (function () {
  39747. var extendStatics = function (d,
  39748. b) {
  39749. extendStatics = Object.setPrototypeOf ||
  39750. ({ __proto__: [] } instanceof Array && function (d,
  39751. b) { d.__proto__ = b; }) ||
  39752. function (d,
  39753. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39754. return extendStatics(d, b);
  39755. };
  39756. return function (d, b) {
  39757. extendStatics(d, b);
  39758. function __() { this.constructor = d; }
  39759. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39760. };
  39761. })();
  39762. var defined = U.defined,
  39763. merge = U.merge;
  39764. /* *
  39765. *
  39766. * Class
  39767. *
  39768. * */
  39769. /**
  39770. * The line series is the base type and is therefor the series base prototype.
  39771. *
  39772. * @private
  39773. */
  39774. var LineSeries = /** @class */ (function (_super) {
  39775. __extends(LineSeries, _super);
  39776. function LineSeries() {
  39777. /* *
  39778. *
  39779. * Static Functions
  39780. *
  39781. * */
  39782. var _this = _super !== null && _super.apply(this,
  39783. arguments) || this;
  39784. /* *
  39785. *
  39786. * Properties
  39787. *
  39788. * */
  39789. _this.data = void 0;
  39790. _this.options = void 0;
  39791. _this.points = void 0;
  39792. return _this;
  39793. }
  39794. /* *
  39795. *
  39796. * Functions
  39797. *
  39798. * */
  39799. /**
  39800. * Draw the graph. Called internally when rendering line-like series
  39801. * types. The first time it generates the `series.graph` item and
  39802. * optionally other series-wide items like `series.area` for area
  39803. * charts. On subsequent calls these items are updated with new
  39804. * positions and attributes.
  39805. *
  39806. * @function Highcharts.Series#drawGraph
  39807. */
  39808. LineSeries.prototype.drawGraph = function () {
  39809. var series = this,
  39810. options = this.options,
  39811. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  39812. styledMode = this.chart.styledMode,
  39813. props = [[
  39814. 'graph',
  39815. 'highcharts-graph'
  39816. ]];
  39817. // Presentational properties
  39818. if (!styledMode) {
  39819. props[0].push((options.lineColor ||
  39820. this.color ||
  39821. palette.neutralColor20 // when colorByPoint = true
  39822. ), options.dashStyle);
  39823. }
  39824. props = series.getZonesGraphs(props);
  39825. // Draw the graph
  39826. props.forEach(function (prop, i) {
  39827. var graphKey = prop[0],
  39828. graph = series[graphKey],
  39829. verb = graph ? 'animate' : 'attr',
  39830. attribs;
  39831. if (graph) {
  39832. graph.endX = series.preventGraphAnimation ?
  39833. null :
  39834. graphPath.xMap;
  39835. graph.animate({ d: graphPath });
  39836. }
  39837. else if (graphPath.length) { // #1487
  39838. /**
  39839. * SVG element of area-based charts. Can be used for styling
  39840. * purposes. If zones are configured, this element will be
  39841. * hidden and replaced by multiple zone areas, accessible
  39842. * via `series['zone-area-x']` (where x is a number,
  39843. * starting with 0).
  39844. *
  39845. * @name Highcharts.Series#area
  39846. * @type {Highcharts.SVGElement|undefined}
  39847. */
  39848. /**
  39849. * SVG element of line-based charts. Can be used for styling
  39850. * purposes. If zones are configured, this element will be
  39851. * hidden and replaced by multiple zone lines, accessible
  39852. * via `series['zone-graph-x']` (where x is a number,
  39853. * starting with 0).
  39854. *
  39855. * @name Highcharts.Series#graph
  39856. * @type {Highcharts.SVGElement|undefined}
  39857. */
  39858. series[graphKey] = graph = series.chart.renderer
  39859. .path(graphPath)
  39860. .addClass(prop[1])
  39861. .attr({ zIndex: 1 }) // #1069
  39862. .add(series.group);
  39863. }
  39864. if (graph && !styledMode) {
  39865. attribs = {
  39866. 'stroke': prop[2],
  39867. 'stroke-width': options.lineWidth,
  39868. // Polygon series use filled graph
  39869. 'fill': (series.fillGraph && series.color) || 'none'
  39870. };
  39871. if (prop[3]) {
  39872. attribs.dashstyle = prop[3];
  39873. }
  39874. else if (options.linecap !== 'square') {
  39875. attribs['stroke-linecap'] =
  39876. attribs['stroke-linejoin'] = 'round';
  39877. }
  39878. graph[verb](attribs)
  39879. // Add shadow to normal series (0) or to first
  39880. // zone (1) #3932
  39881. .shadow((i < 2) && options.shadow);
  39882. }
  39883. // Helpers for animation
  39884. if (graph) {
  39885. graph.startX = graphPath.xMap;
  39886. graph.isArea = graphPath.isArea; // For arearange animation
  39887. }
  39888. });
  39889. };
  39890. // eslint-disable-next-line valid-jsdoc
  39891. /**
  39892. * Get the graph path.
  39893. *
  39894. * @private
  39895. */
  39896. LineSeries.prototype.getGraphPath = function (points, nullsAsZeroes, connectCliffs) {
  39897. var series = this,
  39898. options = series.options,
  39899. step = options.step,
  39900. reversed,
  39901. graphPath = [],
  39902. xMap = [],
  39903. gap;
  39904. points = points || series.points;
  39905. // Bottom of a stack is reversed
  39906. reversed = points.reversed;
  39907. if (reversed) {
  39908. points.reverse();
  39909. }
  39910. // Reverse the steps (#5004)
  39911. step = {
  39912. right: 1,
  39913. center: 2
  39914. }[step] || (step && 3);
  39915. if (step && reversed) {
  39916. step = 4 - step;
  39917. }
  39918. // Remove invalid points, especially in spline (#5015)
  39919. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  39920. // Build the line
  39921. points.forEach(function (point, i) {
  39922. var plotX = point.plotX,
  39923. plotY = point.plotY,
  39924. lastPoint = points[i - 1],
  39925. // the path to this point from the previous
  39926. pathToPoint;
  39927. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  39928. !connectCliffs) {
  39929. gap = true; // ... and continue
  39930. }
  39931. // Line series, nullsAsZeroes is not handled
  39932. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  39933. gap = !options.connectNulls;
  39934. // Area series, nullsAsZeroes is set
  39935. }
  39936. else if (point.isNull && !nullsAsZeroes) {
  39937. gap = true;
  39938. }
  39939. else {
  39940. if (i === 0 || gap) {
  39941. pathToPoint = [[
  39942. 'M',
  39943. point.plotX,
  39944. point.plotY
  39945. ]];
  39946. // Generate the spline as defined in the SplineSeries object
  39947. }
  39948. else if (series.getPointSpline) {
  39949. pathToPoint = [series.getPointSpline(points, point, i)];
  39950. }
  39951. else if (step) {
  39952. if (step === 1) { // right
  39953. pathToPoint = [[
  39954. 'L',
  39955. lastPoint.plotX,
  39956. plotY
  39957. ]];
  39958. }
  39959. else if (step === 2) { // center
  39960. pathToPoint = [[
  39961. 'L',
  39962. (lastPoint.plotX + plotX) / 2,
  39963. lastPoint.plotY
  39964. ], [
  39965. 'L',
  39966. (lastPoint.plotX + plotX) / 2,
  39967. plotY
  39968. ]];
  39969. }
  39970. else {
  39971. pathToPoint = [[
  39972. 'L',
  39973. plotX,
  39974. lastPoint.plotY
  39975. ]];
  39976. }
  39977. pathToPoint.push([
  39978. 'L',
  39979. plotX,
  39980. plotY
  39981. ]);
  39982. }
  39983. else {
  39984. // normal line to next point
  39985. pathToPoint = [[
  39986. 'L',
  39987. plotX,
  39988. plotY
  39989. ]];
  39990. }
  39991. // Prepare for animation. When step is enabled, there are
  39992. // two path nodes for each x value.
  39993. xMap.push(point.x);
  39994. if (step) {
  39995. xMap.push(point.x);
  39996. if (step === 2) { // step = center (#8073)
  39997. xMap.push(point.x);
  39998. }
  39999. }
  40000. graphPath.push.apply(graphPath, pathToPoint);
  40001. gap = false;
  40002. }
  40003. });
  40004. graphPath.xMap = xMap;
  40005. series.graphPath = graphPath;
  40006. return graphPath;
  40007. };
  40008. // eslint-disable-next-line valid-jsdoc
  40009. /**
  40010. * Get zones properties for building graphs. Extendable by series with
  40011. * multiple lines within one series.
  40012. *
  40013. * @private
  40014. */
  40015. LineSeries.prototype.getZonesGraphs = function (props) {
  40016. // Add the zone properties if any
  40017. this.zones.forEach(function (zone, i) {
  40018. var propset = [
  40019. 'zone-graph-' + i,
  40020. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  40021. (zone.className || '')
  40022. ];
  40023. if (!this.chart.styledMode) {
  40024. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  40025. }
  40026. props.push(propset);
  40027. }, this);
  40028. return props;
  40029. };
  40030. /**
  40031. * General options for all series types.
  40032. *
  40033. * @optionparent plotOptions.series
  40034. */
  40035. LineSeries.defaultOptions = merge(Series.defaultOptions, {
  40036. // nothing here yet
  40037. });
  40038. return LineSeries;
  40039. }(Series));
  40040. SeriesRegistry.registerSeriesType('line', LineSeries);
  40041. /* *
  40042. *
  40043. * Default Export
  40044. *
  40045. * */
  40046. /* *
  40047. *
  40048. * API Options
  40049. *
  40050. * */
  40051. /**
  40052. * A line series displays information as a series of data points connected by
  40053. * straight line segments.
  40054. *
  40055. * @sample {highcharts} highcharts/demo/line-basic/
  40056. * Line chart
  40057. * @sample {highstock} stock/demo/basic-line/
  40058. * Line chart
  40059. *
  40060. * @extends plotOptions.series
  40061. * @product highcharts highstock
  40062. * @apioption plotOptions.line
  40063. */
  40064. /**
  40065. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  40066. * of a line graph. Round means that lines are rounded in the ends and
  40067. * bends.
  40068. *
  40069. * @type {Highcharts.SeriesLinecapValue}
  40070. * @default round
  40071. * @since 3.0.7
  40072. * @apioption plotOptions.line.linecap
  40073. */
  40074. /**
  40075. * A `line` series. If the [type](#series.line.type) option is not
  40076. * specified, it is inherited from [chart.type](#chart.type).
  40077. *
  40078. * @extends series,plotOptions.line
  40079. * @excluding dataParser,dataURL
  40080. * @product highcharts highstock
  40081. * @apioption series.line
  40082. */
  40083. /**
  40084. * An array of data points for the series. For the `line` series type,
  40085. * points can be given in the following ways:
  40086. *
  40087. * 1. An array of numerical values. In this case, the numerical values will be
  40088. * interpreted as `y` options. The `x` values will be automatically
  40089. * calculated, either starting at 0 and incremented by 1, or from
  40090. * `pointStart` and `pointInterval` given in the series options. If the axis
  40091. * has categories, these will be used. Example:
  40092. * ```js
  40093. * data: [0, 5, 3, 5]
  40094. * ```
  40095. *
  40096. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40097. * `x,y`. If the first value is a string, it is applied as the name of the
  40098. * point, and the `x` value is inferred.
  40099. * ```js
  40100. * data: [
  40101. * [0, 1],
  40102. * [1, 2],
  40103. * [2, 8]
  40104. * ]
  40105. * ```
  40106. *
  40107. * 3. An array of objects with named values. The following snippet shows only a
  40108. * few settings, see the complete options set below. If the total number of
  40109. * data points exceeds the series'
  40110. * [turboThreshold](#series.line.turboThreshold),
  40111. * this option is not available.
  40112. * ```js
  40113. * data: [{
  40114. * x: 1,
  40115. * y: 9,
  40116. * name: "Point2",
  40117. * color: "#00FF00"
  40118. * }, {
  40119. * x: 1,
  40120. * y: 6,
  40121. * name: "Point1",
  40122. * color: "#FF00FF"
  40123. * }]
  40124. * ```
  40125. *
  40126. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  40127. * additional declaration to allow custom data types:
  40128. * ```ts
  40129. * declare module `highcharts` {
  40130. * interface PointOptionsObject {
  40131. * custom: Record<string, (boolean|number|string)>;
  40132. * }
  40133. * }
  40134. * ```
  40135. *
  40136. * @sample {highcharts} highcharts/chart/reflow-true/
  40137. * Numerical values
  40138. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40139. * Arrays of numeric x and y
  40140. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40141. * Arrays of datetime x and y
  40142. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40143. * Arrays of point.name and y
  40144. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40145. * Config objects
  40146. *
  40147. * @declare Highcharts.PointOptionsObject
  40148. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40149. * @apioption series.line.data
  40150. */
  40151. /**
  40152. * An additional, individual class name for the data point's graphic
  40153. * representation.
  40154. *
  40155. * @type {string}
  40156. * @since 5.0.0
  40157. * @product highcharts gantt
  40158. * @apioption series.line.data.className
  40159. */
  40160. /**
  40161. * Individual color for the point. By default the color is pulled from
  40162. * the global `colors` array.
  40163. *
  40164. * In styled mode, the `color` option doesn't take effect. Instead, use
  40165. * `colorIndex`.
  40166. *
  40167. * @sample {highcharts} highcharts/point/color/
  40168. * Mark the highest point
  40169. *
  40170. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40171. * @product highcharts highstock gantt
  40172. * @apioption series.line.data.color
  40173. */
  40174. /**
  40175. * A specific color index to use for the point, so its graphic representations
  40176. * are given the class name `highcharts-color-{n}`. In styled mode this will
  40177. * change the color of the graphic. In non-styled mode, the color by is set by
  40178. * the `fill` attribute, so the change in class name won't have a visual effect
  40179. * by default.
  40180. *
  40181. * @type {number}
  40182. * @since 5.0.0
  40183. * @product highcharts gantt
  40184. * @apioption series.line.data.colorIndex
  40185. */
  40186. /**
  40187. * A reserved subspace to store options and values for customized functionality.
  40188. * Here you can add additional data for your own event callbacks and formatter
  40189. * callbacks.
  40190. *
  40191. * @sample {highcharts} highcharts/point/custom/
  40192. * Point and series with custom data
  40193. *
  40194. * @type {Highcharts.Dictionary<*>}
  40195. * @apioption series.line.data.custom
  40196. */
  40197. /**
  40198. * Individual data label for each point. The options are the same as
  40199. * the ones for [plotOptions.series.dataLabels](
  40200. * #plotOptions.series.dataLabels).
  40201. *
  40202. * @sample highcharts/point/datalabels/
  40203. * Show a label for the last value
  40204. *
  40205. * @declare Highcharts.DataLabelsOptions
  40206. * @extends plotOptions.line.dataLabels
  40207. * @product highcharts highstock gantt
  40208. * @apioption series.line.data.dataLabels
  40209. */
  40210. /**
  40211. * A description of the point to add to the screen reader information
  40212. * about the point.
  40213. *
  40214. * @type {string}
  40215. * @since 5.0.0
  40216. * @requires modules/accessibility
  40217. * @apioption series.line.data.description
  40218. */
  40219. /**
  40220. * An id for the point. This can be used after render time to get a
  40221. * pointer to the point object through `chart.get()`.
  40222. *
  40223. * @sample {highcharts} highcharts/point/id/
  40224. * Remove an id'd point
  40225. *
  40226. * @type {string}
  40227. * @since 1.2.0
  40228. * @product highcharts highstock gantt
  40229. * @apioption series.line.data.id
  40230. */
  40231. /**
  40232. * The rank for this point's data label in case of collision. If two
  40233. * data labels are about to overlap, only the one with the highest `labelrank`
  40234. * will be drawn.
  40235. *
  40236. * @type {number}
  40237. * @apioption series.line.data.labelrank
  40238. */
  40239. /**
  40240. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  40241. *
  40242. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  40243. *
  40244. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40245. * Point names
  40246. *
  40247. * @type {string}
  40248. * @apioption series.line.data.name
  40249. */
  40250. /**
  40251. * Whether the data point is selected initially.
  40252. *
  40253. * @type {boolean}
  40254. * @default false
  40255. * @product highcharts highstock gantt
  40256. * @apioption series.line.data.selected
  40257. */
  40258. /**
  40259. * The x value of the point. For datetime axes, the X value is the timestamp
  40260. * in milliseconds since 1970.
  40261. *
  40262. * @type {number}
  40263. * @product highcharts highstock
  40264. * @apioption series.line.data.x
  40265. */
  40266. /**
  40267. * The y value of the point.
  40268. *
  40269. * @type {number|null}
  40270. * @product highcharts highstock
  40271. * @apioption series.line.data.y
  40272. */
  40273. /**
  40274. * The individual point events.
  40275. *
  40276. * @extends plotOptions.series.point.events
  40277. * @product highcharts highstock gantt
  40278. * @apioption series.line.data.events
  40279. */
  40280. /**
  40281. * Options for the point markers of line-like series.
  40282. *
  40283. * @declare Highcharts.PointMarkerOptionsObject
  40284. * @extends plotOptions.series.marker
  40285. * @product highcharts highstock
  40286. * @apioption series.line.data.marker
  40287. */
  40288. ''; // include precedent doclets in transpilat
  40289. return LineSeries;
  40290. });
  40291. _registerModule(_modules, 'Series/Area/AreaSeries.js', [_modules['Core/Color/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Color, LegendSymbolMixin, SeriesRegistry, U) {
  40292. /* *
  40293. *
  40294. * (c) 2010-2021 Torstein Honsi
  40295. *
  40296. * License: www.highcharts.com/license
  40297. *
  40298. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40299. *
  40300. * */
  40301. var __extends = (this && this.__extends) || (function () {
  40302. var extendStatics = function (d,
  40303. b) {
  40304. extendStatics = Object.setPrototypeOf ||
  40305. ({ __proto__: [] } instanceof Array && function (d,
  40306. b) { d.__proto__ = b; }) ||
  40307. function (d,
  40308. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40309. return extendStatics(d, b);
  40310. };
  40311. return function (d, b) {
  40312. extendStatics(d, b);
  40313. function __() { this.constructor = d; }
  40314. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40315. };
  40316. })();
  40317. var color = Color.parse;
  40318. var LineSeries = SeriesRegistry.seriesTypes.line;
  40319. var extend = U.extend,
  40320. merge = U.merge,
  40321. objectEach = U.objectEach,
  40322. pick = U.pick;
  40323. /* *
  40324. *
  40325. * Class
  40326. *
  40327. * */
  40328. /**
  40329. * Area series type.
  40330. *
  40331. * @private
  40332. * @class
  40333. * @name AreaSeries
  40334. *
  40335. * @augments LineSeries
  40336. */
  40337. var AreaSeries = /** @class */ (function (_super) {
  40338. __extends(AreaSeries, _super);
  40339. function AreaSeries() {
  40340. /* *
  40341. *
  40342. * Static Properties
  40343. *
  40344. * */
  40345. var _this = _super !== null && _super.apply(this,
  40346. arguments) || this;
  40347. _this.data = void 0;
  40348. _this.options = void 0;
  40349. _this.points = void 0;
  40350. return _this;
  40351. /* eslint-enable valid-jsdoc */
  40352. }
  40353. /* *
  40354. *
  40355. * Functions
  40356. *
  40357. * */
  40358. /* eslint-disable valid-jsdoc */
  40359. /**
  40360. * Draw the graph and the underlying area. This method calls the Series
  40361. * base function and adds the area. The areaPath is calculated in the
  40362. * getSegmentPath method called from Series.prototype.drawGraph.
  40363. * @private
  40364. */
  40365. AreaSeries.prototype.drawGraph = function () {
  40366. // Define or reset areaPath
  40367. this.areaPath = [];
  40368. // Call the base method
  40369. _super.prototype.drawGraph.apply(this);
  40370. // Define local variables
  40371. var series = this,
  40372. areaPath = this.areaPath,
  40373. options = this.options,
  40374. zones = this.zones,
  40375. props = [[
  40376. 'area',
  40377. 'highcharts-area',
  40378. this.color,
  40379. options.fillColor
  40380. ]]; // area name, main color, fill color
  40381. zones.forEach(function (zone,
  40382. i) {
  40383. props.push([
  40384. 'zone-area-' + i,
  40385. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  40386. zone.className,
  40387. zone.color || series.color,
  40388. zone.fillColor || options.fillColor
  40389. ]);
  40390. });
  40391. props.forEach(function (prop) {
  40392. var areaKey = prop[0],
  40393. area = series[areaKey],
  40394. verb = area ? 'animate' : 'attr',
  40395. attribs = {};
  40396. // Create or update the area
  40397. if (area) { // update
  40398. area.endX = series.preventGraphAnimation ?
  40399. null :
  40400. areaPath.xMap;
  40401. area.animate({ d: areaPath });
  40402. }
  40403. else { // create
  40404. attribs.zIndex = 0; // #1069
  40405. area = series[areaKey] = series.chart.renderer
  40406. .path(areaPath)
  40407. .addClass(prop[1])
  40408. .add(series.group);
  40409. area.isArea = true;
  40410. }
  40411. if (!series.chart.styledMode) {
  40412. attribs.fill = pick(prop[3], color(prop[2])
  40413. .setOpacity(pick(options.fillOpacity, 0.75))
  40414. .get());
  40415. }
  40416. area[verb](attribs);
  40417. area.startX = areaPath.xMap;
  40418. area.shiftUnit = options.step ? 2 : 1;
  40419. });
  40420. };
  40421. /**
  40422. * @private
  40423. */
  40424. AreaSeries.prototype.getGraphPath = function (points) {
  40425. var getGraphPath = LineSeries.prototype.getGraphPath, graphPath, options = this.options, stacking = options.stacking, yAxis = this.yAxis, topPath, bottomPath, bottomPoints = [], graphPoints = [], seriesIndex = this.index, i, areaPath, plotX, stacks = yAxis.stacking.stacks[this.stackKey], threshold = options.threshold, translatedThreshold = Math.round(// #10909
  40426. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  40427. options.connectNulls, stacking === 'percent'),
  40428. // To display null points in underlying stacked series, this
  40429. // series graph must be broken, and the area also fall down to
  40430. // fill the gap left by the null point. #2069
  40431. addDummyPoints = function (i, otherI, side) {
  40432. var point = points[i], stackedValues = stacking &&
  40433. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  40434. if (cliffVal || nullVal) {
  40435. top = (nullVal ?
  40436. stackedValues[0] :
  40437. stackedValues[1]) + cliffVal;
  40438. bottom = stackedValues[0] + cliffVal;
  40439. isNull = !!nullVal;
  40440. }
  40441. else if (!stacking &&
  40442. points[otherI] &&
  40443. points[otherI].isNull) {
  40444. top = bottom = threshold;
  40445. }
  40446. // Add to the top and bottom line of the area
  40447. if (typeof top !== 'undefined') {
  40448. graphPoints.push({
  40449. plotX: plotX,
  40450. plotY: top === null ?
  40451. translatedThreshold :
  40452. yAxis.getThreshold(top),
  40453. isNull: isNull,
  40454. isCliff: true
  40455. });
  40456. bottomPoints.push({
  40457. plotX: plotX,
  40458. plotY: bottom === null ?
  40459. translatedThreshold :
  40460. yAxis.getThreshold(bottom),
  40461. doCurve: false // #1041, gaps in areaspline areas
  40462. });
  40463. }
  40464. };
  40465. // Find what points to use
  40466. points = points || this.points;
  40467. // Fill in missing points
  40468. if (stacking) {
  40469. points = this.getStackPoints(points);
  40470. }
  40471. for (i = 0; i < points.length; i++) {
  40472. // Reset after series.update of stacking property (#12033)
  40473. if (!stacking) {
  40474. points[i].leftCliff = points[i].rightCliff =
  40475. points[i].leftNull = points[i].rightNull = void 0;
  40476. }
  40477. isNull = points[i].isNull;
  40478. plotX = pick(points[i].rectPlotX, points[i].plotX);
  40479. yBottom = stacking ? pick(points[i].yBottom, translatedThreshold) : translatedThreshold;
  40480. if (!isNull || connectNulls) {
  40481. if (!connectNulls) {
  40482. addDummyPoints(i, i - 1, 'left');
  40483. }
  40484. // Skip null point when stacking is false and connectNulls
  40485. // true
  40486. if (!(isNull && !stacking && connectNulls)) {
  40487. graphPoints.push(points[i]);
  40488. bottomPoints.push({
  40489. x: i,
  40490. plotX: plotX,
  40491. plotY: yBottom
  40492. });
  40493. }
  40494. if (!connectNulls) {
  40495. addDummyPoints(i, i + 1, 'right');
  40496. }
  40497. }
  40498. }
  40499. topPath = getGraphPath.call(this, graphPoints, true, true);
  40500. bottomPoints.reversed = true;
  40501. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  40502. var firstBottomPoint = bottomPath[0];
  40503. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  40504. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  40505. }
  40506. areaPath = topPath.concat(bottomPath);
  40507. if (areaPath.length) {
  40508. areaPath.push(['Z']);
  40509. }
  40510. // TODO: don't set leftCliff and rightCliff when connectNulls?
  40511. graphPath = getGraphPath
  40512. .call(this, graphPoints, false, connectNulls);
  40513. areaPath.xMap = topPath.xMap;
  40514. this.areaPath = areaPath;
  40515. return graphPath;
  40516. };
  40517. /**
  40518. * Return an array of stacked points, where null and missing points are
  40519. * replaced by dummy points in order for gaps to be drawn correctly in
  40520. * stacks.
  40521. * @private
  40522. */
  40523. AreaSeries.prototype.getStackPoints = function (points) {
  40524. var series = this,
  40525. segment = [],
  40526. keys = [],
  40527. xAxis = this.xAxis,
  40528. yAxis = this.yAxis,
  40529. stack = yAxis.stacking.stacks[this.stackKey],
  40530. pointMap = {},
  40531. yAxisSeries = yAxis.series,
  40532. seriesLength = yAxisSeries.length,
  40533. upOrDown = yAxis.options.reversedStacks ? 1 : -1,
  40534. seriesIndex = yAxisSeries.indexOf(series);
  40535. points = points || this.points;
  40536. if (this.options.stacking) {
  40537. for (var i = 0; i < points.length; i++) {
  40538. // Reset after point update (#7326)
  40539. points[i].leftNull = points[i].rightNull = void 0;
  40540. // Create a map where we can quickly look up the points by
  40541. // their X values.
  40542. pointMap[points[i].x] = points[i];
  40543. }
  40544. // Sort the keys (#1651)
  40545. objectEach(stack, function (stackX, x) {
  40546. // nulled after switching between
  40547. // grouping and not (#1651, #2336)
  40548. if (stackX.total !== null) {
  40549. keys.push(x);
  40550. }
  40551. });
  40552. keys.sort(function (a, b) {
  40553. return a - b;
  40554. });
  40555. var visibleSeries_1 = yAxisSeries.map(function (s) { return s.visible; });
  40556. keys.forEach(function (x, idx) {
  40557. var y = 0,
  40558. stackPoint,
  40559. stackedValues;
  40560. if (pointMap[x] && !pointMap[x].isNull) {
  40561. segment.push(pointMap[x]);
  40562. // Find left and right cliff. -1 goes left, 1 goes
  40563. // right.
  40564. [-1, 1].forEach(function (direction) {
  40565. var nullName = direction === 1 ?
  40566. 'rightNull' :
  40567. 'leftNull',
  40568. cliffName = direction === 1 ?
  40569. 'rightCliff' :
  40570. 'leftCliff',
  40571. cliff = 0,
  40572. otherStack = stack[keys[idx + direction]];
  40573. // If there is a stack next to this one,
  40574. // to the left or to the right...
  40575. if (otherStack) {
  40576. var i = seriesIndex;
  40577. // Can go either up or down,
  40578. // depending on reversedStacks
  40579. while (i >= 0 && i < seriesLength) {
  40580. var si = yAxisSeries[i].index;
  40581. stackPoint = otherStack.points[si];
  40582. if (!stackPoint) {
  40583. // If the next point in this series
  40584. // is missing, mark the point
  40585. // with point.leftNull or
  40586. // point.rightNull = true.
  40587. if (si === series.index) {
  40588. pointMap[x][nullName] = true;
  40589. // If there are missing points in
  40590. // the next stack in any of the
  40591. // series below this one, we need
  40592. // to substract the missing values
  40593. // and add a hiatus to the left or
  40594. // right.
  40595. }
  40596. else if (visibleSeries_1[i]) {
  40597. stackedValues =
  40598. stack[x].points[si];
  40599. if (stackedValues) {
  40600. cliff -= stackedValues[1] - stackedValues[0];
  40601. }
  40602. }
  40603. }
  40604. // When reversedStacks is true, loop up,
  40605. // else loop down
  40606. i += upOrDown;
  40607. }
  40608. }
  40609. pointMap[x][cliffName] = cliff;
  40610. });
  40611. // There is no point for this X value in this series, so we
  40612. // insert a dummy point in order for the areas to be drawn
  40613. // correctly.
  40614. }
  40615. else {
  40616. // Loop down the stack to find the series below this
  40617. // one that has a value (#1991)
  40618. var i = seriesIndex;
  40619. while (i >= 0 && i < seriesLength) {
  40620. var si = yAxisSeries[i].index;
  40621. stackPoint = stack[x].points[si];
  40622. if (stackPoint) {
  40623. y = stackPoint[1];
  40624. break;
  40625. }
  40626. // When reversedStacks is true, loop up, else loop
  40627. // down
  40628. i += upOrDown;
  40629. }
  40630. y = pick(y, 0);
  40631. y = yAxis.translate(// #6272
  40632. y, 0, 1, 0, 1);
  40633. segment.push({
  40634. isNull: true,
  40635. plotX: xAxis.translate(// #6272
  40636. x, 0, 0, 0, 1),
  40637. x: x,
  40638. plotY: y,
  40639. yBottom: y
  40640. });
  40641. }
  40642. });
  40643. }
  40644. return segment;
  40645. };
  40646. /**
  40647. * The area series type.
  40648. *
  40649. * @sample {highcharts} highcharts/demo/area-basic/
  40650. * Area chart
  40651. * @sample {highstock} stock/demo/area/
  40652. * Area chart
  40653. *
  40654. * @extends plotOptions.line
  40655. * @excluding useOhlcData
  40656. * @product highcharts highstock
  40657. * @optionparent plotOptions.area
  40658. */
  40659. AreaSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  40660. /**
  40661. * @see [fillColor](#plotOptions.area.fillColor)
  40662. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40663. *
  40664. * @apioption plotOptions.area.color
  40665. */
  40666. /**
  40667. * Fill color or gradient for the area. When `null`, the series' `color`
  40668. * is used with the series' `fillOpacity`.
  40669. *
  40670. * In styled mode, the fill color can be set with the `.highcharts-area`
  40671. * class name.
  40672. *
  40673. * @see [color](#plotOptions.area.color)
  40674. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40675. *
  40676. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  40677. * Null by default
  40678. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  40679. * Gradient
  40680. *
  40681. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40682. * @product highcharts highstock
  40683. * @apioption plotOptions.area.fillColor
  40684. */
  40685. /**
  40686. * Fill opacity for the area. When you set an explicit `fillColor`,
  40687. * the `fillOpacity` is not applied. Instead, you should define the
  40688. * opacity in the `fillColor` with an rgba color definition. The
  40689. * `fillOpacity` setting, also the default setting, overrides the alpha
  40690. * component of the `color` setting.
  40691. *
  40692. * In styled mode, the fill opacity can be set with the
  40693. * `.highcharts-area` class name.
  40694. *
  40695. * @see [color](#plotOptions.area.color)
  40696. * @see [fillColor](#plotOptions.area.fillColor)
  40697. *
  40698. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  40699. * Automatic fill color and fill opacity of 0.1
  40700. *
  40701. * @type {number}
  40702. * @default {highcharts} 0.75
  40703. * @default {highstock} 0.75
  40704. * @product highcharts highstock
  40705. * @apioption plotOptions.area.fillOpacity
  40706. */
  40707. /**
  40708. * A separate color for the graph line. By default the line takes the
  40709. * `color` of the series, but the lineColor setting allows setting a
  40710. * separate color for the line without altering the `fillColor`.
  40711. *
  40712. * In styled mode, the line stroke can be set with the
  40713. * `.highcharts-graph` class name.
  40714. *
  40715. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  40716. * Dark gray line
  40717. *
  40718. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40719. * @product highcharts highstock
  40720. * @apioption plotOptions.area.lineColor
  40721. */
  40722. /**
  40723. * A separate color for the negative part of the area.
  40724. *
  40725. * In styled mode, a negative color is set with the
  40726. * `.highcharts-negative` class name.
  40727. *
  40728. * @see [negativeColor](#plotOptions.area.negativeColor)
  40729. *
  40730. * @sample {highcharts} highcharts/css/series-negative-color/
  40731. * Negative color in styled mode
  40732. *
  40733. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40734. * @since 3.0
  40735. * @product highcharts
  40736. * @apioption plotOptions.area.negativeFillColor
  40737. */
  40738. /**
  40739. * Whether the whole area or just the line should respond to mouseover
  40740. * tooltips and other mouse or touch events.
  40741. *
  40742. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  40743. * Display the tooltip when the area is hovered
  40744. *
  40745. * @type {boolean}
  40746. * @default false
  40747. * @since 1.1.6
  40748. * @product highcharts highstock
  40749. * @apioption plotOptions.area.trackByArea
  40750. */
  40751. /**
  40752. * The Y axis value to serve as the base for the area, for
  40753. * distinguishing between values above and below a threshold. The area
  40754. * between the graph and the threshold is filled.
  40755. *
  40756. * * If a number is given, the Y axis will scale to the threshold.
  40757. * * If `null`, the scaling behaves like a line series with fill between
  40758. * the graph and the Y axis minimum.
  40759. * * If `Infinity` or `-Infinity`, the area between the graph and the
  40760. * corresponding Y axis extreme is filled (since v6.1.0).
  40761. *
  40762. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  40763. * A threshold of 100
  40764. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  40765. * A threshold of Infinity
  40766. *
  40767. * @type {number|null}
  40768. * @since 2.0
  40769. * @product highcharts highstock
  40770. */
  40771. threshold: 0
  40772. });
  40773. return AreaSeries;
  40774. }(LineSeries));
  40775. extend(AreaSeries.prototype, {
  40776. singleStacks: false,
  40777. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  40778. });
  40779. SeriesRegistry.registerSeriesType('area', AreaSeries);
  40780. /* *
  40781. *
  40782. * Default Export
  40783. *
  40784. * */
  40785. /* *
  40786. *
  40787. * API Options
  40788. *
  40789. * */
  40790. /**
  40791. * A `area` series. If the [type](#series.area.type) option is not
  40792. * specified, it is inherited from [chart.type](#chart.type).
  40793. *
  40794. * @extends series,plotOptions.area
  40795. * @excluding dataParser, dataURL, useOhlcData
  40796. * @product highcharts highstock
  40797. * @apioption series.area
  40798. */
  40799. /**
  40800. * @see [fillColor](#series.area.fillColor)
  40801. * @see [fillOpacity](#series.area.fillOpacity)
  40802. *
  40803. * @apioption series.area.color
  40804. */
  40805. /**
  40806. * An array of data points for the series. For the `area` series type,
  40807. * points can be given in the following ways:
  40808. *
  40809. * 1. An array of numerical values. In this case, the numerical values will be
  40810. * interpreted as `y` options. The `x` values will be automatically
  40811. * calculated, either starting at 0 and incremented by 1, or from
  40812. * `pointStart` * and `pointInterval` given in the series options. If the
  40813. * axis has categories, these will be used. Example:
  40814. * ```js
  40815. * data: [0, 5, 3, 5]
  40816. * ```
  40817. *
  40818. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40819. * `x,y`. If the first value is a string, it is applied as the name of the
  40820. * point, and the `x` value is inferred.
  40821. * ```js
  40822. * data: [
  40823. * [0, 9],
  40824. * [1, 7],
  40825. * [2, 6]
  40826. * ]
  40827. * ```
  40828. *
  40829. * 3. An array of objects with named values. The following snippet shows only a
  40830. * few settings, see the complete options set below. If the total number of
  40831. * data points exceeds the series'
  40832. * [turboThreshold](#series.area.turboThreshold), this option is not
  40833. * available.
  40834. * ```js
  40835. * data: [{
  40836. * x: 1,
  40837. * y: 9,
  40838. * name: "Point2",
  40839. * color: "#00FF00"
  40840. * }, {
  40841. * x: 1,
  40842. * y: 6,
  40843. * name: "Point1",
  40844. * color: "#FF00FF"
  40845. * }]
  40846. * ```
  40847. *
  40848. * @sample {highcharts} highcharts/chart/reflow-true/
  40849. * Numerical values
  40850. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40851. * Arrays of numeric x and y
  40852. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40853. * Arrays of datetime x and y
  40854. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40855. * Arrays of point.name and y
  40856. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40857. * Config objects
  40858. *
  40859. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40860. * @extends series.line.data
  40861. * @product highcharts highstock
  40862. * @apioption series.area.data
  40863. */
  40864. /**
  40865. * @see [color](#series.area.color)
  40866. * @see [fillOpacity](#series.area.fillOpacity)
  40867. *
  40868. * @apioption series.area.fillColor
  40869. */
  40870. /**
  40871. * @see [color](#series.area.color)
  40872. * @see [fillColor](#series.area.fillColor)
  40873. *
  40874. * @default {highcharts} 0.75
  40875. * @default {highstock} 0.75
  40876. * @apioption series.area.fillOpacity
  40877. */
  40878. ''; // adds doclets above to transpilat
  40879. return AreaSeries;
  40880. });
  40881. _registerModule(_modules, 'Series/Spline/SplineSeries.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  40882. /* *
  40883. *
  40884. * (c) 2010-2021 Torstein Honsi
  40885. *
  40886. * License: www.highcharts.com/license
  40887. *
  40888. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40889. *
  40890. * */
  40891. var __extends = (this && this.__extends) || (function () {
  40892. var extendStatics = function (d,
  40893. b) {
  40894. extendStatics = Object.setPrototypeOf ||
  40895. ({ __proto__: [] } instanceof Array && function (d,
  40896. b) { d.__proto__ = b; }) ||
  40897. function (d,
  40898. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40899. return extendStatics(d, b);
  40900. };
  40901. return function (d, b) {
  40902. extendStatics(d, b);
  40903. function __() { this.constructor = d; }
  40904. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40905. };
  40906. })();
  40907. var LineSeries = SeriesRegistry.seriesTypes.line;
  40908. var merge = U.merge,
  40909. pick = U.pick;
  40910. /**
  40911. * Spline series type.
  40912. *
  40913. * @private
  40914. */
  40915. var SplineSeries = /** @class */ (function (_super) {
  40916. __extends(SplineSeries, _super);
  40917. function SplineSeries() {
  40918. /* *
  40919. *
  40920. * Static Properties
  40921. *
  40922. * */
  40923. var _this = _super !== null && _super.apply(this,
  40924. arguments) || this;
  40925. /* *
  40926. *
  40927. * Properties
  40928. *
  40929. * */
  40930. _this.data = void 0;
  40931. _this.options = void 0;
  40932. _this.points = void 0;
  40933. return _this;
  40934. /* eslint-enable valid-jsdoc */
  40935. }
  40936. /* *
  40937. *
  40938. * Functions
  40939. *
  40940. * */
  40941. /* eslint-disable valid-jsdoc */
  40942. /**
  40943. * Get the spline segment from a given point's previous neighbour to the
  40944. * given point.
  40945. *
  40946. * @private
  40947. * @function Highcharts.seriesTypes.spline#getPointSpline
  40948. *
  40949. * @param {Array<Highcharts.Point>}
  40950. *
  40951. * @param {Highcharts.Point} point
  40952. *
  40953. * @param {number} i
  40954. *
  40955. * @return {Highcharts.SVGPathArray}
  40956. */
  40957. SplineSeries.prototype.getPointSpline = function (points, point, i) {
  40958. var
  40959. // 1 means control points midway between points, 2 means 1/3
  40960. // from the point, 3 is 1/4 etc
  40961. smoothing = 1.5,
  40962. denom = smoothing + 1,
  40963. plotX = point.plotX || 0,
  40964. plotY = point.plotY || 0,
  40965. lastPoint = points[i - 1],
  40966. nextPoint = points[i + 1],
  40967. leftContX,
  40968. leftContY,
  40969. rightContX,
  40970. rightContY,
  40971. ret;
  40972. /**
  40973. * @private
  40974. */
  40975. function doCurve(otherPoint) {
  40976. return otherPoint &&
  40977. !otherPoint.isNull &&
  40978. otherPoint.doCurve !== false &&
  40979. // #6387, area splines next to null:
  40980. !point.isCliff;
  40981. }
  40982. // Find control points
  40983. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  40984. var lastX = lastPoint.plotX || 0,
  40985. lastY = lastPoint.plotY || 0,
  40986. nextX = nextPoint.plotX || 0,
  40987. nextY = nextPoint.plotY || 0,
  40988. correction = 0;
  40989. leftContX = (smoothing * plotX + lastX) / denom;
  40990. leftContY = (smoothing * plotY + lastY) / denom;
  40991. rightContX = (smoothing * plotX + nextX) / denom;
  40992. rightContY = (smoothing * plotY + nextY) / denom;
  40993. // Have the two control points make a straight line through main
  40994. // point
  40995. if (rightContX !== leftContX) { // #5016, division by zero
  40996. correction = (((rightContY - leftContY) *
  40997. (rightContX - plotX)) /
  40998. (rightContX - leftContX) + plotY - rightContY);
  40999. }
  41000. leftContY += correction;
  41001. rightContY += correction;
  41002. // to prevent false extremes, check that control points are
  41003. // between neighbouring points' y values
  41004. if (leftContY > lastY && leftContY > plotY) {
  41005. leftContY = Math.max(lastY, plotY);
  41006. // mirror of left control point
  41007. rightContY = 2 * plotY - leftContY;
  41008. }
  41009. else if (leftContY < lastY && leftContY < plotY) {
  41010. leftContY = Math.min(lastY, plotY);
  41011. rightContY = 2 * plotY - leftContY;
  41012. }
  41013. if (rightContY > nextY && rightContY > plotY) {
  41014. rightContY = Math.max(nextY, plotY);
  41015. leftContY = 2 * plotY - rightContY;
  41016. }
  41017. else if (rightContY < nextY && rightContY < plotY) {
  41018. rightContY = Math.min(nextY, plotY);
  41019. leftContY = 2 * plotY - rightContY;
  41020. }
  41021. // record for drawing in next point
  41022. point.rightContX = rightContX;
  41023. point.rightContY = rightContY;
  41024. }
  41025. // Visualize control points for debugging
  41026. /*
  41027. if (leftContX) {
  41028. this.chart.renderer.circle(
  41029. leftContX + this.chart.plotLeft,
  41030. leftContY + this.chart.plotTop,
  41031. 2
  41032. )
  41033. .attr({
  41034. stroke: 'red',
  41035. 'stroke-width': 2,
  41036. fill: 'none',
  41037. zIndex: 9
  41038. })
  41039. .add();
  41040. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  41041. leftContY + this.chart.plotTop,
  41042. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41043. .attr({
  41044. stroke: 'red',
  41045. 'stroke-width': 2,
  41046. zIndex: 9
  41047. })
  41048. .add();
  41049. }
  41050. if (rightContX) {
  41051. this.chart.renderer.circle(
  41052. rightContX + this.chart.plotLeft,
  41053. rightContY + this.chart.plotTop,
  41054. 2
  41055. )
  41056. .attr({
  41057. stroke: 'green',
  41058. 'stroke-width': 2,
  41059. fill: 'none',
  41060. zIndex: 9
  41061. })
  41062. .add();
  41063. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  41064. rightContY + this.chart.plotTop,
  41065. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41066. .attr({
  41067. stroke: 'green',
  41068. 'stroke-width': 2,
  41069. zIndex: 9
  41070. })
  41071. .add();
  41072. }
  41073. // */
  41074. ret = [
  41075. 'C',
  41076. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  41077. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  41078. pick(leftContX, plotX, 0),
  41079. pick(leftContY, plotY, 0),
  41080. plotX,
  41081. plotY
  41082. ];
  41083. // reset for updating series later
  41084. lastPoint.rightContX = lastPoint.rightContY = void 0;
  41085. return ret;
  41086. };
  41087. /**
  41088. * A spline series is a special type of line series, where the segments
  41089. * between the data points are smoothed.
  41090. *
  41091. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  41092. * Spline chart
  41093. * @sample {highstock} stock/demo/spline/
  41094. * Spline chart
  41095. *
  41096. * @extends plotOptions.series
  41097. * @excluding step, boostThreshold, boostBlending
  41098. * @product highcharts highstock
  41099. * @optionparent plotOptions.spline
  41100. */
  41101. SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
  41102. return SplineSeries;
  41103. }(LineSeries));
  41104. SeriesRegistry.registerSeriesType('spline', SplineSeries);
  41105. /* *
  41106. *
  41107. * Default Export
  41108. *
  41109. * */
  41110. /* *
  41111. *
  41112. * API Options
  41113. *
  41114. * */
  41115. /**
  41116. * A `spline` series. If the [type](#series.spline.type) option is
  41117. * not specified, it is inherited from [chart.type](#chart.type).
  41118. *
  41119. * @extends series,plotOptions.spline
  41120. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41121. * @product highcharts highstock
  41122. * @apioption series.spline
  41123. */
  41124. /**
  41125. * An array of data points for the series. For the `spline` series type,
  41126. * points can be given in the following ways:
  41127. *
  41128. * 1. An array of numerical values. In this case, the numerical values will be
  41129. * interpreted as `y` options. The `x` values will be automatically
  41130. * calculated, either starting at 0 and incremented by 1, or from
  41131. * `pointStart` and `pointInterval` given in the series options. If the axis
  41132. * has categories, these will be used. Example:
  41133. * ```js
  41134. * data: [0, 5, 3, 5]
  41135. * ```
  41136. *
  41137. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41138. * `x,y`. If the first value is a string, it is applied as the name of the
  41139. * point, and the `x` value is inferred.
  41140. * ```js
  41141. * data: [
  41142. * [0, 9],
  41143. * [1, 2],
  41144. * [2, 8]
  41145. * ]
  41146. * ```
  41147. *
  41148. * 3. An array of objects with named values. The following snippet shows only a
  41149. * few settings, see the complete options set below. If the total number of
  41150. * data points exceeds the series'
  41151. * [turboThreshold](#series.spline.turboThreshold),
  41152. * this option is not available.
  41153. * ```js
  41154. * data: [{
  41155. * x: 1,
  41156. * y: 9,
  41157. * name: "Point2",
  41158. * color: "#00FF00"
  41159. * }, {
  41160. * x: 1,
  41161. * y: 0,
  41162. * name: "Point1",
  41163. * color: "#FF00FF"
  41164. * }]
  41165. * ```
  41166. *
  41167. * @sample {highcharts} highcharts/chart/reflow-true/
  41168. * Numerical values
  41169. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41170. * Arrays of numeric x and y
  41171. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41172. * Arrays of datetime x and y
  41173. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41174. * Arrays of point.name and y
  41175. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41176. * Config objects
  41177. *
  41178. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41179. * @extends series.line.data
  41180. * @product highcharts highstock
  41181. * @apioption series.spline.data
  41182. */
  41183. ''; // adds doclets above intro transpilat
  41184. return SplineSeries;
  41185. });
  41186. _registerModule(_modules, 'Series/AreaSpline/AreaSplineSeries.js', [_modules['Series/Area/AreaSeries.js'], _modules['Series/Spline/SplineSeries.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (AreaSeries, SplineSeries, LegendSymbolMixin, SeriesRegistry, U) {
  41187. /* *
  41188. *
  41189. * (c) 2010-2021 Torstein Honsi
  41190. *
  41191. * License: www.highcharts.com/license
  41192. *
  41193. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41194. *
  41195. * */
  41196. var __extends = (this && this.__extends) || (function () {
  41197. var extendStatics = function (d,
  41198. b) {
  41199. extendStatics = Object.setPrototypeOf ||
  41200. ({ __proto__: [] } instanceof Array && function (d,
  41201. b) { d.__proto__ = b; }) ||
  41202. function (d,
  41203. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41204. return extendStatics(d, b);
  41205. };
  41206. return function (d, b) {
  41207. extendStatics(d, b);
  41208. function __() { this.constructor = d; }
  41209. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41210. };
  41211. })();
  41212. var areaProto = AreaSeries.prototype;
  41213. var extend = U.extend,
  41214. merge = U.merge;
  41215. /* *
  41216. *
  41217. * Class
  41218. *
  41219. * */
  41220. /**
  41221. * AreaSpline series type.
  41222. *
  41223. * @private
  41224. * @class
  41225. * @name Highcharts.seriesTypes.areaspline
  41226. *
  41227. * @augments Highcharts.Series
  41228. */
  41229. var AreaSplineSeries = /** @class */ (function (_super) {
  41230. __extends(AreaSplineSeries, _super);
  41231. function AreaSplineSeries() {
  41232. /* *
  41233. *
  41234. * Static properties
  41235. *
  41236. * */
  41237. var _this = _super !== null && _super.apply(this,
  41238. arguments) || this;
  41239. /* *
  41240. *
  41241. * Properties
  41242. *
  41243. * */
  41244. _this.data = void 0;
  41245. _this.points = void 0;
  41246. _this.options = void 0;
  41247. return _this;
  41248. }
  41249. /**
  41250. * The area spline series is an area series where the graph between the
  41251. * points is smoothed into a spline.
  41252. *
  41253. * @sample {highcharts} highcharts/demo/areaspline/
  41254. * Area spline chart
  41255. * @sample {highstock} stock/demo/areaspline/
  41256. * Area spline chart
  41257. *
  41258. * @extends plotOptions.area
  41259. * @excluding step, boostThreshold, boostBlending
  41260. * @product highcharts highstock
  41261. * @apioption plotOptions.areaspline
  41262. */
  41263. /**
  41264. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41265. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41266. *
  41267. * @apioption plotOptions.areaspline.color
  41268. */
  41269. /**
  41270. * @see [color](#plotOptions.areaspline.color)
  41271. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41272. *
  41273. * @apioption plotOptions.areaspline.fillColor
  41274. */
  41275. /**
  41276. * @see [color](#plotOptions.areaspline.color)
  41277. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41278. *
  41279. * @default {highcharts} 0.75
  41280. * @default {highstock} 0.75
  41281. * @apioption plotOptions.areaspline.fillOpacity
  41282. */
  41283. AreaSplineSeries.defaultOptions = merge(SplineSeries.defaultOptions, AreaSeries.defaultOptions);
  41284. return AreaSplineSeries;
  41285. }(SplineSeries));
  41286. extend(AreaSplineSeries.prototype, {
  41287. getGraphPath: areaProto.getGraphPath,
  41288. getStackPoints: areaProto.getStackPoints,
  41289. drawGraph: areaProto.drawGraph,
  41290. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41291. });
  41292. SeriesRegistry.registerSeriesType('areaspline', AreaSplineSeries);
  41293. /* *
  41294. *
  41295. * Default export
  41296. *
  41297. * */
  41298. /**
  41299. * A `areaspline` series. If the [type](#series.areaspline.type) option
  41300. * is not specified, it is inherited from [chart.type](#chart.type).
  41301. *
  41302. *
  41303. * @extends series,plotOptions.areaspline
  41304. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41305. * @product highcharts highstock
  41306. * @apioption series.areaspline
  41307. */
  41308. /**
  41309. * @see [fillColor](#series.areaspline.fillColor)
  41310. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41311. *
  41312. * @apioption series.areaspline.color
  41313. */
  41314. /**
  41315. * An array of data points for the series. For the `areaspline` series
  41316. * type, points can be given in the following ways:
  41317. *
  41318. * 1. An array of numerical values. In this case, the numerical values will be
  41319. * interpreted as `y` options. The `x` values will be automatically
  41320. * calculated, either starting at 0 and incremented by 1, or from
  41321. * `pointStart` and `pointInterval` given in the series options. If the axis
  41322. * has categories, these will be used. Example:
  41323. * ```js
  41324. * data: [0, 5, 3, 5]
  41325. * ```
  41326. *
  41327. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41328. * `x,y`. If the first value is a string, it is applied as the name of the
  41329. * point, and the `x` value is inferred.
  41330. * ```js
  41331. * data: [
  41332. * [0, 10],
  41333. * [1, 9],
  41334. * [2, 3]
  41335. * ]
  41336. * ```
  41337. *
  41338. * 3. An array of objects with named values. The following snippet shows only a
  41339. * few settings, see the complete options set below. If the total number of
  41340. * data points exceeds the series'
  41341. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  41342. * available.
  41343. * ```js
  41344. * data: [{
  41345. * x: 1,
  41346. * y: 4,
  41347. * name: "Point2",
  41348. * color: "#00FF00"
  41349. * }, {
  41350. * x: 1,
  41351. * y: 4,
  41352. * name: "Point1",
  41353. * color: "#FF00FF"
  41354. * }]
  41355. * ```
  41356. *
  41357. * @sample {highcharts} highcharts/chart/reflow-true/
  41358. * Numerical values
  41359. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41360. * Arrays of numeric x and y
  41361. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41362. * Arrays of datetime x and y
  41363. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41364. * Arrays of point.name and y
  41365. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41366. * Config objects
  41367. *
  41368. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41369. * @extends series.line.data
  41370. * @product highcharts highstock
  41371. * @apioption series.areaspline.data
  41372. */
  41373. /**
  41374. * @see [color](#series.areaspline.color)
  41375. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41376. *
  41377. * @apioption series.areaspline.fillColor
  41378. */
  41379. /**
  41380. * @see [color](#series.areaspline.color)
  41381. * @see [fillColor](#series.areaspline.fillColor)
  41382. *
  41383. * @default {highcharts} 0.75
  41384. * @default {highstock} 0.75
  41385. * @apioption series.areaspline.fillOpacity
  41386. */
  41387. ''; // adds doclets above into transpilat
  41388. return AreaSplineSeries;
  41389. });
  41390. _registerModule(_modules, 'Series/Column/ColumnSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, Color, H, LegendSymbolMixin, palette, Series, SeriesRegistry, U) {
  41391. /* *
  41392. *
  41393. * (c) 2010-2021 Torstein Honsi
  41394. *
  41395. * License: www.highcharts.com/license
  41396. *
  41397. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41398. *
  41399. * */
  41400. var __extends = (this && this.__extends) || (function () {
  41401. var extendStatics = function (d,
  41402. b) {
  41403. extendStatics = Object.setPrototypeOf ||
  41404. ({ __proto__: [] } instanceof Array && function (d,
  41405. b) { d.__proto__ = b; }) ||
  41406. function (d,
  41407. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41408. return extendStatics(d, b);
  41409. };
  41410. return function (d, b) {
  41411. extendStatics(d, b);
  41412. function __() { this.constructor = d; }
  41413. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41414. };
  41415. })();
  41416. var animObject = A.animObject;
  41417. var color = Color.parse;
  41418. var hasTouch = H.hasTouch,
  41419. noop = H.noop;
  41420. var clamp = U.clamp,
  41421. css = U.css,
  41422. defined = U.defined,
  41423. extend = U.extend,
  41424. fireEvent = U.fireEvent,
  41425. isArray = U.isArray,
  41426. isNumber = U.isNumber,
  41427. merge = U.merge,
  41428. pick = U.pick,
  41429. objectEach = U.objectEach;
  41430. /**
  41431. * The column series type.
  41432. *
  41433. * @private
  41434. * @class
  41435. * @name Highcharts.seriesTypes.column
  41436. *
  41437. * @augments Highcharts.Series
  41438. */
  41439. var ColumnSeries = /** @class */ (function (_super) {
  41440. __extends(ColumnSeries, _super);
  41441. function ColumnSeries() {
  41442. /* *
  41443. *
  41444. * Static Properties
  41445. *
  41446. * */
  41447. var _this = _super !== null && _super.apply(this,
  41448. arguments) || this;
  41449. /* *
  41450. *
  41451. * Properties
  41452. *
  41453. * */
  41454. _this.borderWidth = void 0;
  41455. _this.data = void 0;
  41456. _this.group = void 0;
  41457. _this.options = void 0;
  41458. _this.points = void 0;
  41459. return _this;
  41460. /* eslint-enable valid-jsdoc */
  41461. }
  41462. /* *
  41463. *
  41464. * Functions
  41465. *
  41466. * */
  41467. /* eslint-disable valid-jsdoc */
  41468. /**
  41469. * Animate the column heights one by one from zero.
  41470. *
  41471. * @private
  41472. * @function Highcharts.seriesTypes.column#animate
  41473. *
  41474. * @param {boolean} init
  41475. * Whether to initialize the animation or run it
  41476. */
  41477. ColumnSeries.prototype.animate = function (init) {
  41478. var series = this,
  41479. yAxis = this.yAxis,
  41480. options = series.options,
  41481. inverted = this.chart.inverted,
  41482. attr = {},
  41483. translateProp = inverted ? 'translateX' : 'translateY',
  41484. translateStart,
  41485. translatedThreshold;
  41486. if (init) {
  41487. attr.scaleY = 0.001;
  41488. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  41489. if (inverted) {
  41490. attr.translateX = translatedThreshold - yAxis.len;
  41491. }
  41492. else {
  41493. attr.translateY = translatedThreshold;
  41494. }
  41495. // apply finnal clipping (used in Highcharts Stock) (#7083)
  41496. // animation is done by scaleY, so cliping is for panes
  41497. if (series.clipBox) {
  41498. series.setClip();
  41499. }
  41500. series.group.attr(attr);
  41501. }
  41502. else { // run the animation
  41503. translateStart = Number(series.group.attr(translateProp));
  41504. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  41505. // Do the scale synchronously to ensure smooth
  41506. // updating (#5030, #7228)
  41507. step: function (val, fx) {
  41508. if (series.group) {
  41509. attr[translateProp] = translateStart +
  41510. fx.pos * (yAxis.pos - translateStart);
  41511. series.group.attr(attr);
  41512. }
  41513. }
  41514. }));
  41515. }
  41516. };
  41517. /**
  41518. * Initialize the series. Extends the basic Series.init method by
  41519. * marking other series of the same type as dirty.
  41520. *
  41521. * @private
  41522. * @function Highcharts.seriesTypes.column#init
  41523. */
  41524. ColumnSeries.prototype.init = function (chart, options) {
  41525. _super.prototype.init.apply(this, arguments);
  41526. var series = this;
  41527. chart = series.chart;
  41528. // if the series is added dynamically, force redraw of other
  41529. // series affected by a new column
  41530. if (chart.hasRendered) {
  41531. chart.series.forEach(function (otherSeries) {
  41532. if (otherSeries.type === series.type) {
  41533. otherSeries.isDirty = true;
  41534. }
  41535. });
  41536. }
  41537. };
  41538. /**
  41539. * Return the width and x offset of the columns adjusted for grouping,
  41540. * groupPadding, pointPadding, pointWidth etc.
  41541. *
  41542. * @private
  41543. * @function Highcharts.seriesTypes.column#getColumnMetrics
  41544. * @return {Highcharts.ColumnMetricsObject}
  41545. */
  41546. ColumnSeries.prototype.getColumnMetrics = function () {
  41547. var series = this,
  41548. options = series.options,
  41549. xAxis = series.xAxis,
  41550. yAxis = series.yAxis,
  41551. reversedStacks = xAxis.options.reversedStacks,
  41552. // Keep backward compatibility: reversed xAxis had reversed
  41553. // stacks
  41554. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  41555. (!xAxis.reversed && reversedStacks),
  41556. stackKey,
  41557. stackGroups = {},
  41558. columnCount = 0;
  41559. // Get the total number of column type series. This is called on
  41560. // every series. Consider moving this logic to a chart.orderStacks()
  41561. // function and call it on init, addSeries and removeSeries
  41562. if (options.grouping === false) {
  41563. columnCount = 1;
  41564. }
  41565. else {
  41566. series.chart.series.forEach(function (otherSeries) {
  41567. var otherYAxis = otherSeries.yAxis,
  41568. otherOptions = otherSeries.options,
  41569. columnIndex;
  41570. if (otherSeries.type === series.type &&
  41571. (otherSeries.visible ||
  41572. !series.chart.options.chart.ignoreHiddenSeries) &&
  41573. yAxis.len === otherYAxis.len &&
  41574. yAxis.pos === otherYAxis.pos) { // #642, #2086
  41575. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  41576. stackKey = otherSeries.stackKey;
  41577. if (typeof stackGroups[stackKey] ===
  41578. 'undefined') {
  41579. stackGroups[stackKey] = columnCount++;
  41580. }
  41581. columnIndex = stackGroups[stackKey];
  41582. }
  41583. else if (otherOptions.grouping !== false) { // #1162
  41584. columnIndex = columnCount++;
  41585. }
  41586. otherSeries.columnIndex = columnIndex;
  41587. }
  41588. });
  41589. }
  41590. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  41591. options.pointRange ||
  41592. xAxis.closestPointRange ||
  41593. xAxis.tickInterval ||
  41594. 1), // #2610
  41595. xAxis.len // #1535
  41596. ),
  41597. groupPadding = categoryWidth * options.groupPadding,
  41598. groupWidth = categoryWidth - 2 * groupPadding,
  41599. pointOffsetWidth = groupWidth / (columnCount || 1),
  41600. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  41601. pick(options.pointWidth,
  41602. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  41603. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  41604. // #1251, #3737
  41605. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  41606. pointXOffset = pointPadding +
  41607. (groupPadding +
  41608. colIndex * pointOffsetWidth -
  41609. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  41610. // Save it for reading in linked series (Error bars particularly)
  41611. series.columnMetrics = {
  41612. width: pointWidth,
  41613. offset: pointXOffset,
  41614. paddedWidth: pointOffsetWidth,
  41615. columnCount: columnCount
  41616. };
  41617. return series.columnMetrics;
  41618. };
  41619. /**
  41620. * Make the columns crisp. The edges are rounded to the nearest full
  41621. * pixel.
  41622. *
  41623. * @private
  41624. * @function Highcharts.seriesTypes.column#crispCol
  41625. */
  41626. ColumnSeries.prototype.crispCol = function (x, y, w, h) {
  41627. var chart = this.chart,
  41628. borderWidth = this.borderWidth,
  41629. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  41630. yCrisp = borderWidth % 2 ? 0.5 : 1,
  41631. right,
  41632. bottom,
  41633. fromTop;
  41634. if (chart.inverted && chart.renderer.isVML) {
  41635. yCrisp += 1;
  41636. }
  41637. // Horizontal. We need to first compute the exact right edge, then
  41638. // round it and compute the width from there.
  41639. if (this.options.crisp) {
  41640. right = Math.round(x + w) + xCrisp;
  41641. x = Math.round(x) + xCrisp;
  41642. w = right - x;
  41643. }
  41644. // Vertical
  41645. bottom = Math.round(y + h) + yCrisp;
  41646. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  41647. y = Math.round(y) + yCrisp;
  41648. h = bottom - y;
  41649. // Top edges are exceptions
  41650. if (fromTop && h) { // #5146
  41651. y -= 1;
  41652. h += 1;
  41653. }
  41654. return {
  41655. x: x,
  41656. y: y,
  41657. width: w,
  41658. height: h
  41659. };
  41660. };
  41661. /**
  41662. * Adjust for missing columns, according to the `centerInCategory`
  41663. * option. Missing columns are either single points or stacks where the
  41664. * point or points are either missing or null.
  41665. *
  41666. * @private
  41667. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  41668. * @param {number} x
  41669. * The x coordinate of the column, left side
  41670. *
  41671. * @param {number} pointWidth
  41672. * The pointWidth, already computed upstream
  41673. *
  41674. * @param {Highcharts.ColumnPoint} point
  41675. * The point instance
  41676. *
  41677. * @param {Highcharts.ColumnMetricsObject} metrics
  41678. * The series-wide column metrics
  41679. *
  41680. * @return {number}
  41681. * The adjusted x position, or the original if not adjusted
  41682. */
  41683. ColumnSeries.prototype.adjustForMissingColumns = function (x, pointWidth, point, metrics) {
  41684. var _this = this;
  41685. var stacking = this.options.stacking;
  41686. if (!point.isNull && metrics.columnCount > 1) {
  41687. var indexInCategory_1 = 0;
  41688. var totalInCategory_1 = 0;
  41689. // Loop over all the stacks on the Y axis. When stacking is
  41690. // enabled, these are real point stacks. When stacking is not
  41691. // enabled, but `centerInCategory` is true, there is one stack
  41692. // handling the grouping of points in each category. This is
  41693. // done in the `setGroupedPoints` function.
  41694. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  41695. if (typeof point.x === 'number') {
  41696. var stackItem = stack[point.x.toString()];
  41697. if (stackItem) {
  41698. var pointValues = stackItem.points[_this.index],
  41699. total = stackItem.total;
  41700. // If true `stacking` is enabled, count the
  41701. // total number of non-null stacks in the
  41702. // category, and note which index this point is
  41703. // within those stacks.
  41704. if (stacking) {
  41705. if (pointValues) {
  41706. indexInCategory_1 = totalInCategory_1;
  41707. }
  41708. if (stackItem.hasValidPoints) {
  41709. totalInCategory_1++;
  41710. }
  41711. // If `stacking` is not enabled, look for the
  41712. // index and total of the `group` stack.
  41713. }
  41714. else if (isArray(pointValues)) {
  41715. indexInCategory_1 = pointValues[1];
  41716. totalInCategory_1 = total || 0;
  41717. }
  41718. }
  41719. }
  41720. });
  41721. // Compute the adjusted x position
  41722. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  41723. pointWidth;
  41724. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  41725. indexInCategory_1 * metrics.paddedWidth;
  41726. }
  41727. return x;
  41728. };
  41729. /**
  41730. * Translate each point to the plot area coordinate system and find
  41731. * shape positions
  41732. *
  41733. * @private
  41734. * @function Highcharts.seriesTypes.column#translate
  41735. */
  41736. ColumnSeries.prototype.translate = function () {
  41737. var series = this,
  41738. chart = series.chart,
  41739. options = series.options,
  41740. dense = series.dense =
  41741. series.closestPointRange * series.xAxis.transA < 2,
  41742. borderWidth = series.borderWidth = pick(options.borderWidth,
  41743. dense ? 0 : 1 // #3635
  41744. ),
  41745. xAxis = series.xAxis,
  41746. yAxis = series.yAxis,
  41747. threshold = options.threshold,
  41748. translatedThreshold = series.translatedThreshold =
  41749. yAxis.getThreshold(threshold),
  41750. minPointLength = pick(options.minPointLength, 5),
  41751. metrics = series.getColumnMetrics(),
  41752. seriesPointWidth = metrics.width,
  41753. // postprocessed for border width
  41754. seriesBarW = series.barW =
  41755. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  41756. seriesXOffset = series.pointXOffset = metrics.offset,
  41757. dataMin = series.dataMin,
  41758. dataMax = series.dataMax;
  41759. if (chart.inverted) {
  41760. translatedThreshold -= 0.5; // #3355
  41761. }
  41762. // When the pointPadding is 0, we want the columns to be packed
  41763. // tightly, so we allow individual columns to have individual sizes.
  41764. // When pointPadding is greater, we strive for equal-width columns
  41765. // (#2694).
  41766. if (options.pointPadding) {
  41767. seriesBarW = Math.ceil(seriesBarW);
  41768. }
  41769. Series.prototype.translate.apply(series);
  41770. // Record the new values
  41771. series.points.forEach(function (point) {
  41772. var yBottom = pick(point.yBottom,
  41773. translatedThreshold),
  41774. safeDistance = 999 + Math.abs(yBottom),
  41775. pointWidth = seriesPointWidth,
  41776. plotX = point.plotX || 0,
  41777. // Don't draw too far outside plot area (#1303, #2241,
  41778. // #4264)
  41779. plotY = clamp(point.plotY, -safeDistance,
  41780. yAxis.len + safeDistance),
  41781. barX = plotX + seriesXOffset,
  41782. barW = seriesBarW,
  41783. barY = Math.min(plotY,
  41784. yBottom),
  41785. up,
  41786. barH = Math.max(plotY,
  41787. yBottom) - barY;
  41788. // Handle options.minPointLength
  41789. if (minPointLength && Math.abs(barH) < minPointLength) {
  41790. barH = minPointLength;
  41791. up = (!yAxis.reversed && !point.negative) ||
  41792. (yAxis.reversed && point.negative);
  41793. // Reverse zeros if there's no positive value in the series
  41794. // in visible range (#7046)
  41795. if (isNumber(threshold) &&
  41796. isNumber(dataMax) &&
  41797. point.y === threshold &&
  41798. dataMax <= threshold &&
  41799. // and if there's room for it (#7311)
  41800. (yAxis.min || 0) < threshold &&
  41801. // if all points are the same value (i.e zero) not draw
  41802. // as negative points (#10646), but only if there's room
  41803. // for it (#14876)
  41804. (dataMin !== dataMax || (yAxis.max || 0) <= threshold)) {
  41805. up = !up;
  41806. }
  41807. // If stacked...
  41808. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  41809. // ...keep position
  41810. yBottom - minPointLength :
  41811. // #1485, #4051
  41812. translatedThreshold -
  41813. (up ? minPointLength : 0));
  41814. }
  41815. // Handle point.options.pointWidth
  41816. // @todo Handle grouping/stacking too. Calculate offset properly
  41817. if (defined(point.options.pointWidth)) {
  41818. pointWidth = barW =
  41819. Math.ceil(point.options.pointWidth);
  41820. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  41821. }
  41822. // Adjust for null or missing points
  41823. if (options.centerInCategory) {
  41824. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  41825. }
  41826. // Cache for access in polar
  41827. point.barX = barX;
  41828. point.pointWidth = pointWidth;
  41829. // Fix the tooltip on center of grouped columns (#1216, #424,
  41830. // #3648)
  41831. point.tooltipPos = chart.inverted ?
  41832. [
  41833. clamp(yAxis.len + yAxis.pos - chart.plotLeft - plotY, yAxis.pos - chart.plotLeft, yAxis.len + yAxis.pos - chart.plotLeft),
  41834. xAxis.len + xAxis.pos - chart.plotTop - barX - barW / 2,
  41835. barH
  41836. ] :
  41837. [
  41838. xAxis.left - chart.plotLeft + barX + barW / 2,
  41839. clamp(plotY + yAxis.pos -
  41840. chart.plotTop, yAxis.pos - chart.plotTop, yAxis.len + yAxis.pos - chart.plotTop),
  41841. barH
  41842. ];
  41843. // Register shape type and arguments to be used in drawPoints
  41844. // Allow shapeType defined on pointClass level
  41845. point.shapeType = series.pointClass.prototype.shapeType || 'rect';
  41846. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  41847. // #3169, drilldown from null must have a position to work
  41848. // from #6585, dataLabel should be placed on xAxis, not
  41849. // floating in the middle of the chart
  41850. [barX, translatedThreshold, barW, 0] :
  41851. [barX, barY, barW, barH]);
  41852. });
  41853. };
  41854. /**
  41855. * Columns have no graph
  41856. *
  41857. * @private
  41858. * @function Highcharts.seriesTypes.column#drawGraph
  41859. */
  41860. ColumnSeries.prototype.drawGraph = function () {
  41861. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  41862. };
  41863. /**
  41864. * Get presentational attributes
  41865. *
  41866. * @private
  41867. * @function Highcharts.seriesTypes.column#pointAttribs
  41868. */
  41869. ColumnSeries.prototype.pointAttribs = function (point, state) {
  41870. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  41871. // set to fill when borderColor null:
  41872. stroke = ((point && point[strokeOption]) ||
  41873. options[strokeOption] ||
  41874. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  41875. options[strokeWidthOption] ||
  41876. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  41877. // Handle zone colors
  41878. if (point && this.zones.length) {
  41879. zone = point.getZone();
  41880. // When zones are present, don't use point.color (#4267).
  41881. // Changed order (#6527), added support for colorAxis (#10670)
  41882. fill = (point.options.color ||
  41883. (zone && (zone.color || point.nonZonedColor)) ||
  41884. this.color);
  41885. if (zone) {
  41886. stroke = zone.borderColor || stroke;
  41887. dashstyle = zone.dashStyle || dashstyle;
  41888. strokeWidth = zone.borderWidth || strokeWidth;
  41889. }
  41890. }
  41891. // Select or hover states
  41892. if (state && point) {
  41893. stateOptions = merge(options.states[state],
  41894. // #6401
  41895. point.options.states &&
  41896. point.options.states[state] ||
  41897. {});
  41898. brightness = stateOptions.brightness;
  41899. fill =
  41900. stateOptions.color || (typeof brightness !== 'undefined' &&
  41901. color(fill)
  41902. .brighten(stateOptions.brightness)
  41903. .get()) || fill;
  41904. stroke = stateOptions[strokeOption] || stroke;
  41905. strokeWidth =
  41906. stateOptions[strokeWidthOption] || strokeWidth;
  41907. dashstyle = stateOptions.dashStyle || dashstyle;
  41908. opacity = pick(stateOptions.opacity, opacity);
  41909. }
  41910. ret = {
  41911. fill: fill,
  41912. stroke: stroke,
  41913. 'stroke-width': strokeWidth,
  41914. opacity: opacity
  41915. };
  41916. if (dashstyle) {
  41917. ret.dashstyle = dashstyle;
  41918. }
  41919. return ret;
  41920. };
  41921. /**
  41922. * Draw the columns. For bars, the series.group is rotated, so the same
  41923. * coordinates apply for columns and bars. This method is inherited by
  41924. * scatter series.
  41925. *
  41926. * @private
  41927. * @function Highcharts.seriesTypes.column#drawPoints
  41928. */
  41929. ColumnSeries.prototype.drawPoints = function () {
  41930. var series = this,
  41931. chart = this.chart,
  41932. options = series.options,
  41933. renderer = chart.renderer,
  41934. animationLimit = options.animationLimit || 250,
  41935. shapeArgs;
  41936. // draw the columns
  41937. series.points.forEach(function (point) {
  41938. var plotY = point.plotY,
  41939. graphic = point.graphic,
  41940. hasGraphic = !!graphic,
  41941. verb = graphic && chart.pointCount < animationLimit ?
  41942. 'animate' : 'attr';
  41943. if (isNumber(plotY) && point.y !== null) {
  41944. shapeArgs = point.shapeArgs;
  41945. // When updating a series between 2d and 3d or cartesian and
  41946. // polar, the shape type changes.
  41947. if (graphic && point.hasNewShapeType()) {
  41948. graphic = graphic.destroy();
  41949. }
  41950. // Set starting position for point sliding animation.
  41951. if (series.enabledDataSorting) {
  41952. point.startXPos = series.xAxis.reversed ?
  41953. -(shapeArgs ? (shapeArgs.width || 0) : 0) :
  41954. series.xAxis.width;
  41955. }
  41956. if (!graphic) {
  41957. point.graphic = graphic =
  41958. renderer[point.shapeType](shapeArgs)
  41959. .add(point.group || series.group);
  41960. if (graphic &&
  41961. series.enabledDataSorting &&
  41962. chart.hasRendered &&
  41963. chart.pointCount < animationLimit) {
  41964. graphic.attr({
  41965. x: point.startXPos
  41966. });
  41967. hasGraphic = true;
  41968. verb = 'animate';
  41969. }
  41970. }
  41971. if (graphic && hasGraphic) { // update
  41972. graphic[verb](merge(shapeArgs));
  41973. }
  41974. // Border radius is not stylable (#6900)
  41975. if (options.borderRadius) {
  41976. graphic[verb]({
  41977. r: options.borderRadius
  41978. });
  41979. }
  41980. // Presentational
  41981. if (!chart.styledMode) {
  41982. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  41983. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  41984. }
  41985. if (graphic) {
  41986. graphic.addClass(point.getClassName(), true);
  41987. graphic.attr({
  41988. visibility: point.visible ? 'inherit' : 'hidden'
  41989. });
  41990. }
  41991. }
  41992. else if (graphic) {
  41993. point.graphic = graphic.destroy(); // #1269
  41994. }
  41995. });
  41996. };
  41997. /**
  41998. * Draw the tracker for a point.
  41999. * @private
  42000. */
  42001. ColumnSeries.prototype.drawTracker = function () {
  42002. var series = this,
  42003. chart = series.chart,
  42004. pointer = chart.pointer,
  42005. onMouseOver = function (e) {
  42006. var point = pointer.getPointFromEvent(e);
  42007. // undefined on graph in scatterchart
  42008. if (typeof point !== 'undefined') {
  42009. pointer.isDirectTouch = true;
  42010. point.onMouseOver(e);
  42011. }
  42012. }, dataLabels;
  42013. // Add reference to the point
  42014. series.points.forEach(function (point) {
  42015. dataLabels = (isArray(point.dataLabels) ?
  42016. point.dataLabels :
  42017. (point.dataLabel ? [point.dataLabel] : []));
  42018. if (point.graphic) {
  42019. point.graphic.element.point = point;
  42020. }
  42021. dataLabels.forEach(function (dataLabel) {
  42022. if (dataLabel.div) {
  42023. dataLabel.div.point = point;
  42024. }
  42025. else {
  42026. dataLabel.element.point = point;
  42027. }
  42028. });
  42029. });
  42030. // Add the event listeners, we need to do this only once
  42031. if (!series._hasTracking) {
  42032. series.trackerGroups.forEach(function (key) {
  42033. if (series[key]) {
  42034. // we don't always have dataLabelsGroup
  42035. series[key]
  42036. .addClass('highcharts-tracker')
  42037. .on('mouseover', onMouseOver)
  42038. .on('mouseout', function (e) {
  42039. pointer.onTrackerMouseOut(e);
  42040. });
  42041. if (hasTouch) {
  42042. series[key].on('touchstart', onMouseOver);
  42043. }
  42044. if (!chart.styledMode && series.options.cursor) {
  42045. series[key]
  42046. .css(css)
  42047. .css({ cursor: series.options.cursor });
  42048. }
  42049. }
  42050. });
  42051. series._hasTracking = true;
  42052. }
  42053. fireEvent(this, 'afterDrawTracker');
  42054. };
  42055. /**
  42056. * Remove this series from the chart
  42057. *
  42058. * @private
  42059. * @function Highcharts.seriesTypes.column#remove
  42060. */
  42061. ColumnSeries.prototype.remove = function () {
  42062. var series = this,
  42063. chart = series.chart;
  42064. // column and bar series affects other series of the same type
  42065. // as they are either stacked or grouped
  42066. if (chart.hasRendered) {
  42067. chart.series.forEach(function (otherSeries) {
  42068. if (otherSeries.type === series.type) {
  42069. otherSeries.isDirty = true;
  42070. }
  42071. });
  42072. }
  42073. Series.prototype.remove.apply(series, arguments);
  42074. };
  42075. /**
  42076. * Column series display one column per value along an X axis.
  42077. *
  42078. * @sample {highcharts} highcharts/demo/column-basic/
  42079. * Column chart
  42080. * @sample {highstock} stock/demo/column/
  42081. * Column chart
  42082. *
  42083. * @extends plotOptions.line
  42084. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  42085. * lineWidth, marker, step, useOhlcData
  42086. * @product highcharts highstock
  42087. * @optionparent plotOptions.column
  42088. */
  42089. ColumnSeries.defaultOptions = merge(Series.defaultOptions, {
  42090. /**
  42091. * The corner radius of the border surrounding each column or bar.
  42092. *
  42093. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  42094. * Rounded columns
  42095. *
  42096. * @product highcharts highstock gantt
  42097. *
  42098. * @private
  42099. */
  42100. borderRadius: 0,
  42101. /**
  42102. * When using automatic point colors pulled from the global
  42103. * [colors](colors) or series-specific
  42104. * [plotOptions.column.colors](series.colors) collections, this option
  42105. * determines whether the chart should receive one color per series or
  42106. * one color per point.
  42107. *
  42108. * In styled mode, the `colors` or `series.colors` arrays are not
  42109. * supported, and instead this option gives the points individual color
  42110. * class names on the form `highcharts-color-{n}`.
  42111. *
  42112. * @see [series colors](#plotOptions.column.colors)
  42113. *
  42114. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  42115. * False by default
  42116. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  42117. * True
  42118. *
  42119. * @type {boolean}
  42120. * @default false
  42121. * @since 2.0
  42122. * @product highcharts highstock gantt
  42123. * @apioption plotOptions.column.colorByPoint
  42124. */
  42125. /**
  42126. * A series specific or series type specific color set to apply instead
  42127. * of the global [colors](#colors) when [colorByPoint](
  42128. * #plotOptions.column.colorByPoint) is true.
  42129. *
  42130. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  42131. * @since 3.0
  42132. * @product highcharts highstock gantt
  42133. * @apioption plotOptions.column.colors
  42134. */
  42135. /**
  42136. * When `true`, the columns will center in the category, ignoring null
  42137. * or missing points. When `false`, space will be reserved for null or
  42138. * missing points.
  42139. *
  42140. * @sample {highcharts} highcharts/series-column/centerincategory/
  42141. * Center in category
  42142. *
  42143. * @since 8.0.1
  42144. * @product highcharts highstock gantt
  42145. *
  42146. * @private
  42147. */
  42148. centerInCategory: false,
  42149. /**
  42150. * Padding between each value groups, in x axis units.
  42151. *
  42152. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  42153. * 0.2 by default
  42154. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  42155. * No group padding - all columns are evenly spaced
  42156. *
  42157. * @product highcharts highstock gantt
  42158. *
  42159. * @private
  42160. */
  42161. groupPadding: 0.2,
  42162. /**
  42163. * Whether to group non-stacked columns or to let them render
  42164. * independent of each other. Non-grouped columns will be laid out
  42165. * individually and overlap each other.
  42166. *
  42167. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  42168. * Grouping disabled
  42169. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  42170. * Grouping disabled
  42171. *
  42172. * @type {boolean}
  42173. * @default true
  42174. * @since 2.3.0
  42175. * @product highcharts highstock gantt
  42176. * @apioption plotOptions.column.grouping
  42177. */
  42178. /**
  42179. * @ignore-option
  42180. * @private
  42181. */
  42182. marker: null,
  42183. /**
  42184. * The maximum allowed pixel width for a column, translated to the
  42185. * height of a bar in a bar chart. This prevents the columns from
  42186. * becoming too wide when there is a small number of points in the
  42187. * chart.
  42188. *
  42189. * @see [pointWidth](#plotOptions.column.pointWidth)
  42190. *
  42191. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  42192. * Limited to 50
  42193. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  42194. * Limited to 50
  42195. *
  42196. * @type {number}
  42197. * @since 4.1.8
  42198. * @product highcharts highstock gantt
  42199. * @apioption plotOptions.column.maxPointWidth
  42200. */
  42201. /**
  42202. * Padding between each column or bar, in x axis units.
  42203. *
  42204. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  42205. * 0.1 by default
  42206. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  42207. * 0.25
  42208. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  42209. * 0 for tightly packed columns
  42210. *
  42211. * @product highcharts highstock gantt
  42212. *
  42213. * @private
  42214. */
  42215. pointPadding: 0.1,
  42216. /**
  42217. * A pixel value specifying a fixed width for each column or bar point.
  42218. * When set to `undefined`, the width is calculated from the
  42219. * `pointPadding` and `groupPadding`. The width effects the dimension
  42220. * that is not based on the point value. For column series it is the
  42221. * hoizontal length and for bar series it is the vertical length.
  42222. *
  42223. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  42224. *
  42225. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  42226. * 20px wide columns regardless of chart width or the amount of
  42227. * data points
  42228. *
  42229. * @type {number}
  42230. * @since 1.2.5
  42231. * @product highcharts highstock gantt
  42232. * @apioption plotOptions.column.pointWidth
  42233. */
  42234. /**
  42235. * A pixel value specifying a fixed width for the column or bar.
  42236. * Overrides pointWidth on the series.
  42237. *
  42238. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42239. *
  42240. * @type {number}
  42241. * @default undefined
  42242. * @since 7.0.0
  42243. * @product highcharts highstock gantt
  42244. * @apioption series.column.data.pointWidth
  42245. */
  42246. /**
  42247. * The minimal height for a column or width for a bar. By default,
  42248. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  42249. * set the minimal point length to a pixel value like 3\. In stacked
  42250. * column charts, minPointLength might not be respected for tightly
  42251. * packed values.
  42252. *
  42253. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  42254. * Zero base value
  42255. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  42256. * Positive and negative close to zero values
  42257. *
  42258. * @product highcharts highstock gantt
  42259. *
  42260. * @private
  42261. */
  42262. minPointLength: 0,
  42263. /**
  42264. * When the series contains less points than the crop threshold, all
  42265. * points are drawn, event if the points fall outside the visible plot
  42266. * area at the current zoom. The advantage of drawing all points
  42267. * (including markers and columns), is that animation is performed on
  42268. * updates. On the other hand, when the series contains more points than
  42269. * the crop threshold, the series data is cropped to only contain points
  42270. * that fall within the plot area. The advantage of cropping away
  42271. * invisible points is to increase performance on large series.
  42272. *
  42273. * @product highcharts highstock gantt
  42274. *
  42275. * @private
  42276. */
  42277. cropThreshold: 50,
  42278. /**
  42279. * The X axis range that each point is valid for. This determines the
  42280. * width of the column. On a categorized axis, the range will be 1
  42281. * by default (one category unit). On linear and datetime axes, the
  42282. * range will be computed as the distance between the two closest data
  42283. * points.
  42284. *
  42285. * The default `null` means it is computed automatically, but this
  42286. * option can be used to override the automatic value.
  42287. *
  42288. * This option is set by default to 1 if data sorting is enabled.
  42289. *
  42290. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  42291. * Set the point range to one day on a data set with one week
  42292. * between the points
  42293. *
  42294. * @type {number|null}
  42295. * @since 2.3
  42296. * @product highcharts highstock gantt
  42297. *
  42298. * @private
  42299. */
  42300. pointRange: null,
  42301. states: {
  42302. /**
  42303. * Options for the hovered point. These settings override the normal
  42304. * state options when a point is moused over or touched.
  42305. *
  42306. * @extends plotOptions.series.states.hover
  42307. * @excluding halo, lineWidth, lineWidthPlus, marker
  42308. * @product highcharts highstock gantt
  42309. */
  42310. hover: {
  42311. /** @ignore-option */
  42312. halo: false,
  42313. /**
  42314. * A specific border color for the hovered point. Defaults to
  42315. * inherit the normal state border color.
  42316. *
  42317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42318. * @product highcharts gantt
  42319. * @apioption plotOptions.column.states.hover.borderColor
  42320. */
  42321. /**
  42322. * A specific color for the hovered point.
  42323. *
  42324. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42325. * @product highcharts gantt
  42326. * @apioption plotOptions.column.states.hover.color
  42327. */
  42328. /**
  42329. * How much to brighten the point on interaction. Requires the
  42330. * main color to be defined in hex or rgb(a) format.
  42331. *
  42332. * In styled mode, the hover brightening is by default replaced
  42333. * with a fill-opacity set in the `.highcharts-point:hover`
  42334. * rule.
  42335. *
  42336. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  42337. * Brighten by 0.5
  42338. *
  42339. * @product highcharts highstock gantt
  42340. */
  42341. brightness: 0.1
  42342. },
  42343. /**
  42344. * Options for the selected point. These settings override the
  42345. * normal state options when a point is selected.
  42346. *
  42347. * @extends plotOptions.series.states.select
  42348. * @excluding halo, lineWidth, lineWidthPlus, marker
  42349. * @product highcharts highstock gantt
  42350. */
  42351. select: {
  42352. /**
  42353. * A specific color for the selected point.
  42354. *
  42355. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42356. * @default #cccccc
  42357. * @product highcharts highstock gantt
  42358. */
  42359. color: palette.neutralColor20,
  42360. /**
  42361. * A specific border color for the selected point.
  42362. *
  42363. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42364. * @default #000000
  42365. * @product highcharts highstock gantt
  42366. */
  42367. borderColor: palette.neutralColor100
  42368. }
  42369. },
  42370. dataLabels: {
  42371. align: void 0,
  42372. verticalAlign: void 0,
  42373. /**
  42374. * The y position offset of the label relative to the point in
  42375. * pixels.
  42376. *
  42377. * @type {number}
  42378. */
  42379. y: void 0
  42380. },
  42381. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  42382. /**
  42383. * @ignore-option
  42384. * @private
  42385. */
  42386. startFromThreshold: true,
  42387. stickyTracking: false,
  42388. tooltip: {
  42389. distance: 6
  42390. },
  42391. /**
  42392. * The Y axis value to serve as the base for the columns, for
  42393. * distinguishing between values above and below a threshold. If `null`,
  42394. * the columns extend from the padding Y axis minimum.
  42395. *
  42396. * @type {number|null}
  42397. * @since 2.0
  42398. * @product highcharts
  42399. *
  42400. * @private
  42401. */
  42402. threshold: 0,
  42403. /**
  42404. * The width of the border surrounding each column or bar. Defaults to
  42405. * `1` when there is room for a border, but to `0` when the columns are
  42406. * so dense that a border would cover the next column.
  42407. *
  42408. * In styled mode, the stroke width can be set with the
  42409. * `.highcharts-point` rule.
  42410. *
  42411. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42412. * 2px black border
  42413. *
  42414. * @type {number}
  42415. * @default undefined
  42416. * @product highcharts highstock gantt
  42417. * @apioption plotOptions.column.borderWidth
  42418. */
  42419. /**
  42420. * The color of the border surrounding each column or bar.
  42421. *
  42422. * In styled mode, the border stroke can be set with the
  42423. * `.highcharts-point` rule.
  42424. *
  42425. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42426. * Dark gray border
  42427. *
  42428. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42429. * @default #ffffff
  42430. * @product highcharts highstock gantt
  42431. *
  42432. * @private
  42433. */
  42434. borderColor: palette.backgroundColor
  42435. });
  42436. return ColumnSeries;
  42437. }(Series));
  42438. extend(ColumnSeries.prototype, {
  42439. cropShoulder: 0,
  42440. // When tooltip is not shared, this series (and derivatives) requires
  42441. // direct touch/hover. KD-tree does not apply.
  42442. directTouch: true,
  42443. /**
  42444. * Use a solid rectangle like the area series types
  42445. *
  42446. * @private
  42447. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  42448. *
  42449. * @param {Highcharts.Legend} legend
  42450. * The legend object
  42451. *
  42452. * @param {Highcharts.Series|Highcharts.Point} item
  42453. * The series (this) or point
  42454. */
  42455. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  42456. getSymbol: noop,
  42457. // use separate negative stacks, unlike area stacks where a negative
  42458. // point is substracted from previous (#1910)
  42459. negStacks: true,
  42460. trackerGroups: ['group', 'dataLabelsGroup']
  42461. });
  42462. SeriesRegistry.registerSeriesType('column', ColumnSeries);
  42463. /* *
  42464. *
  42465. * Export
  42466. *
  42467. * */
  42468. /* *
  42469. *
  42470. * API Declarations
  42471. *
  42472. * */
  42473. /**
  42474. * Adjusted width and x offset of the columns for grouping.
  42475. *
  42476. * @private
  42477. * @interface Highcharts.ColumnMetricsObject
  42478. */ /**
  42479. * Width of the columns.
  42480. * @name Highcharts.ColumnMetricsObject#width
  42481. * @type {number}
  42482. */ /**
  42483. * Offset of the columns.
  42484. * @name Highcharts.ColumnMetricsObject#offset
  42485. * @type {number}
  42486. */
  42487. ''; // detach doclets above
  42488. /* *
  42489. *
  42490. * API Options
  42491. *
  42492. * */
  42493. /**
  42494. * A `column` series. If the [type](#series.column.type) option is
  42495. * not specified, it is inherited from [chart.type](#chart.type).
  42496. *
  42497. * @extends series,plotOptions.column
  42498. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  42499. * lineWidth, marker, connectEnds, step
  42500. * @product highcharts highstock
  42501. * @apioption series.column
  42502. */
  42503. /**
  42504. * An array of data points for the series. For the `column` series type,
  42505. * points can be given in the following ways:
  42506. *
  42507. * 1. An array of numerical values. In this case, the numerical values will be
  42508. * interpreted as `y` options. The `x` values will be automatically
  42509. * calculated, either starting at 0 and incremented by 1, or from
  42510. * `pointStart` and `pointInterval` given in the series options. If the axis
  42511. * has categories, these will be used. Example:
  42512. * ```js
  42513. * data: [0, 5, 3, 5]
  42514. * ```
  42515. *
  42516. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42517. * `x,y`. If the first value is a string, it is applied as the name of the
  42518. * point, and the `x` value is inferred.
  42519. * ```js
  42520. * data: [
  42521. * [0, 6],
  42522. * [1, 2],
  42523. * [2, 6]
  42524. * ]
  42525. * ```
  42526. *
  42527. * 3. An array of objects with named values. The following snippet shows only a
  42528. * few settings, see the complete options set below. If the total number of
  42529. * data points exceeds the series'
  42530. * [turboThreshold](#series.column.turboThreshold), this option is not
  42531. * available.
  42532. * ```js
  42533. * data: [{
  42534. * x: 1,
  42535. * y: 9,
  42536. * name: "Point2",
  42537. * color: "#00FF00"
  42538. * }, {
  42539. * x: 1,
  42540. * y: 6,
  42541. * name: "Point1",
  42542. * color: "#FF00FF"
  42543. * }]
  42544. * ```
  42545. *
  42546. * @sample {highcharts} highcharts/chart/reflow-true/
  42547. * Numerical values
  42548. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42549. * Arrays of numeric x and y
  42550. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42551. * Arrays of datetime x and y
  42552. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42553. * Arrays of point.name and y
  42554. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42555. * Config objects
  42556. *
  42557. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42558. * @extends series.line.data
  42559. * @excluding marker
  42560. * @product highcharts highstock
  42561. * @apioption series.column.data
  42562. */
  42563. /**
  42564. * The color of the border surrounding the column or bar.
  42565. *
  42566. * In styled mode, the border stroke can be set with the `.highcharts-point`
  42567. * rule.
  42568. *
  42569. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42570. * Dark gray border
  42571. *
  42572. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42573. * @product highcharts highstock
  42574. * @apioption series.column.data.borderColor
  42575. */
  42576. /**
  42577. * The width of the border surrounding the column or bar.
  42578. *
  42579. * In styled mode, the stroke width can be set with the `.highcharts-point`
  42580. * rule.
  42581. *
  42582. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42583. * 2px black border
  42584. *
  42585. * @type {number}
  42586. * @product highcharts highstock
  42587. * @apioption series.column.data.borderWidth
  42588. */
  42589. /**
  42590. * A name for the dash style to use for the column or bar. Overrides
  42591. * dashStyle on the series.
  42592. *
  42593. * In styled mode, the stroke dash-array can be set with the same classes as
  42594. * listed under [data.color](#series.column.data.color).
  42595. *
  42596. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  42597. *
  42598. * @type {Highcharts.DashStyleValue}
  42599. * @apioption series.column.data.dashStyle
  42600. */
  42601. /**
  42602. * A pixel value specifying a fixed width for the column or bar. Overrides
  42603. * pointWidth on the series. The width effects the dimension that is not based
  42604. * on the point value.
  42605. *
  42606. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42607. *
  42608. * @type {number}
  42609. * @apioption series.column.data.pointWidth
  42610. */
  42611. /**
  42612. * @excluding halo, lineWidth, lineWidthPlus, marker
  42613. * @product highcharts highstock
  42614. * @apioption series.column.states.hover
  42615. */
  42616. /**
  42617. * @excluding halo, lineWidth, lineWidthPlus, marker
  42618. * @product highcharts highstock
  42619. * @apioption series.column.states.select
  42620. */
  42621. ''; // includes above doclets in transpilat
  42622. return ColumnSeries;
  42623. });
  42624. _registerModule(_modules, 'Series/Bar/BarSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  42625. /* *
  42626. *
  42627. * (c) 2010-2021 Torstein Honsi
  42628. *
  42629. * License: www.highcharts.com/license
  42630. *
  42631. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42632. *
  42633. * */
  42634. var __extends = (this && this.__extends) || (function () {
  42635. var extendStatics = function (d,
  42636. b) {
  42637. extendStatics = Object.setPrototypeOf ||
  42638. ({ __proto__: [] } instanceof Array && function (d,
  42639. b) { d.__proto__ = b; }) ||
  42640. function (d,
  42641. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42642. return extendStatics(d, b);
  42643. };
  42644. return function (d, b) {
  42645. extendStatics(d, b);
  42646. function __() { this.constructor = d; }
  42647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42648. };
  42649. })();
  42650. var extend = U.extend,
  42651. merge = U.merge;
  42652. /* *
  42653. *
  42654. * Class
  42655. *
  42656. * */
  42657. /**
  42658. * Bar series type.
  42659. *
  42660. * @private
  42661. * @class
  42662. * @name Highcharts.seriesTypes.bar
  42663. *
  42664. * @augments Highcharts.Series
  42665. */
  42666. var BarSeries = /** @class */ (function (_super) {
  42667. __extends(BarSeries, _super);
  42668. function BarSeries() {
  42669. /* *
  42670. *
  42671. * Static Properties
  42672. *
  42673. * */
  42674. var _this = _super !== null && _super.apply(this,
  42675. arguments) || this;
  42676. /* *
  42677. *
  42678. * Properties
  42679. *
  42680. * */
  42681. _this.data = void 0;
  42682. _this.options = void 0;
  42683. _this.points = void 0;
  42684. return _this;
  42685. }
  42686. /**
  42687. * A bar series is a special type of column series where the columns are
  42688. * horizontal.
  42689. *
  42690. * @sample highcharts/demo/bar-basic/
  42691. * Bar chart
  42692. *
  42693. * @extends plotOptions.column
  42694. * @product highcharts
  42695. * @optionparent plotOptions.bar
  42696. */
  42697. BarSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  42698. // nothing here yet
  42699. });
  42700. return BarSeries;
  42701. }(ColumnSeries));
  42702. extend(BarSeries.prototype, {
  42703. inverted: true
  42704. });
  42705. SeriesRegistry.registerSeriesType('bar', BarSeries);
  42706. /* *
  42707. *
  42708. * Default Export
  42709. *
  42710. * */
  42711. /* *
  42712. *
  42713. * API Options
  42714. *
  42715. * */
  42716. /**
  42717. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  42718. * it is inherited from [chart.type](#chart.type).
  42719. *
  42720. * @extends series,plotOptions.bar
  42721. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  42722. * linecap, lineWidth, marker, connectEnds, step
  42723. * @product highcharts
  42724. * @apioption series.bar
  42725. */
  42726. /**
  42727. * An array of data points for the series. For the `bar` series type,
  42728. * points can be given in the following ways:
  42729. *
  42730. * 1. An array of numerical values. In this case, the numerical values will be
  42731. * interpreted as `y` options. The `x` values will be automatically
  42732. * calculated, either starting at 0 and incremented by 1, or from
  42733. * `pointStart` and `pointInterval` given in the series options. If the axis
  42734. * has categories, these will be used. Example:
  42735. * ```js
  42736. * data: [0, 5, 3, 5]
  42737. * ```
  42738. *
  42739. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42740. * `x,y`. If the first value is a string, it is applied as the name of the
  42741. * point, and the `x` value is inferred.
  42742. * ```js
  42743. * data: [
  42744. * [0, 5],
  42745. * [1, 10],
  42746. * [2, 3]
  42747. * ]
  42748. * ```
  42749. *
  42750. * 3. An array of objects with named values. The following snippet shows only a
  42751. * few settings, see the complete options set below. If the total number of
  42752. * data points exceeds the series'
  42753. * [turboThreshold](#series.bar.turboThreshold), this option is not
  42754. * available.
  42755. * ```js
  42756. * data: [{
  42757. * x: 1,
  42758. * y: 1,
  42759. * name: "Point2",
  42760. * color: "#00FF00"
  42761. * }, {
  42762. * x: 1,
  42763. * y: 10,
  42764. * name: "Point1",
  42765. * color: "#FF00FF"
  42766. * }]
  42767. * ```
  42768. *
  42769. * @sample {highcharts} highcharts/chart/reflow-true/
  42770. * Numerical values
  42771. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42772. * Arrays of numeric x and y
  42773. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42774. * Arrays of datetime x and y
  42775. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42776. * Arrays of point.name and y
  42777. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42778. * Config objects
  42779. *
  42780. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42781. * @extends series.column.data
  42782. * @product highcharts
  42783. * @apioption series.bar.data
  42784. */
  42785. /**
  42786. * @excluding halo,lineWidth,lineWidthPlus,marker
  42787. * @product highcharts highstock
  42788. * @apioption series.bar.states.hover
  42789. */
  42790. /**
  42791. * @excluding halo,lineWidth,lineWidthPlus,marker
  42792. * @product highcharts highstock
  42793. * @apioption series.bar.states.select
  42794. */
  42795. ''; // gets doclets above into transpilat
  42796. return BarSeries;
  42797. });
  42798. _registerModule(_modules, 'Series/Scatter/ScatterSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Series/Line/LineSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, LineSeries, SeriesRegistry, U) {
  42799. /* *
  42800. *
  42801. * (c) 2010-2021 Torstein Honsi
  42802. *
  42803. * License: www.highcharts.com/license
  42804. *
  42805. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42806. *
  42807. * */
  42808. var __extends = (this && this.__extends) || (function () {
  42809. var extendStatics = function (d,
  42810. b) {
  42811. extendStatics = Object.setPrototypeOf ||
  42812. ({ __proto__: [] } instanceof Array && function (d,
  42813. b) { d.__proto__ = b; }) ||
  42814. function (d,
  42815. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42816. return extendStatics(d, b);
  42817. };
  42818. return function (d, b) {
  42819. extendStatics(d, b);
  42820. function __() { this.constructor = d; }
  42821. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42822. };
  42823. })();
  42824. var addEvent = U.addEvent,
  42825. extend = U.extend,
  42826. merge = U.merge;
  42827. /* *
  42828. *
  42829. * Class
  42830. *
  42831. * */
  42832. /**
  42833. * Scatter series type.
  42834. *
  42835. * @private
  42836. */
  42837. var ScatterSeries = /** @class */ (function (_super) {
  42838. __extends(ScatterSeries, _super);
  42839. function ScatterSeries() {
  42840. var _this = _super !== null && _super.apply(this,
  42841. arguments) || this;
  42842. /* *
  42843. *
  42844. * Properties
  42845. *
  42846. * */
  42847. _this.data = void 0;
  42848. _this.options = void 0;
  42849. _this.points = void 0;
  42850. return _this;
  42851. /* eslint-enable valid-jsdoc */
  42852. }
  42853. /* *
  42854. *
  42855. * Functions
  42856. *
  42857. * */
  42858. /* eslint-disable valid-jsdoc */
  42859. /**
  42860. * Optionally add the jitter effect.
  42861. * @private
  42862. */
  42863. ScatterSeries.prototype.applyJitter = function () {
  42864. var series = this,
  42865. jitter = this.options.jitter,
  42866. len = this.points.length;
  42867. /**
  42868. * Return a repeatable, pseudo-random number based on an integer
  42869. * seed.
  42870. * @private
  42871. */
  42872. function unrandom(seed) {
  42873. var rand = Math.sin(seed) * 10000;
  42874. return rand - Math.floor(rand);
  42875. }
  42876. if (jitter) {
  42877. this.points.forEach(function (point, i) {
  42878. ['x', 'y'].forEach(function (dim, j) {
  42879. var axis,
  42880. plotProp = 'plot' + dim.toUpperCase(),
  42881. min,
  42882. max,
  42883. translatedJitter;
  42884. if (jitter[dim] && !point.isNull) {
  42885. axis = series[dim + 'Axis'];
  42886. translatedJitter =
  42887. jitter[dim] * axis.transA;
  42888. if (axis && !axis.isLog) {
  42889. // Identify the outer bounds of the jitter range
  42890. min = Math.max(0, point[plotProp] - translatedJitter);
  42891. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  42892. // Find a random position within this range
  42893. point[plotProp] = min +
  42894. (max - min) * unrandom(i + j * len);
  42895. // Update clientX for the tooltip k-d-tree
  42896. if (dim === 'x') {
  42897. point.clientX = point.plotX;
  42898. }
  42899. }
  42900. }
  42901. });
  42902. });
  42903. }
  42904. };
  42905. /**
  42906. * @private
  42907. * @function Highcharts.seriesTypes.scatter#drawGraph
  42908. */
  42909. ScatterSeries.prototype.drawGraph = function () {
  42910. if (this.options.lineWidth ||
  42911. // In case we have a graph from before and we update the line
  42912. // width to 0 (#13816)
  42913. (this.options.lineWidth === 0 &&
  42914. this.graph &&
  42915. this.graph.strokeWidth())) {
  42916. _super.prototype.drawGraph.call(this);
  42917. }
  42918. };
  42919. /**
  42920. * A scatter plot uses cartesian coordinates to display values for two
  42921. * variables for a set of data.
  42922. *
  42923. * @sample {highcharts} highcharts/demo/scatter/
  42924. * Scatter plot
  42925. *
  42926. * @extends plotOptions.line
  42927. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  42928. * @product highcharts highstock
  42929. * @optionparent plotOptions.scatter
  42930. */
  42931. ScatterSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  42932. /**
  42933. * The width of the line connecting the data points.
  42934. *
  42935. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  42936. * 0 by default
  42937. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  42938. * 1px
  42939. *
  42940. * @product highcharts highstock
  42941. */
  42942. lineWidth: 0,
  42943. findNearestPointBy: 'xy',
  42944. /**
  42945. * Apply a jitter effect for the rendered markers. When plotting
  42946. * discrete values, a little random noise may help telling the points
  42947. * apart. The jitter setting applies a random displacement of up to `n`
  42948. * axis units in either direction. So for example on a horizontal X
  42949. * axis, setting the `jitter.x` to 0.24 will render the point in a
  42950. * random position between 0.24 units to the left and 0.24 units to the
  42951. * right of the true axis position. On a category axis, setting it to
  42952. * 0.5 will fill up the bin and make the data appear continuous.
  42953. *
  42954. * When rendered on top of a box plot or a column series, a jitter value
  42955. * of 0.24 will correspond to the underlying series' default
  42956. * [groupPadding](
  42957. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  42958. * and [pointPadding](
  42959. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  42960. * settings.
  42961. *
  42962. * @sample {highcharts} highcharts/series-scatter/jitter
  42963. * Jitter on a scatter plot
  42964. *
  42965. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  42966. * Jittered scatter plot on top of a box plot
  42967. *
  42968. * @product highcharts highstock
  42969. * @since 7.0.2
  42970. */
  42971. jitter: {
  42972. /**
  42973. * The maximal X offset for the random jitter effect.
  42974. */
  42975. x: 0,
  42976. /**
  42977. * The maximal Y offset for the random jitter effect.
  42978. */
  42979. y: 0
  42980. },
  42981. marker: {
  42982. enabled: true // Overrides auto-enabling in line series (#3647)
  42983. },
  42984. /**
  42985. * Sticky tracking of mouse events. When true, the `mouseOut` event
  42986. * on a series isn't triggered until the mouse moves over another
  42987. * series, or out of the plot area. When false, the `mouseOut` event on
  42988. * a series is triggered when the mouse leaves the area around the
  42989. * series' graph or markers. This also implies the tooltip. When
  42990. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  42991. * will be hidden when moving the mouse between series.
  42992. *
  42993. * @type {boolean}
  42994. * @default false
  42995. * @product highcharts highstock
  42996. * @apioption plotOptions.scatter.stickyTracking
  42997. */
  42998. /**
  42999. * A configuration object for the tooltip rendering of each single
  43000. * series. Properties are inherited from [tooltip](#tooltip).
  43001. * Overridable properties are `headerFormat`, `pointFormat`,
  43002. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  43003. * series, in a scatter plot the series.name by default shows in the
  43004. * headerFormat and point.x and point.y in the pointFormat.
  43005. *
  43006. * @product highcharts highstock
  43007. */
  43008. tooltip: {
  43009. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  43010. '<span style="font-size: 10px"> {series.name}</span><br/>',
  43011. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  43012. }
  43013. });
  43014. return ScatterSeries;
  43015. }(LineSeries));
  43016. extend(ScatterSeries.prototype, {
  43017. drawTracker: ColumnSeries.prototype.drawTracker,
  43018. sorted: false,
  43019. requireSorting: false,
  43020. noSharedTooltip: true,
  43021. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  43022. takeOrdinalPosition: false // #2342
  43023. });
  43024. /* *
  43025. *
  43026. * Events
  43027. *
  43028. * */
  43029. /* eslint-disable no-invalid-this */
  43030. addEvent(ScatterSeries, 'afterTranslate', function () {
  43031. this.applyJitter();
  43032. });
  43033. SeriesRegistry.registerSeriesType('scatter', ScatterSeries);
  43034. /* *
  43035. *
  43036. * Default Export
  43037. *
  43038. * */
  43039. /* *
  43040. *
  43041. * API Options
  43042. *
  43043. * */
  43044. /**
  43045. * A `scatter` series. If the [type](#series.scatter.type) option is
  43046. * not specified, it is inherited from [chart.type](#chart.type).
  43047. *
  43048. * @extends series,plotOptions.scatter
  43049. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  43050. * @product highcharts highstock
  43051. * @apioption series.scatter
  43052. */
  43053. /**
  43054. * An array of data points for the series. For the `scatter` series
  43055. * type, points can be given in the following ways:
  43056. *
  43057. * 1. An array of numerical values. In this case, the numerical values will be
  43058. * interpreted as `y` options. The `x` values will be automatically
  43059. * calculated, either starting at 0 and incremented by 1, or from
  43060. * `pointStart` and `pointInterval` given in the series options. If the axis
  43061. * has categories, these will be used. Example:
  43062. * ```js
  43063. * data: [0, 5, 3, 5]
  43064. * ```
  43065. *
  43066. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43067. * `x,y`. If the first value is a string, it is applied as the name of the
  43068. * point, and the `x` value is inferred.
  43069. * ```js
  43070. * data: [
  43071. * [0, 0],
  43072. * [1, 8],
  43073. * [2, 9]
  43074. * ]
  43075. * ```
  43076. *
  43077. * 3. An array of objects with named values. The following snippet shows only a
  43078. * few settings, see the complete options set below. If the total number of
  43079. * data points exceeds the series'
  43080. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  43081. * available.
  43082. * ```js
  43083. * data: [{
  43084. * x: 1,
  43085. * y: 2,
  43086. * name: "Point2",
  43087. * color: "#00FF00"
  43088. * }, {
  43089. * x: 1,
  43090. * y: 4,
  43091. * name: "Point1",
  43092. * color: "#FF00FF"
  43093. * }]
  43094. * ```
  43095. *
  43096. * @sample {highcharts} highcharts/chart/reflow-true/
  43097. * Numerical values
  43098. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43099. * Arrays of numeric x and y
  43100. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43101. * Arrays of datetime x and y
  43102. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43103. * Arrays of point.name and y
  43104. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43105. * Config objects
  43106. *
  43107. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43108. * @extends series.line.data
  43109. * @product highcharts highstock
  43110. * @apioption series.scatter.data
  43111. */
  43112. ''; // adds doclets above to transpilat
  43113. return ScatterSeries;
  43114. });
  43115. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (H, Series, U) {
  43116. /* *
  43117. *
  43118. * (c) 2010-2021 Torstein Honsi
  43119. *
  43120. * License: www.highcharts.com/license
  43121. *
  43122. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43123. *
  43124. * */
  43125. /**
  43126. * @private
  43127. * @interface Highcharts.RadianAngles
  43128. */ /**
  43129. * @name Highcharts.RadianAngles#end
  43130. * @type {number}
  43131. */ /**
  43132. * @name Highcharts.RadianAngles#start
  43133. * @type {number}
  43134. */
  43135. var isNumber = U.isNumber,
  43136. pick = U.pick,
  43137. relativeLength = U.relativeLength;
  43138. var deg2rad = H.deg2rad;
  43139. /* eslint-disable valid-jsdoc */
  43140. /**
  43141. * @private
  43142. * @mixin Highcharts.CenteredSeriesMixin
  43143. */
  43144. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  43145. /**
  43146. * Get the center of the pie based on the size and center options relative
  43147. * to the plot area. Borrowed by the polar and gauge series types.
  43148. *
  43149. * @private
  43150. * @function Highcharts.CenteredSeriesMixin.getCenter
  43151. *
  43152. * @return {Array<number>}
  43153. */
  43154. getCenter: function () {
  43155. var options = this.options,
  43156. chart = this.chart,
  43157. slicingRoom = 2 * (options.slicedOffset || 0),
  43158. handleSlicingRoom,
  43159. plotWidth = chart.plotWidth - 2 * slicingRoom,
  43160. plotHeight = chart.plotHeight - 2 * slicingRoom,
  43161. centerOption = options.center,
  43162. smallestSize = Math.min(plotWidth,
  43163. plotHeight),
  43164. size = options.size,
  43165. innerSize = options.innerSize || 0,
  43166. positions,
  43167. i,
  43168. value;
  43169. if (typeof size === 'string') {
  43170. size = parseFloat(size);
  43171. }
  43172. if (typeof innerSize === 'string') {
  43173. innerSize = parseFloat(innerSize);
  43174. }
  43175. positions = [
  43176. pick(centerOption[0], '50%'),
  43177. pick(centerOption[1], '50%'),
  43178. // Prevent from negative values
  43179. pick(size && size < 0 ? void 0 : options.size, '100%'),
  43180. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  43181. ];
  43182. // No need for inner size in angular (gauges) series but still required
  43183. // for pie series
  43184. if (chart.angular && !(this instanceof Series)) {
  43185. positions[3] = 0;
  43186. }
  43187. for (i = 0; i < 4; ++i) {
  43188. value = positions[i];
  43189. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  43190. // i == 0: centerX, relative to width
  43191. // i == 1: centerY, relative to height
  43192. // i == 2: size, relative to smallestSize
  43193. // i == 3: innerSize, relative to size
  43194. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  43195. }
  43196. // innerSize cannot be larger than size (#3632)
  43197. if (positions[3] > positions[2]) {
  43198. positions[3] = positions[2];
  43199. }
  43200. return positions;
  43201. },
  43202. /**
  43203. * getStartAndEndRadians - Calculates start and end angles in radians.
  43204. * Used in series types such as pie and sunburst.
  43205. *
  43206. * @private
  43207. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  43208. *
  43209. * @param {number} [start]
  43210. * Start angle in degrees.
  43211. *
  43212. * @param {number} [end]
  43213. * Start angle in degrees.
  43214. *
  43215. * @return {Highcharts.RadianAngles}
  43216. * Returns an object containing start and end angles as radians.
  43217. */
  43218. getStartAndEndRadians: function (start, end) {
  43219. var startAngle = isNumber(start) ? start : 0, // must be a number
  43220. endAngle = ((isNumber(end) && // must be a number
  43221. end > startAngle && // must be larger than the start angle
  43222. // difference must be less than 360 degrees
  43223. (end - startAngle) < 360) ?
  43224. end :
  43225. startAngle + 360),
  43226. correction = -90;
  43227. return {
  43228. start: deg2rad * (startAngle + correction),
  43229. end: deg2rad * (endAngle + correction)
  43230. };
  43231. }
  43232. };
  43233. return centeredSeriesMixin;
  43234. });
  43235. _registerModule(_modules, 'Series/Pie/PiePoint.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, Point, U) {
  43236. /* *
  43237. *
  43238. * (c) 2010-2021 Torstein Honsi
  43239. *
  43240. * License: www.highcharts.com/license
  43241. *
  43242. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43243. *
  43244. * */
  43245. var __extends = (this && this.__extends) || (function () {
  43246. var extendStatics = function (d,
  43247. b) {
  43248. extendStatics = Object.setPrototypeOf ||
  43249. ({ __proto__: [] } instanceof Array && function (d,
  43250. b) { d.__proto__ = b; }) ||
  43251. function (d,
  43252. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43253. return extendStatics(d, b);
  43254. };
  43255. return function (d, b) {
  43256. extendStatics(d, b);
  43257. function __() { this.constructor = d; }
  43258. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43259. };
  43260. })();
  43261. var setAnimation = A.setAnimation;
  43262. var addEvent = U.addEvent,
  43263. defined = U.defined,
  43264. extend = U.extend,
  43265. isNumber = U.isNumber,
  43266. pick = U.pick,
  43267. relativeLength = U.relativeLength;
  43268. /* *
  43269. *
  43270. * Class
  43271. *
  43272. * */
  43273. var PiePoint = /** @class */ (function (_super) {
  43274. __extends(PiePoint, _super);
  43275. function PiePoint() {
  43276. /* *
  43277. *
  43278. * Properties
  43279. *
  43280. * */
  43281. var _this = _super !== null && _super.apply(this,
  43282. arguments) || this;
  43283. _this.labelDistance = void 0;
  43284. _this.options = void 0;
  43285. _this.series = void 0;
  43286. return _this;
  43287. }
  43288. /* *
  43289. *
  43290. * Functions
  43291. *
  43292. * */
  43293. /* eslint-disable valid-jsdoc */
  43294. /**
  43295. * Extendable method for getting the path of the connector between the
  43296. * data label and the pie slice.
  43297. * @private
  43298. */
  43299. PiePoint.prototype.getConnectorPath = function () {
  43300. var labelPosition = this.labelPosition,
  43301. options = this.series.options.dataLabels,
  43302. connectorShape = options.connectorShape,
  43303. predefinedShapes = this.connectorShapes;
  43304. // find out whether to use the predefined shape
  43305. if (predefinedShapes[connectorShape]) {
  43306. connectorShape = predefinedShapes[connectorShape];
  43307. }
  43308. return connectorShape.call(this, {
  43309. // pass simplified label position object for user's convenience
  43310. x: labelPosition.final.x,
  43311. y: labelPosition.final.y,
  43312. alignment: labelPosition.alignment
  43313. }, labelPosition.connectorPosition, options);
  43314. };
  43315. /**
  43316. * @private
  43317. */
  43318. PiePoint.prototype.getTranslate = function () {
  43319. return this.sliced ? this.slicedTranslation : {
  43320. translateX: 0,
  43321. translateY: 0
  43322. };
  43323. };
  43324. /**
  43325. * @private
  43326. */
  43327. PiePoint.prototype.haloPath = function (size) {
  43328. var shapeArgs = this.shapeArgs;
  43329. return this.sliced || !this.visible ?
  43330. [] :
  43331. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  43332. // Substract 1px to ensure the background is not bleeding
  43333. // through between the halo and the slice (#7495).
  43334. innerR: shapeArgs.r - 1,
  43335. start: shapeArgs.start,
  43336. end: shapeArgs.end
  43337. });
  43338. };
  43339. /**
  43340. * Initialize the pie slice.
  43341. * @private
  43342. */
  43343. PiePoint.prototype.init = function () {
  43344. Point.prototype.init.apply(this, arguments);
  43345. var point = this,
  43346. toggleSlice;
  43347. point.name = pick(point.name, 'Slice');
  43348. // add event listener for select
  43349. toggleSlice = function (e) {
  43350. point.slice(e.type === 'select');
  43351. };
  43352. addEvent(point, 'select', toggleSlice);
  43353. addEvent(point, 'unselect', toggleSlice);
  43354. return point;
  43355. };
  43356. /**
  43357. * Negative points are not valid (#1530, #3623, #5322)
  43358. * @private
  43359. */
  43360. PiePoint.prototype.isValid = function () {
  43361. return isNumber(this.y) && this.y >= 0;
  43362. };
  43363. /**
  43364. * Toggle the visibility of the pie slice.
  43365. * @private
  43366. *
  43367. * @param {boolean} vis
  43368. * Whether to show the slice or not. If undefined, the visibility is
  43369. * toggled.
  43370. */
  43371. PiePoint.prototype.setVisible = function (vis, redraw) {
  43372. var point = this,
  43373. series = point.series,
  43374. chart = series.chart,
  43375. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  43376. redraw = pick(redraw, ignoreHiddenPoint);
  43377. if (vis !== point.visible) {
  43378. // If called without an argument, toggle visibility
  43379. point.visible = point.options.visible = vis =
  43380. typeof vis === 'undefined' ? !point.visible : vis;
  43381. // update userOptions.data
  43382. series.options.data[series.data.indexOf(point)] =
  43383. point.options;
  43384. // Show and hide associated elements. This is performed
  43385. // regardless of redraw or not, because chart.redraw only
  43386. // handles full series.
  43387. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  43388. if (point[key]) {
  43389. point[key][vis ? 'show' : 'hide'](vis);
  43390. }
  43391. });
  43392. if (point.legendItem) {
  43393. chart.legend.colorizeItem(point, vis);
  43394. }
  43395. // #4170, hide halo after hiding point
  43396. if (!vis && point.state === 'hover') {
  43397. point.setState('');
  43398. }
  43399. // Handle ignore hidden slices
  43400. if (ignoreHiddenPoint) {
  43401. series.isDirty = true;
  43402. }
  43403. if (redraw) {
  43404. chart.redraw();
  43405. }
  43406. }
  43407. };
  43408. /**
  43409. * Set or toggle whether the slice is cut out from the pie.
  43410. * @private
  43411. *
  43412. * @param {boolean} sliced
  43413. * When undefined, the slice state is toggled.
  43414. *
  43415. * @param {boolean} redraw
  43416. * Whether to redraw the chart. True by default.
  43417. *
  43418. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  43419. * Animation options.
  43420. */
  43421. PiePoint.prototype.slice = function (sliced, redraw, animation) {
  43422. var point = this,
  43423. series = point.series,
  43424. chart = series.chart;
  43425. setAnimation(animation, chart);
  43426. // redraw is true by default
  43427. redraw = pick(redraw, true);
  43428. /**
  43429. * Pie series only. Whether to display a slice offset from the
  43430. * center.
  43431. * @name Highcharts.Point#sliced
  43432. * @type {boolean|undefined}
  43433. */
  43434. // if called without an argument, toggle
  43435. point.sliced = point.options.sliced = sliced =
  43436. defined(sliced) ? sliced : !point.sliced;
  43437. // update userOptions.data
  43438. series.options.data[series.data.indexOf(point)] =
  43439. point.options;
  43440. if (point.graphic) {
  43441. point.graphic.animate(this.getTranslate());
  43442. }
  43443. if (point.shadowGroup) {
  43444. point.shadowGroup.animate(this.getTranslate());
  43445. }
  43446. };
  43447. return PiePoint;
  43448. }(Point));
  43449. extend(PiePoint.prototype, {
  43450. connectorShapes: {
  43451. // only one available before v7.0.0
  43452. fixedOffset: function (labelPosition, connectorPosition, options) {
  43453. var breakAt = connectorPosition.breakAt,
  43454. touchingSliceAt = connectorPosition.touchingSliceAt,
  43455. lineSegment = options.softConnector ? [
  43456. 'C',
  43457. // 1st control point (of the curve)
  43458. labelPosition.x +
  43459. // 5 gives the connector a little horizontal bend
  43460. (labelPosition.alignment === 'left' ? -5 : 5),
  43461. labelPosition.y,
  43462. 2 * breakAt.x - touchingSliceAt.x,
  43463. 2 * breakAt.y - touchingSliceAt.y,
  43464. breakAt.x,
  43465. breakAt.y //
  43466. ] : [
  43467. 'L',
  43468. breakAt.x,
  43469. breakAt.y
  43470. ];
  43471. // assemble the path
  43472. return ([
  43473. ['M', labelPosition.x, labelPosition.y],
  43474. lineSegment,
  43475. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43476. ]);
  43477. },
  43478. straight: function (labelPosition, connectorPosition) {
  43479. var touchingSliceAt = connectorPosition.touchingSliceAt;
  43480. // direct line to the slice
  43481. return [
  43482. ['M', labelPosition.x, labelPosition.y],
  43483. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43484. ];
  43485. },
  43486. crookedLine: function (labelPosition, connectorPosition, options) {
  43487. var touchingSliceAt = connectorPosition.touchingSliceAt,
  43488. series = this.series,
  43489. pieCenterX = series.center[0],
  43490. plotWidth = series.chart.plotWidth,
  43491. plotLeft = series.chart.plotLeft,
  43492. alignment = labelPosition.alignment,
  43493. radius = this.shapeArgs.r,
  43494. crookDistance = relativeLength(// % to fraction
  43495. options.crookDistance, 1),
  43496. crookX = alignment === 'left' ?
  43497. pieCenterX + radius + (plotWidth + plotLeft -
  43498. pieCenterX - radius) * (1 - crookDistance) :
  43499. plotLeft + (pieCenterX - radius) * crookDistance,
  43500. segmentWithCrook = [
  43501. 'L',
  43502. crookX,
  43503. labelPosition.y
  43504. ],
  43505. useCrook = true;
  43506. // crookedLine formula doesn't make sense if the path overlaps
  43507. // the label - use straight line instead in that case
  43508. if (alignment === 'left' ?
  43509. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  43510. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  43511. useCrook = false;
  43512. }
  43513. // assemble the path
  43514. var path = [
  43515. ['M',
  43516. labelPosition.x,
  43517. labelPosition.y]
  43518. ];
  43519. if (useCrook) {
  43520. path.push(segmentWithCrook);
  43521. }
  43522. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  43523. return path;
  43524. }
  43525. }
  43526. });
  43527. /* *
  43528. *
  43529. * Default Export
  43530. *
  43531. * */
  43532. return PiePoint;
  43533. });
  43534. _registerModule(_modules, 'Series/Pie/PieSeries.js', [_modules['Mixins/CenteredSeries.js'], _modules['Series/Column/ColumnSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Series/Pie/PiePoint.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (CenteredSeriesMixin, ColumnSeries, H, LegendSymbolMixin, palette, PiePoint, Series, SeriesRegistry, SVGRenderer, U) {
  43535. /* *
  43536. *
  43537. * (c) 2010-2021 Torstein Honsi
  43538. *
  43539. * License: www.highcharts.com/license
  43540. *
  43541. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43542. *
  43543. * */
  43544. var __extends = (this && this.__extends) || (function () {
  43545. var extendStatics = function (d,
  43546. b) {
  43547. extendStatics = Object.setPrototypeOf ||
  43548. ({ __proto__: [] } instanceof Array && function (d,
  43549. b) { d.__proto__ = b; }) ||
  43550. function (d,
  43551. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43552. return extendStatics(d, b);
  43553. };
  43554. return function (d, b) {
  43555. extendStatics(d, b);
  43556. function __() { this.constructor = d; }
  43557. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43558. };
  43559. })();
  43560. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  43561. var noop = H.noop;
  43562. var clamp = U.clamp,
  43563. extend = U.extend,
  43564. fireEvent = U.fireEvent,
  43565. merge = U.merge,
  43566. pick = U.pick,
  43567. relativeLength = U.relativeLength;
  43568. /* *
  43569. *
  43570. * Class
  43571. *
  43572. * */
  43573. /**
  43574. * Pie series type.
  43575. *
  43576. * @private
  43577. * @class
  43578. * @name Highcharts.seriesTypes.pie
  43579. *
  43580. * @augments Highcharts.Series
  43581. */
  43582. var PieSeries = /** @class */ (function (_super) {
  43583. __extends(PieSeries, _super);
  43584. function PieSeries() {
  43585. /* *
  43586. *
  43587. * Static Properties
  43588. *
  43589. * */
  43590. var _this = _super !== null && _super.apply(this,
  43591. arguments) || this;
  43592. /* *
  43593. *
  43594. * Properties
  43595. *
  43596. * */
  43597. _this.center = void 0;
  43598. _this.data = void 0;
  43599. _this.maxLabelDistance = void 0;
  43600. _this.options = void 0;
  43601. _this.points = void 0;
  43602. return _this;
  43603. /* eslint-enable valid-jsdoc */
  43604. }
  43605. /* *
  43606. *
  43607. * Functions
  43608. *
  43609. * */
  43610. /* eslint-disable valid-jsdoc */
  43611. /**
  43612. * Animates the pies in.
  43613. * @private
  43614. */
  43615. PieSeries.prototype.animate = function (init) {
  43616. var series = this,
  43617. points = series.points,
  43618. startAngleRad = series.startAngleRad;
  43619. if (!init) {
  43620. points.forEach(function (point) {
  43621. var graphic = point.graphic,
  43622. args = point.shapeArgs;
  43623. if (graphic && args) {
  43624. // start values
  43625. graphic.attr({
  43626. // animate from inner radius (#779)
  43627. r: pick(point.startR, (series.center && series.center[3] / 2)),
  43628. start: startAngleRad,
  43629. end: startAngleRad
  43630. });
  43631. // animate
  43632. graphic.animate({
  43633. r: args.r,
  43634. start: args.start,
  43635. end: args.end
  43636. }, series.options.animation);
  43637. }
  43638. });
  43639. }
  43640. };
  43641. /**
  43642. * Called internally to draw auxiliary graph in pie-like series in
  43643. * situtation when the default graph is not sufficient enough to present
  43644. * the data well. Auxiliary graph is saved in the same object as
  43645. * regular graph.
  43646. * @private
  43647. */
  43648. PieSeries.prototype.drawEmpty = function () {
  43649. var centerX,
  43650. centerY,
  43651. start = this.startAngleRad,
  43652. end = this.endAngleRad,
  43653. options = this.options;
  43654. // Draw auxiliary graph if there're no visible points.
  43655. if (this.total === 0 && this.center) {
  43656. centerX = this.center[0];
  43657. centerY = this.center[1];
  43658. if (!this.graph) {
  43659. this.graph = this.chart.renderer
  43660. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  43661. .addClass('highcharts-empty-series')
  43662. .add(this.group);
  43663. }
  43664. this.graph.attr({
  43665. d: SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  43666. start: start,
  43667. end: end,
  43668. innerR: this.center[3] / 2
  43669. })
  43670. });
  43671. if (!this.chart.styledMode) {
  43672. this.graph.attr({
  43673. 'stroke-width': options.borderWidth,
  43674. fill: options.fillColor || 'none',
  43675. stroke: options.color || palette.neutralColor20
  43676. });
  43677. }
  43678. }
  43679. else if (this.graph) { // Destroy the graph object.
  43680. this.graph = this.graph.destroy();
  43681. }
  43682. };
  43683. /**
  43684. * Slices in pie chart are initialized in DOM, but it's shapes and
  43685. * animations are normally run in `drawPoints()`.
  43686. * @private
  43687. */
  43688. PieSeries.prototype.drawPoints = function () {
  43689. var renderer = this.chart.renderer;
  43690. this.points.forEach(function (point) {
  43691. // When updating a series between 2d and 3d or cartesian and
  43692. // polar, the shape type changes.
  43693. if (point.graphic && point.hasNewShapeType()) {
  43694. point.graphic = point.graphic.destroy();
  43695. }
  43696. if (!point.graphic) {
  43697. point.graphic = renderer[point.shapeType](point.shapeArgs)
  43698. .add(point.series.group);
  43699. point.delayedRendering = true;
  43700. }
  43701. });
  43702. };
  43703. /**
  43704. * Extend the generatePoints method by adding total and percentage
  43705. * properties to each point
  43706. * @private
  43707. */
  43708. PieSeries.prototype.generatePoints = function () {
  43709. _super.prototype.generatePoints.call(this);
  43710. this.updateTotals();
  43711. };
  43712. /**
  43713. * Utility for getting the x value from a given y, used for
  43714. * anticollision logic in data labels. Added point for using specific
  43715. * points' label distance.
  43716. * @private
  43717. */
  43718. PieSeries.prototype.getX = function (y, left, point) {
  43719. var center = this.center,
  43720. // Variable pie has individual radius
  43721. radius = this.radii ?
  43722. this.radii[point.index] || 0 :
  43723. center[2] / 2,
  43724. angle,
  43725. x;
  43726. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  43727. x = center[0] +
  43728. (left ? -1 : 1) *
  43729. (Math.cos(angle) * (radius + point.labelDistance)) +
  43730. (point.labelDistance > 0 ?
  43731. (left ? -1 : 1) * this.options.dataLabels.padding :
  43732. 0);
  43733. return x;
  43734. };
  43735. /**
  43736. * Define hasData function for non-cartesian series. Returns true if the
  43737. * series has points at all.
  43738. * @private
  43739. */
  43740. PieSeries.prototype.hasData = function () {
  43741. return !!this.processedXData.length; // != 0
  43742. };
  43743. /**
  43744. * Draw the data points
  43745. * @private
  43746. */
  43747. PieSeries.prototype.redrawPoints = function () {
  43748. var series = this,
  43749. chart = series.chart,
  43750. renderer = chart.renderer,
  43751. groupTranslation,
  43752. graphic,
  43753. pointAttr,
  43754. shapeArgs,
  43755. shadow = series.options.shadow;
  43756. this.drawEmpty();
  43757. if (shadow && !series.shadowGroup && !chart.styledMode) {
  43758. series.shadowGroup = renderer
  43759. .g('shadow')
  43760. .attr({ zIndex: -1 })
  43761. .add(series.group);
  43762. }
  43763. // draw the slices
  43764. series.points.forEach(function (point) {
  43765. var animateTo = {};
  43766. graphic = point.graphic;
  43767. if (!point.isNull && graphic) {
  43768. var shadowGroup = void 0;
  43769. shapeArgs = point.shapeArgs;
  43770. // If the point is sliced, use special translation, else use
  43771. // plot area translation
  43772. groupTranslation = point.getTranslate();
  43773. if (!chart.styledMode) {
  43774. // Put the shadow behind all points
  43775. shadowGroup = point.shadowGroup;
  43776. if (shadow && !shadowGroup) {
  43777. shadowGroup = point.shadowGroup = renderer
  43778. .g('shadow')
  43779. .add(series.shadowGroup);
  43780. }
  43781. if (shadowGroup) {
  43782. shadowGroup.attr(groupTranslation);
  43783. }
  43784. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  43785. }
  43786. // Draw the slice
  43787. if (!point.delayedRendering) {
  43788. graphic
  43789. .setRadialReference(series.center);
  43790. if (!chart.styledMode) {
  43791. merge(true, animateTo, pointAttr);
  43792. }
  43793. merge(true, animateTo, shapeArgs, groupTranslation);
  43794. graphic.animate(animateTo);
  43795. }
  43796. else {
  43797. graphic
  43798. .setRadialReference(series.center)
  43799. .attr(shapeArgs)
  43800. .attr(groupTranslation);
  43801. if (!chart.styledMode) {
  43802. graphic
  43803. .attr(pointAttr)
  43804. .attr({ 'stroke-linejoin': 'round' })
  43805. .shadow(shadow, shadowGroup);
  43806. }
  43807. point.delayedRendering = false;
  43808. }
  43809. graphic.attr({
  43810. visibility: point.visible ? 'inherit' : 'hidden'
  43811. });
  43812. graphic.addClass(point.getClassName(), true);
  43813. }
  43814. else if (graphic) {
  43815. point.graphic = graphic.destroy();
  43816. }
  43817. });
  43818. };
  43819. /**
  43820. * Utility for sorting data labels.
  43821. * @private
  43822. */
  43823. PieSeries.prototype.sortByAngle = function (points, sign) {
  43824. points.sort(function (a, b) {
  43825. return ((typeof a.angle !== 'undefined') &&
  43826. (b.angle - a.angle) * sign);
  43827. });
  43828. };
  43829. /**
  43830. * Do translation for pie slices
  43831. * @private
  43832. */
  43833. PieSeries.prototype.translate = function (positions) {
  43834. this.generatePoints();
  43835. var series = this,
  43836. cumulative = 0,
  43837. precision = 1000, // issue #172
  43838. options = series.options,
  43839. slicedOffset = options.slicedOffset,
  43840. connectorOffset = slicedOffset + (options.borderWidth || 0),
  43841. finalConnectorOffset,
  43842. start,
  43843. end,
  43844. angle,
  43845. radians = getStartAndEndRadians(options.startAngle,
  43846. options.endAngle),
  43847. startAngleRad = series.startAngleRad = radians.start,
  43848. endAngleRad = series.endAngleRad = radians.end,
  43849. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  43850. points = series.points,
  43851. // the x component of the radius vector for a given point
  43852. radiusX,
  43853. radiusY,
  43854. labelDistance = options.dataLabels.distance,
  43855. ignoreHiddenPoint = options.ignoreHiddenPoint,
  43856. i,
  43857. len = points.length,
  43858. point;
  43859. // Get positions - either an integer or a percentage string must be
  43860. // given. If positions are passed as a parameter, we're in a
  43861. // recursive loop for adjusting space for data labels.
  43862. if (!positions) {
  43863. series.center = positions = series.getCenter();
  43864. }
  43865. // Calculate the geometry for each point
  43866. for (i = 0; i < len; i++) {
  43867. point = points[i];
  43868. // set start and end angle
  43869. start = startAngleRad + (cumulative * circ);
  43870. if (point.isValid() &&
  43871. (!ignoreHiddenPoint || point.visible)) {
  43872. cumulative += point.percentage / 100;
  43873. }
  43874. end = startAngleRad + (cumulative * circ);
  43875. // set the shape
  43876. var shapeArgs = {
  43877. x: positions[0],
  43878. y: positions[1],
  43879. r: positions[2] / 2,
  43880. innerR: positions[3] / 2,
  43881. start: Math.round(start * precision) / precision,
  43882. end: Math.round(end * precision) / precision
  43883. };
  43884. point.shapeType = 'arc';
  43885. point.shapeArgs = shapeArgs;
  43886. // Used for distance calculation for specific point.
  43887. point.labelDistance = pick((point.options.dataLabels &&
  43888. point.options.dataLabels.distance), labelDistance);
  43889. // Compute point.labelDistance if it's defined as percentage
  43890. // of slice radius (#8854)
  43891. point.labelDistance = relativeLength(point.labelDistance, shapeArgs.r);
  43892. // Saved for later dataLabels distance calculation.
  43893. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  43894. // The angle must stay within -90 and 270 (#2645)
  43895. angle = (end + start) / 2;
  43896. if (angle > 1.5 * Math.PI) {
  43897. angle -= 2 * Math.PI;
  43898. }
  43899. else if (angle < -Math.PI / 2) {
  43900. angle += 2 * Math.PI;
  43901. }
  43902. // Center for the sliced out slice
  43903. point.slicedTranslation = {
  43904. translateX: Math.round(Math.cos(angle) * slicedOffset),
  43905. translateY: Math.round(Math.sin(angle) * slicedOffset)
  43906. };
  43907. // set the anchor point for tooltips
  43908. radiusX = Math.cos(angle) * positions[2] / 2;
  43909. radiusY = Math.sin(angle) * positions[2] / 2;
  43910. point.tooltipPos = [
  43911. positions[0] + radiusX * 0.7,
  43912. positions[1] + radiusY * 0.7
  43913. ];
  43914. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  43915. 1 :
  43916. 0;
  43917. point.angle = angle;
  43918. // Set the anchor point for data labels. Use point.labelDistance
  43919. // instead of labelDistance // #1174
  43920. // finalConnectorOffset - not override connectorOffset value.
  43921. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  43922. point.labelPosition = {
  43923. natural: {
  43924. // initial position of the data label - it's utilized for
  43925. // finding the final position for the label
  43926. x: positions[0] + radiusX + Math.cos(angle) *
  43927. point.labelDistance,
  43928. y: positions[1] + radiusY + Math.sin(angle) *
  43929. point.labelDistance
  43930. },
  43931. 'final': {
  43932. // used for generating connector path -
  43933. // initialized later in drawDataLabels function
  43934. // x: undefined,
  43935. // y: undefined
  43936. },
  43937. // left - pie on the left side of the data label
  43938. // right - pie on the right side of the data label
  43939. // center - data label overlaps the pie
  43940. alignment: point.labelDistance < 0 ?
  43941. 'center' : point.half ? 'right' : 'left',
  43942. connectorPosition: {
  43943. breakAt: {
  43944. x: positions[0] + radiusX + Math.cos(angle) *
  43945. finalConnectorOffset,
  43946. y: positions[1] + radiusY + Math.sin(angle) *
  43947. finalConnectorOffset
  43948. },
  43949. touchingSliceAt: {
  43950. x: positions[0] + radiusX,
  43951. y: positions[1] + radiusY
  43952. }
  43953. }
  43954. };
  43955. }
  43956. fireEvent(series, 'afterTranslate');
  43957. };
  43958. /**
  43959. * Recompute total chart sum and update percentages of points.
  43960. * @private
  43961. */
  43962. PieSeries.prototype.updateTotals = function () {
  43963. var i,
  43964. total = 0,
  43965. points = this.points,
  43966. len = points.length,
  43967. point,
  43968. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  43969. // Get the total sum
  43970. for (i = 0; i < len; i++) {
  43971. point = points[i];
  43972. if (point.isValid() &&
  43973. (!ignoreHiddenPoint || point.visible)) {
  43974. total += point.y;
  43975. }
  43976. }
  43977. this.total = total;
  43978. // Set each point's properties
  43979. for (i = 0; i < len; i++) {
  43980. point = points[i];
  43981. point.percentage =
  43982. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  43983. point.y / total * 100 :
  43984. 0;
  43985. point.total = total;
  43986. }
  43987. };
  43988. /**
  43989. * A pie chart is a circular graphic which is divided into slices to
  43990. * illustrate numerical proportion.
  43991. *
  43992. * @sample highcharts/demo/pie-basic/
  43993. * Pie chart
  43994. *
  43995. * @extends plotOptions.line
  43996. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  43997. * cropThreshold, dashStyle, dataSorting, dragDrop,
  43998. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  43999. * marker, negativeColor, pointInterval, pointIntervalUnit,
  44000. * pointPlacement, pointStart, softThreshold, stacking, step,
  44001. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  44002. * boostBlending
  44003. * @product highcharts
  44004. * @optionparent plotOptions.pie
  44005. */
  44006. PieSeries.defaultOptions = merge(Series.defaultOptions, {
  44007. /**
  44008. * @excluding legendItemClick
  44009. * @apioption plotOptions.pie.events
  44010. */
  44011. /**
  44012. * Fires when the checkbox next to the point name in the legend is
  44013. * clicked. One parameter, event, is passed to the function. The state
  44014. * of the checkbox is found by event.checked. The checked item is found
  44015. * by event.item. Return false to prevent the default action which is to
  44016. * toggle the select state of the series.
  44017. *
  44018. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  44019. * Alert checkbox status
  44020. *
  44021. * @type {Function}
  44022. * @since 1.2.0
  44023. * @product highcharts
  44024. * @context Highcharts.Point
  44025. * @apioption plotOptions.pie.events.checkboxClick
  44026. */
  44027. /**
  44028. * Fires when the legend item belonging to the pie point (slice) is
  44029. * clicked. The `this` keyword refers to the point itself. One
  44030. * parameter, `event`, is passed to the function, containing common
  44031. * event information. The default action is to toggle the visibility of
  44032. * the point. This can be prevented by calling `event.preventDefault()`.
  44033. *
  44034. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  44035. * Confirm toggle visibility
  44036. *
  44037. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  44038. * @since 1.2.0
  44039. * @product highcharts
  44040. * @apioption plotOptions.pie.point.events.legendItemClick
  44041. */
  44042. /**
  44043. * The center of the pie chart relative to the plot area. Can be
  44044. * percentages or pixel values. The default behaviour (as of 3.0) is to
  44045. * center the pie so that all slices and data labels are within the plot
  44046. * area. As a consequence, the pie may actually jump around in a chart
  44047. * with dynamic values, as the data labels move. In that case, the
  44048. * center should be explicitly set, for example to `["50%", "50%"]`.
  44049. *
  44050. * @sample {highcharts} highcharts/plotoptions/pie-center/
  44051. * Centered at 100, 100
  44052. *
  44053. * @type {Array<(number|string|null),(number|string|null)>}
  44054. * @default [null, null]
  44055. * @product highcharts
  44056. *
  44057. * @private
  44058. */
  44059. center: [null, null],
  44060. /**
  44061. * The color of the pie series. A pie series is represented as an empty
  44062. * circle if the total sum of its values is 0. Use this property to
  44063. * define the color of its border.
  44064. *
  44065. * In styled mode, the color can be defined by the
  44066. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  44067. * color can be set with the `.highcharts-series`,
  44068. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  44069. * `.highcharts-series-{n}` class, or individual classes given by the
  44070. * `className` option.
  44071. *
  44072. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44073. * Empty pie series
  44074. *
  44075. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44076. * @default ${palette.neutralColor20}
  44077. * @apioption plotOptions.pie.color
  44078. */
  44079. /**
  44080. * @product highcharts
  44081. *
  44082. * @private
  44083. */
  44084. clip: false,
  44085. /**
  44086. * @ignore-option
  44087. *
  44088. * @private
  44089. */
  44090. colorByPoint: true,
  44091. /**
  44092. * A series specific or series type specific color set to use instead
  44093. * of the global [colors](#colors).
  44094. *
  44095. * @sample {highcharts} highcharts/demo/pie-monochrome/
  44096. * Set default colors for all pies
  44097. *
  44098. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  44099. * @since 3.0
  44100. * @product highcharts
  44101. * @apioption plotOptions.pie.colors
  44102. */
  44103. /**
  44104. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  44105. * @extends plotOptions.series.dataLabels
  44106. * @excluding align, allowOverlap, inside, staggerLines, step
  44107. * @private
  44108. */
  44109. dataLabels: {
  44110. /**
  44111. * Alignment method for data labels. Possible values are:
  44112. *
  44113. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  44114. * the plot area.
  44115. *
  44116. * - `connectors`: Connectors have the same x position and the
  44117. * widest label of each half (left & right) touches the nearest
  44118. * vertical edge of the plot area.
  44119. *
  44120. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  44121. * alignTo: connectors
  44122. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  44123. * alignTo: plotEdges
  44124. *
  44125. * @type {string}
  44126. * @since 7.0.0
  44127. * @product highcharts
  44128. * @apioption plotOptions.pie.dataLabels.alignTo
  44129. */
  44130. allowOverlap: true,
  44131. /**
  44132. * The color of the line connecting the data label to the pie slice.
  44133. * The default color is the same as the point's color.
  44134. *
  44135. * In styled mode, the connector stroke is given in the
  44136. * `.highcharts-data-label-connector` class.
  44137. *
  44138. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  44139. * Blue connectors
  44140. * @sample {highcharts} highcharts/css/pie-point/
  44141. * Styled connectors
  44142. *
  44143. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44144. * @since 2.1
  44145. * @product highcharts
  44146. * @apioption plotOptions.pie.dataLabels.connectorColor
  44147. */
  44148. /**
  44149. * The distance from the data label to the connector. Note that
  44150. * data labels also have a default `padding`, so in order for the
  44151. * connector to touch the text, the `padding` must also be 0.
  44152. *
  44153. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  44154. * No padding
  44155. *
  44156. * @since 2.1
  44157. * @product highcharts
  44158. */
  44159. connectorPadding: 5,
  44160. /**
  44161. * Specifies the method that is used to generate the connector path.
  44162. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  44163. * (default), `'straight'` and `'crookedLine'`. Using
  44164. * `'crookedLine'` has the most sense (in most of the cases) when
  44165. * `'alignTo'` is set.
  44166. *
  44167. * Users can provide their own method by passing a function instead
  44168. * of a String. 3 arguments are passed to the callback:
  44169. *
  44170. * - Object that holds the information about the coordinates of the
  44171. * label (`x` & `y` properties) and how the label is located in
  44172. * relation to the pie (`alignment` property). `alignment` can by
  44173. * one of the following:
  44174. * `'left'` (pie on the left side of the data label),
  44175. * `'right'` (pie on the right side of the data label) or
  44176. * `'center'` (data label overlaps the pie).
  44177. *
  44178. * - Object that holds the information about the position of the
  44179. * connector. Its `touchingSliceAt` porperty tells the position
  44180. * of the place where the connector touches the slice.
  44181. *
  44182. * - Data label options
  44183. *
  44184. * The function has to return an SVG path definition in array form
  44185. * (see the example).
  44186. *
  44187. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  44188. * connectorShape is a String
  44189. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  44190. * connectorShape is a function
  44191. *
  44192. * @type {string|Function}
  44193. * @since 7.0.0
  44194. * @product highcharts
  44195. */
  44196. connectorShape: 'fixedOffset',
  44197. /**
  44198. * The width of the line connecting the data label to the pie slice.
  44199. *
  44200. * In styled mode, the connector stroke width is given in the
  44201. * `.highcharts-data-label-connector` class.
  44202. *
  44203. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  44204. * Disable the connector
  44205. * @sample {highcharts} highcharts/css/pie-point/
  44206. * Styled connectors
  44207. *
  44208. * @type {number}
  44209. * @default 1
  44210. * @since 2.1
  44211. * @product highcharts
  44212. * @apioption plotOptions.pie.dataLabels.connectorWidth
  44213. */
  44214. /**
  44215. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  44216. * far from the vertical plot edge the coonnector path should be
  44217. * crooked.
  44218. *
  44219. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  44220. * crookDistance set to 90%
  44221. *
  44222. * @since 7.0.0
  44223. * @product highcharts
  44224. */
  44225. crookDistance: '70%',
  44226. /**
  44227. * The distance of the data label from the pie's edge. Negative
  44228. * numbers put the data label on top of the pie slices. Can also be
  44229. * defined as a percentage of pie's radius. Connectors are only
  44230. * shown for data labels outside the pie.
  44231. *
  44232. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  44233. * Data labels on top of the pie
  44234. *
  44235. * @type {number|string}
  44236. * @since 2.1
  44237. * @product highcharts
  44238. */
  44239. distance: 30,
  44240. enabled: true,
  44241. /**
  44242. * A
  44243. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  44244. * for the data label. Available variables are the same as for
  44245. * `formatter`.
  44246. *
  44247. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  44248. * Add a unit
  44249. *
  44250. * @type {string}
  44251. * @default undefined
  44252. * @since 3.0
  44253. * @apioption plotOptions.pie.dataLabels.format
  44254. */
  44255. // eslint-disable-next-line valid-jsdoc
  44256. /**
  44257. * Callback JavaScript function to format the data label. Note that
  44258. * if a `format` is defined, the format takes precedence and the
  44259. * formatter is ignored.
  44260. *
  44261. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  44262. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  44263. */
  44264. formatter: function () {
  44265. return this.point.isNull ? void 0 : this.point.name;
  44266. },
  44267. /**
  44268. * Whether to render the connector as a soft arc or a line with
  44269. * sharp break. Works only if `connectorShape` equals to
  44270. * `fixedOffset`.
  44271. *
  44272. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  44273. * Soft
  44274. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  44275. * Non soft
  44276. *
  44277. * @since 2.1.7
  44278. * @product highcharts
  44279. */
  44280. softConnector: true,
  44281. /**
  44282. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  44283. * Long labels truncated with an ellipsis
  44284. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  44285. * Long labels are wrapped
  44286. *
  44287. * @type {Highcharts.CSSObject}
  44288. * @apioption plotOptions.pie.dataLabels.style
  44289. */
  44290. x: 0
  44291. },
  44292. /**
  44293. * If the total sum of the pie's values is 0, the series is represented
  44294. * as an empty circle . The `fillColor` option defines the color of that
  44295. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  44296. * the border thickness.
  44297. *
  44298. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44299. * Empty pie series
  44300. *
  44301. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44302. * @private
  44303. */
  44304. fillColor: void 0,
  44305. /**
  44306. * The end angle of the pie in degrees where 0 is top and 90 is right.
  44307. * Defaults to `startAngle` plus 360.
  44308. *
  44309. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  44310. * Semi-circle donut
  44311. *
  44312. * @type {number}
  44313. * @since 1.3.6
  44314. * @product highcharts
  44315. * @apioption plotOptions.pie.endAngle
  44316. */
  44317. /**
  44318. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  44319. * this option tells whether the series shall be redrawn as if the
  44320. * hidden point were `null`.
  44321. *
  44322. * The default value changed from `false` to `true` with Highcharts
  44323. * 3.0.
  44324. *
  44325. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  44326. * True, the hiddden point is ignored
  44327. *
  44328. * @since 2.3.0
  44329. * @product highcharts
  44330. *
  44331. * @private
  44332. */
  44333. ignoreHiddenPoint: true,
  44334. /**
  44335. * @ignore-option
  44336. *
  44337. * @private
  44338. */
  44339. inactiveOtherPoints: true,
  44340. /**
  44341. * The size of the inner diameter for the pie. A size greater than 0
  44342. * renders a donut chart. Can be a percentage or pixel value.
  44343. * Percentages are relative to the pie size. Pixel values are given as
  44344. * integers.
  44345. *
  44346. *
  44347. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  44348. * area, not the pie size.
  44349. *
  44350. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  44351. * 80px inner size
  44352. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  44353. * 50% of the plot area
  44354. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  44355. * 3D donut
  44356. *
  44357. * @type {number|string}
  44358. * @default 0
  44359. * @since 2.0
  44360. * @product highcharts
  44361. * @apioption plotOptions.pie.innerSize
  44362. */
  44363. /**
  44364. * @ignore-option
  44365. *
  44366. * @private
  44367. */
  44368. legendType: 'point',
  44369. /**
  44370. * @ignore-option
  44371. *
  44372. * @private
  44373. */
  44374. marker: null,
  44375. /**
  44376. * The minimum size for a pie in response to auto margins. The pie will
  44377. * try to shrink to make room for data labels in side the plot area,
  44378. * but only to this size.
  44379. *
  44380. * @type {number|string}
  44381. * @default 80
  44382. * @since 3.0
  44383. * @product highcharts
  44384. * @apioption plotOptions.pie.minSize
  44385. */
  44386. /**
  44387. * The diameter of the pie relative to the plot area. Can be a
  44388. * percentage or pixel value. Pixel values are given as integers. The
  44389. * default behaviour (as of 3.0) is to scale to the plot area and give
  44390. * room for data labels within the plot area.
  44391. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  44392. * default size calculation. As a consequence, the size of the pie may
  44393. * vary when points are updated and data labels more around. In that
  44394. * case it is best to set a fixed value, for example `"75%"`.
  44395. *
  44396. * @sample {highcharts} highcharts/plotoptions/pie-size/
  44397. * Smaller pie
  44398. *
  44399. * @type {number|string|null}
  44400. * @product highcharts
  44401. *
  44402. * @private
  44403. */
  44404. size: null,
  44405. /**
  44406. * Whether to display this particular series or series type in the
  44407. * legend. Since 2.1, pies are not shown in the legend by default.
  44408. *
  44409. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  44410. * One series in the legend, one hidden
  44411. *
  44412. * @product highcharts
  44413. *
  44414. * @private
  44415. */
  44416. showInLegend: false,
  44417. /**
  44418. * If a point is sliced, moved out from the center, how many pixels
  44419. * should it be moved?.
  44420. *
  44421. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  44422. * 20px offset
  44423. *
  44424. * @product highcharts
  44425. *
  44426. * @private
  44427. */
  44428. slicedOffset: 10,
  44429. /**
  44430. * The start angle of the pie slices in degrees where 0 is top and 90
  44431. * right.
  44432. *
  44433. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  44434. * Start from right
  44435. *
  44436. * @type {number}
  44437. * @default 0
  44438. * @since 2.3.4
  44439. * @product highcharts
  44440. * @apioption plotOptions.pie.startAngle
  44441. */
  44442. /**
  44443. * Sticky tracking of mouse events. When true, the `mouseOut` event
  44444. * on a series isn't triggered until the mouse moves over another
  44445. * series, or out of the plot area. When false, the `mouseOut` event on
  44446. * a series is triggered when the mouse leaves the area around the
  44447. * series' graph or markers. This also implies the tooltip. When
  44448. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  44449. * will be hidden when moving the mouse between series.
  44450. *
  44451. * @product highcharts
  44452. *
  44453. * @private
  44454. */
  44455. stickyTracking: false,
  44456. tooltip: {
  44457. followPointer: true
  44458. },
  44459. /**
  44460. * The color of the border surrounding each slice. When `null`, the
  44461. * border takes the same color as the slice fill. This can be used
  44462. * together with a `borderWidth` to fill drawing gaps created by
  44463. * antialiazing artefacts in borderless pies.
  44464. *
  44465. * In styled mode, the border stroke is given in the `.highcharts-point`
  44466. * class.
  44467. *
  44468. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  44469. * Black border
  44470. *
  44471. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44472. * @default #ffffff
  44473. * @product highcharts
  44474. *
  44475. * @private
  44476. */
  44477. borderColor: palette.backgroundColor,
  44478. /**
  44479. * The width of the border surrounding each slice.
  44480. *
  44481. * When setting the border width to 0, there may be small gaps between
  44482. * the slices due to SVG antialiasing artefacts. To work around this,
  44483. * keep the border width at 0.5 or 1, but set the `borderColor` to
  44484. * `null` instead.
  44485. *
  44486. * In styled mode, the border stroke width is given in the
  44487. * `.highcharts-point` class.
  44488. *
  44489. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  44490. * 3px border
  44491. *
  44492. * @product highcharts
  44493. *
  44494. * @private
  44495. */
  44496. borderWidth: 1,
  44497. /**
  44498. * @ignore-options
  44499. * @private
  44500. */
  44501. lineWidth: void 0,
  44502. states: {
  44503. /**
  44504. * @extends plotOptions.series.states.hover
  44505. * @excluding marker, lineWidth, lineWidthPlus
  44506. * @product highcharts
  44507. */
  44508. hover: {
  44509. /**
  44510. * How much to brighten the point on interaction. Requires the
  44511. * main color to be defined in hex or rgb(a) format.
  44512. *
  44513. * In styled mode, the hover brightness is by default replaced
  44514. * by a fill-opacity given in the `.highcharts-point-hover`
  44515. * class.
  44516. *
  44517. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  44518. * Brightened by 0.5
  44519. *
  44520. * @product highcharts
  44521. */
  44522. brightness: 0.1
  44523. }
  44524. }
  44525. });
  44526. return PieSeries;
  44527. }(Series));
  44528. extend(PieSeries.prototype, {
  44529. axisTypes: [],
  44530. directTouch: true,
  44531. drawGraph: void 0,
  44532. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  44533. drawTracker: ColumnSeries.prototype.drawTracker,
  44534. getCenter: CenteredSeriesMixin.getCenter,
  44535. getSymbol: noop,
  44536. isCartesian: false,
  44537. noSharedTooltip: true,
  44538. pointAttribs: ColumnSeries.prototype.pointAttribs,
  44539. pointClass: PiePoint,
  44540. requireSorting: false,
  44541. searchPoint: noop,
  44542. trackerGroups: ['group', 'dataLabelsGroup']
  44543. });
  44544. SeriesRegistry.registerSeriesType('pie', PieSeries);
  44545. /* *
  44546. *
  44547. * Default Export
  44548. *
  44549. * */
  44550. /* *
  44551. *
  44552. * API Options
  44553. *
  44554. * */
  44555. /**
  44556. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  44557. * it is inherited from [chart.type](#chart.type).
  44558. *
  44559. * @extends series,plotOptions.pie
  44560. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  44561. * dataSorting, step, boostThreshold, boostBlending
  44562. * @product highcharts
  44563. * @apioption series.pie
  44564. */
  44565. /**
  44566. * An array of data points for the series. For the `pie` series type,
  44567. * points can be given in the following ways:
  44568. *
  44569. * 1. An array of numerical values. In this case, the numerical values will be
  44570. * interpreted as `y` options. Example:
  44571. * ```js
  44572. * data: [0, 5, 3, 5]
  44573. * ```
  44574. *
  44575. * 2. An array of objects with named values. The following snippet shows only a
  44576. * few settings, see the complete options set below. If the total number of
  44577. * data points exceeds the series'
  44578. * [turboThreshold](#series.pie.turboThreshold),
  44579. * this option is not available.
  44580. * ```js
  44581. * data: [{
  44582. * y: 1,
  44583. * name: "Point2",
  44584. * color: "#00FF00"
  44585. * }, {
  44586. * y: 7,
  44587. * name: "Point1",
  44588. * color: "#FF00FF"
  44589. * }]
  44590. * ```
  44591. *
  44592. * @sample {highcharts} highcharts/chart/reflow-true/
  44593. * Numerical values
  44594. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  44595. * Arrays of numeric x and y
  44596. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  44597. * Arrays of datetime x and y
  44598. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  44599. * Arrays of point.name and y
  44600. * @sample {highcharts} highcharts/series/data-array-of-objects/
  44601. * Config objects
  44602. *
  44603. * @type {Array<number|Array<string,(number|null)>|null|*>}
  44604. * @extends series.line.data
  44605. * @excluding marker, x
  44606. * @product highcharts
  44607. * @apioption series.pie.data
  44608. */
  44609. /**
  44610. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  44611. * @product highcharts
  44612. * @apioption series.pie.data.dataLabels
  44613. */
  44614. /**
  44615. * The sequential index of the data point in the legend.
  44616. *
  44617. * @type {number}
  44618. * @product highcharts
  44619. * @apioption series.pie.data.legendIndex
  44620. */
  44621. /**
  44622. * Whether to display a slice offset from the center.
  44623. *
  44624. * @sample {highcharts} highcharts/point/sliced/
  44625. * One sliced point
  44626. *
  44627. * @type {boolean}
  44628. * @product highcharts
  44629. * @apioption series.pie.data.sliced
  44630. */
  44631. /**
  44632. * @extends plotOptions.pie.dataLabels
  44633. * @excluding align, allowOverlap, inside, staggerLines, step
  44634. * @product highcharts
  44635. * @apioption series.pie.dataLabels
  44636. */
  44637. /**
  44638. * @excluding legendItemClick
  44639. * @product highcharts
  44640. * @apioption series.pie.events
  44641. */
  44642. ''; // placeholder for transpiled doclets above
  44643. return PieSeries;
  44644. });
  44645. _registerModule(_modules, 'Core/Series/DataLabels.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, F, H, palette, Series, SeriesRegistry, U) {
  44646. /* *
  44647. *
  44648. * (c) 2010-2021 Torstein Honsi
  44649. *
  44650. * License: www.highcharts.com/license
  44651. *
  44652. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44653. *
  44654. * */
  44655. var getDeferredAnimation = A.getDeferredAnimation;
  44656. var format = F.format;
  44657. var noop = H.noop;
  44658. var seriesTypes = SeriesRegistry.seriesTypes;
  44659. var arrayMax = U.arrayMax,
  44660. clamp = U.clamp,
  44661. defined = U.defined,
  44662. extend = U.extend,
  44663. fireEvent = U.fireEvent,
  44664. isArray = U.isArray,
  44665. merge = U.merge,
  44666. objectEach = U.objectEach,
  44667. pick = U.pick,
  44668. relativeLength = U.relativeLength,
  44669. splat = U.splat,
  44670. stableSort = U.stableSort;
  44671. /**
  44672. * Callback JavaScript function to format the data label as a string. Note that
  44673. * if a `format` is defined, the format takes precedence and the formatter is
  44674. * ignored.
  44675. *
  44676. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  44677. *
  44678. * @param {Highcharts.PointLabelObject} this
  44679. * Data label context to format
  44680. *
  44681. * @param {Highcharts.DataLabelsOptions} options
  44682. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  44683. *
  44684. * @return {number|string|null|undefined}
  44685. * Formatted data label text
  44686. */
  44687. /**
  44688. * Values for handling data labels that flow outside the plot area.
  44689. *
  44690. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  44691. */
  44692. ''; // detach doclets above
  44693. /* eslint-disable valid-jsdoc */
  44694. /**
  44695. * General distribution algorithm for distributing labels of differing size
  44696. * along a confined length in two dimensions. The algorithm takes an array of
  44697. * objects containing a size, a target and a rank. It will place the labels as
  44698. * close as possible to their targets, skipping the lowest ranked labels if
  44699. * necessary.
  44700. *
  44701. * @private
  44702. * @function Highcharts.distribute
  44703. * @param {Highcharts.DataLabelsBoxArray} boxes
  44704. * @param {number} len
  44705. * @param {number} [maxDistance]
  44706. * @return {void}
  44707. */
  44708. H.distribute = function (boxes, len, maxDistance) {
  44709. var i,
  44710. overlapping = true,
  44711. origBoxes = boxes, // Original array will be altered with added .pos
  44712. restBoxes = [], // The outranked overshoot
  44713. box,
  44714. target,
  44715. total = 0,
  44716. reducedLen = origBoxes.reducedLen || len;
  44717. /**
  44718. * @private
  44719. */
  44720. function sortByTarget(a, b) {
  44721. return a.target - b.target;
  44722. }
  44723. // If the total size exceeds the len, remove those boxes with the lowest
  44724. // rank
  44725. i = boxes.length;
  44726. while (i--) {
  44727. total += boxes[i].size;
  44728. }
  44729. // Sort by rank, then slice away overshoot
  44730. if (total > reducedLen) {
  44731. stableSort(boxes, function (a, b) {
  44732. return (b.rank || 0) - (a.rank || 0);
  44733. });
  44734. i = 0;
  44735. total = 0;
  44736. while (total <= reducedLen) {
  44737. total += boxes[i].size;
  44738. i++;
  44739. }
  44740. restBoxes = boxes.splice(i - 1, boxes.length);
  44741. }
  44742. // Order by target
  44743. stableSort(boxes, sortByTarget);
  44744. // So far we have been mutating the original array. Now
  44745. // create a copy with target arrays
  44746. boxes = boxes.map(function (box) {
  44747. return {
  44748. size: box.size,
  44749. targets: [box.target],
  44750. align: pick(box.align, 0.5)
  44751. };
  44752. });
  44753. while (overlapping) {
  44754. // Initial positions: target centered in box
  44755. i = boxes.length;
  44756. while (i--) {
  44757. box = boxes[i];
  44758. // Composite box, average of targets
  44759. target = (Math.min.apply(0, box.targets) +
  44760. Math.max.apply(0, box.targets)) / 2;
  44761. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  44762. }
  44763. // Detect overlap and join boxes
  44764. i = boxes.length;
  44765. overlapping = false;
  44766. while (i--) {
  44767. // Overlap
  44768. if (i > 0 &&
  44769. boxes[i - 1].pos + boxes[i - 1].size >
  44770. boxes[i].pos) {
  44771. // Add this size to the previous box
  44772. boxes[i - 1].size += boxes[i].size;
  44773. boxes[i - 1].targets = boxes[i - 1]
  44774. .targets
  44775. .concat(boxes[i].targets);
  44776. boxes[i - 1].align = 0.5;
  44777. // Overlapping right, push left
  44778. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  44779. boxes[i - 1].pos = len - boxes[i - 1].size;
  44780. }
  44781. boxes.splice(i, 1); // Remove this item
  44782. overlapping = true;
  44783. }
  44784. }
  44785. }
  44786. // Add the rest (hidden boxes)
  44787. origBoxes.push.apply(origBoxes, restBoxes);
  44788. // Now the composite boxes are placed, we need to put the original boxes
  44789. // within them
  44790. i = 0;
  44791. boxes.some(function (box) {
  44792. var posInCompositeBox = 0;
  44793. if (box.targets.some(function () {
  44794. origBoxes[i].pos = box.pos + posInCompositeBox;
  44795. // If the distance between the position and the target exceeds
  44796. // maxDistance, abort the loop and decrease the length in increments
  44797. // of 10% to recursively reduce the number of visible boxes by
  44798. // rank. Once all boxes are within the maxDistance, we're good.
  44799. if (typeof maxDistance !== 'undefined' &&
  44800. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  44801. // Reset the positions that are already set
  44802. origBoxes.slice(0, i + 1).forEach(function (box) {
  44803. delete box.pos;
  44804. });
  44805. // Try with a smaller length
  44806. origBoxes.reducedLen =
  44807. (origBoxes.reducedLen || len) - (len * 0.1);
  44808. // Recurse
  44809. if (origBoxes.reducedLen > len * 0.1) {
  44810. H.distribute(origBoxes, len, maxDistance);
  44811. }
  44812. // Exceeded maxDistance => abort
  44813. return true;
  44814. }
  44815. posInCompositeBox += origBoxes[i].size;
  44816. i++;
  44817. })) {
  44818. // Exceeded maxDistance => abort
  44819. return true;
  44820. }
  44821. });
  44822. // Add the rest (hidden) boxes and sort by target
  44823. stableSort(origBoxes, sortByTarget);
  44824. };
  44825. /**
  44826. * Draw the data labels
  44827. *
  44828. * @private
  44829. * @function Highcharts.Series#drawDataLabels
  44830. * @return {void}
  44831. * @fires Highcharts.Series#event:afterDrawDataLabels
  44832. */
  44833. Series.prototype.drawDataLabels = function () {
  44834. var series = this,
  44835. chart = series.chart,
  44836. seriesOptions = series.options,
  44837. seriesDlOptions = seriesOptions.dataLabels,
  44838. points = series.points,
  44839. pointOptions,
  44840. hasRendered = series.hasRendered || 0,
  44841. dataLabelsGroup,
  44842. dataLabelAnim = seriesDlOptions.animation,
  44843. animationConfig = seriesDlOptions.defer ?
  44844. getDeferredAnimation(chart,
  44845. dataLabelAnim,
  44846. series) :
  44847. { defer: 0,
  44848. duration: 0 },
  44849. renderer = chart.renderer;
  44850. /**
  44851. * Handle the dataLabels.filter option.
  44852. * @private
  44853. */
  44854. function applyFilter(point, options) {
  44855. var filter = options.filter,
  44856. op,
  44857. prop,
  44858. val;
  44859. if (filter) {
  44860. op = filter.operator;
  44861. prop = point[filter.property];
  44862. val = filter.value;
  44863. if ((op === '>' && prop > val) ||
  44864. (op === '<' && prop < val) ||
  44865. (op === '>=' && prop >= val) ||
  44866. (op === '<=' && prop <= val) ||
  44867. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  44868. (op === '===' && prop === val)) {
  44869. return true;
  44870. }
  44871. return false;
  44872. }
  44873. return true;
  44874. }
  44875. /**
  44876. * Merge two objects that can be arrays. If one of them is an array, the
  44877. * other is merged into each element. If both are arrays, each element is
  44878. * merged by index. If neither are arrays, we use normal merge.
  44879. * @private
  44880. */
  44881. function mergeArrays(one, two) {
  44882. var res = [],
  44883. i;
  44884. if (isArray(one) && !isArray(two)) {
  44885. res = one.map(function (el) {
  44886. return merge(el, two);
  44887. });
  44888. }
  44889. else if (isArray(two) && !isArray(one)) {
  44890. res = two.map(function (el) {
  44891. return merge(one, el);
  44892. });
  44893. }
  44894. else if (!isArray(one) && !isArray(two)) {
  44895. res = merge(one, two);
  44896. }
  44897. else {
  44898. i = Math.max(one.length, two.length);
  44899. while (i--) {
  44900. res[i] = merge(one[i], two[i]);
  44901. }
  44902. }
  44903. return res;
  44904. }
  44905. // Merge in plotOptions.dataLabels for series
  44906. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  44907. chart.options.plotOptions.series &&
  44908. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  44909. chart.options.plotOptions[series.type] &&
  44910. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  44911. fireEvent(this, 'drawDataLabels');
  44912. if (isArray(seriesDlOptions) ||
  44913. seriesDlOptions.enabled ||
  44914. series._hasPointLabels) {
  44915. // Create a separate group for the data labels to avoid rotation
  44916. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  44917. seriesDlOptions.zIndex || 6);
  44918. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  44919. if (!hasRendered) {
  44920. var group = series.dataLabelsGroup;
  44921. if (group) {
  44922. if (series.visible) { // #2597, #3023, #3024
  44923. dataLabelsGroup.show(true);
  44924. }
  44925. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  44926. }
  44927. }
  44928. // Make the labels for each point
  44929. points.forEach(function (point) {
  44930. // Merge in series options for the point.
  44931. // @note dataLabelAttribs (like pointAttribs) would eradicate
  44932. // the need for dlOptions, and simplify the section below.
  44933. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  44934. (point.options && point.options.dataLabels)));
  44935. // Handle each individual data label for this point
  44936. pointOptions.forEach(function (labelOptions, i) {
  44937. // Options for one datalabel
  44938. var labelEnabled = (labelOptions.enabled &&
  44939. // #2282, #4641, #7112, #10049
  44940. (!point.isNull || point.dataLabelOnNull) &&
  44941. applyFilter(point,
  44942. labelOptions)),
  44943. labelConfig,
  44944. formatString,
  44945. labelText,
  44946. style,
  44947. rotation,
  44948. attr,
  44949. dataLabel = point.dataLabels ? point.dataLabels[i] :
  44950. point.dataLabel,
  44951. connector = point.connectors ? point.connectors[i] :
  44952. point.connector,
  44953. labelDistance = pick(labelOptions.distance,
  44954. point.labelDistance),
  44955. isNew = !dataLabel;
  44956. if (labelEnabled) {
  44957. // Create individual options structure that can be extended
  44958. // without affecting others
  44959. labelConfig = point.getLabelConfig();
  44960. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  44961. labelText = defined(formatString) ?
  44962. format(formatString, labelConfig, chart) :
  44963. (labelOptions[point.formatPrefix + 'Formatter'] ||
  44964. labelOptions.formatter).call(labelConfig, labelOptions);
  44965. style = labelOptions.style;
  44966. rotation = labelOptions.rotation;
  44967. if (!chart.styledMode) {
  44968. // Determine the color
  44969. style.color = pick(labelOptions.color, style.color, series.color, palette.neutralColor100);
  44970. // Get automated contrast color
  44971. if (style.color === 'contrast') {
  44972. point.contrastColor = renderer.getContrast((point.color || series.color));
  44973. style.color = (!defined(labelDistance) &&
  44974. labelOptions.inside) ||
  44975. labelDistance < 0 ||
  44976. !!seriesOptions.stacking ?
  44977. point.contrastColor :
  44978. palette.neutralColor100;
  44979. }
  44980. else {
  44981. delete point.contrastColor;
  44982. }
  44983. if (seriesOptions.cursor) {
  44984. style.cursor = seriesOptions.cursor;
  44985. }
  44986. }
  44987. attr = {
  44988. r: labelOptions.borderRadius || 0,
  44989. rotation: rotation,
  44990. padding: labelOptions.padding,
  44991. zIndex: 1
  44992. };
  44993. if (!chart.styledMode) {
  44994. attr.fill = labelOptions.backgroundColor;
  44995. attr.stroke = labelOptions.borderColor;
  44996. attr['stroke-width'] = labelOptions.borderWidth;
  44997. }
  44998. // Remove unused attributes (#947)
  44999. objectEach(attr, function (val, name) {
  45000. if (typeof val === 'undefined') {
  45001. delete attr[name];
  45002. }
  45003. });
  45004. }
  45005. // If the point is outside the plot area, destroy it. #678, #820
  45006. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  45007. point.dataLabel =
  45008. point.dataLabel && point.dataLabel.destroy();
  45009. if (point.dataLabels) {
  45010. // Remove point.dataLabels if this was the last one
  45011. if (point.dataLabels.length === 1) {
  45012. delete point.dataLabels;
  45013. }
  45014. else {
  45015. delete point.dataLabels[i];
  45016. }
  45017. }
  45018. if (!i) {
  45019. delete point.dataLabel;
  45020. }
  45021. if (connector) {
  45022. point.connector = point.connector.destroy();
  45023. if (point.connectors) {
  45024. // Remove point.connectors if this was the last one
  45025. if (point.connectors.length === 1) {
  45026. delete point.connectors;
  45027. }
  45028. else {
  45029. delete point.connectors[i];
  45030. }
  45031. }
  45032. }
  45033. // Individual labels are disabled if the are explicitly disabled
  45034. // in the point options, or if they fall outside the plot area.
  45035. }
  45036. else if (labelEnabled && defined(labelText)) {
  45037. if (!dataLabel) {
  45038. // Create new label element
  45039. point.dataLabels = point.dataLabels || [];
  45040. dataLabel = point.dataLabels[i] = rotation ?
  45041. // Labels don't rotate, use text element
  45042. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  45043. .addClass('highcharts-data-label') :
  45044. // We can use label
  45045. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  45046. // Store for backwards compatibility
  45047. if (!i) {
  45048. point.dataLabel = dataLabel;
  45049. }
  45050. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  45051. ' ' + (labelOptions.className || '') +
  45052. ( // #3398
  45053. labelOptions.useHTML ?
  45054. ' highcharts-tracker' :
  45055. ''));
  45056. }
  45057. else {
  45058. // Use old element and just update text
  45059. attr.text = labelText;
  45060. }
  45061. // Store data label options for later access
  45062. dataLabel.options = labelOptions;
  45063. dataLabel.attr(attr);
  45064. if (!chart.styledMode) {
  45065. // Styles must be applied before add in order to read
  45066. // text bounding box
  45067. dataLabel.css(style).shadow(labelOptions.shadow);
  45068. }
  45069. if (!dataLabel.added) {
  45070. dataLabel.add(dataLabelsGroup);
  45071. }
  45072. if (labelOptions.textPath && !labelOptions.useHTML) {
  45073. dataLabel.setTextPath((point.getDataLabelPath &&
  45074. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  45075. if (point.dataLabelPath &&
  45076. !labelOptions.textPath.enabled) {
  45077. // clean the DOM
  45078. point.dataLabelPath = point.dataLabelPath.destroy();
  45079. }
  45080. }
  45081. // Now the data label is created and placed at 0,0, so we
  45082. // need to align it
  45083. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  45084. }
  45085. });
  45086. });
  45087. }
  45088. fireEvent(this, 'afterDrawDataLabels');
  45089. };
  45090. /**
  45091. * Align each individual data label.
  45092. *
  45093. * @private
  45094. * @function Highcharts.Series#alignDataLabel
  45095. * @param {Highcharts.Point} point
  45096. * @param {Highcharts.SVGElement} dataLabel
  45097. * @param {Highcharts.DataLabelsOptions} options
  45098. * @param {Highcharts.BBoxObject} alignTo
  45099. * @param {boolean} [isNew]
  45100. * @return {void}
  45101. */
  45102. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45103. var series = this,
  45104. chart = this.chart,
  45105. inverted = this.isCartesian && chart.inverted,
  45106. enabledDataSorting = this.enabledDataSorting,
  45107. plotX = pick(point.dlBox && point.dlBox.centerX,
  45108. point.plotX, -9999),
  45109. plotY = pick(point.plotY, -9999),
  45110. bBox = dataLabel.getBBox(),
  45111. baseline,
  45112. rotation = options.rotation,
  45113. normRotation,
  45114. negRotation,
  45115. align = options.align,
  45116. rotCorr, // rotation correction
  45117. isInsidePlot = chart.isInsidePlot(plotX,
  45118. Math.round(plotY), {
  45119. inverted: inverted,
  45120. paneCoordinates: true,
  45121. series: series
  45122. }),
  45123. // Math.round for rounding errors (#2683), alignTo to allow column
  45124. // labels (#2700)
  45125. alignAttr, // the final position;
  45126. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  45127. point.visible !== false &&
  45128. (point.series.forceDL ||
  45129. (enabledDataSorting && !justify) ||
  45130. isInsidePlot ||
  45131. (
  45132. // If the data label is inside the align box, it is enough
  45133. // that parts of the align box is inside the plot area
  45134. // (#12370). When stacking, it is always inside regardless
  45135. // of the option (#15148).
  45136. pick(options.inside, !!this.options.stacking) &&
  45137. alignTo &&
  45138. chart.isInsidePlot(plotX, inverted ?
  45139. alignTo.x + 1 :
  45140. alignTo.y + alignTo.height - 1, {
  45141. inverted: inverted,
  45142. paneCoordinates: true,
  45143. series: series
  45144. }))), setStartPos = function (alignOptions) {
  45145. if (enabledDataSorting && series.xAxis && !justify) {
  45146. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  45147. }
  45148. };
  45149. if (visible) {
  45150. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  45151. // The alignment box is a singular point
  45152. alignTo = extend({
  45153. x: inverted ? this.yAxis.len - plotY : plotX,
  45154. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  45155. width: 0,
  45156. height: 0
  45157. }, alignTo);
  45158. // Add the text size for alignment calculation
  45159. extend(options, {
  45160. width: bBox.width,
  45161. height: bBox.height
  45162. });
  45163. // Allow a hook for changing alignment in the last moment, then do the
  45164. // alignment
  45165. if (rotation) {
  45166. justify = false; // Not supported for rotated text
  45167. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  45168. alignAttr = {
  45169. x: (alignTo.x +
  45170. (options.x || 0) +
  45171. alignTo.width / 2 +
  45172. rotCorr.x),
  45173. y: (alignTo.y +
  45174. (options.y || 0) +
  45175. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  45176. alignTo.height)
  45177. };
  45178. setStartPos(alignAttr); // data sorting
  45179. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  45180. .attr({
  45181. align: align
  45182. });
  45183. // Compensate for the rotated label sticking out on the sides
  45184. normRotation = (rotation + 720) % 360;
  45185. negRotation = normRotation > 180 && normRotation < 360;
  45186. if (align === 'left') {
  45187. alignAttr.y -= negRotation ? bBox.height : 0;
  45188. }
  45189. else if (align === 'center') {
  45190. alignAttr.x -= bBox.width / 2;
  45191. alignAttr.y -= bBox.height / 2;
  45192. }
  45193. else if (align === 'right') {
  45194. alignAttr.x -= bBox.width;
  45195. alignAttr.y -= negRotation ? 0 : bBox.height;
  45196. }
  45197. dataLabel.placed = true;
  45198. dataLabel.alignAttr = alignAttr;
  45199. }
  45200. else {
  45201. setStartPos(alignTo); // data sorting
  45202. dataLabel.align(options, void 0, alignTo);
  45203. alignAttr = dataLabel.alignAttr;
  45204. }
  45205. // Handle justify or crop
  45206. if (justify && alignTo.height >= 0) { // #8830
  45207. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  45208. // Now check that the data label is within the plot area
  45209. }
  45210. else if (pick(options.crop, true)) {
  45211. visible =
  45212. chart.isInsidePlot(alignAttr.x, alignAttr.y, {
  45213. paneCoordinates: true,
  45214. series: series
  45215. }) &&
  45216. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height, {
  45217. paneCoordinates: true,
  45218. series: series
  45219. });
  45220. }
  45221. // When we're using a shape, make it possible with a connector or an
  45222. // arrow pointing to thie point
  45223. if (options.shape && !rotation) {
  45224. dataLabel[isNew ? 'attr' : 'animate']({
  45225. anchorX: inverted ?
  45226. chart.plotWidth - point.plotY :
  45227. point.plotX,
  45228. anchorY: inverted ?
  45229. chart.plotHeight - point.plotX :
  45230. point.plotY
  45231. });
  45232. }
  45233. }
  45234. // To use alignAttr property in hideOverlappingLabels
  45235. if (isNew && enabledDataSorting) {
  45236. dataLabel.placed = false;
  45237. }
  45238. // Show or hide based on the final aligned position
  45239. if (!visible && (!enabledDataSorting || justify)) {
  45240. dataLabel.hide(true);
  45241. dataLabel.placed = false; // don't animate back in
  45242. }
  45243. };
  45244. /**
  45245. * Set starting position for data label sorting animation.
  45246. *
  45247. * @private
  45248. * @function Highcharts.Series#setDataLabelStartPos
  45249. * @param {Highcharts.SVGElement} dataLabel
  45250. * @param {Highcharts.ColumnPoint} point
  45251. * @param {boolean | undefined} [isNew]
  45252. * @param {boolean} [isInside]
  45253. * @param {Highcharts.AlignObject} [alignOptions]
  45254. *
  45255. * @return {void}
  45256. */
  45257. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  45258. var chart = this.chart,
  45259. inverted = chart.inverted,
  45260. xAxis = this.xAxis,
  45261. reversed = xAxis.reversed,
  45262. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  45263. pointWidth = point.pointWidth,
  45264. halfWidth = pointWidth ? pointWidth / 2 : 0,
  45265. startXPos,
  45266. startYPos;
  45267. startXPos = inverted ?
  45268. alignOptions.x :
  45269. (reversed ?
  45270. -labelCenter - halfWidth :
  45271. xAxis.width - labelCenter + halfWidth);
  45272. startYPos = inverted ?
  45273. (reversed ?
  45274. this.yAxis.height - labelCenter + halfWidth :
  45275. -labelCenter - halfWidth) : alignOptions.y;
  45276. dataLabel.startXPos = startXPos;
  45277. dataLabel.startYPos = startYPos;
  45278. // We need to handle visibility in case of sorting point outside plot area
  45279. if (!isInside) {
  45280. dataLabel
  45281. .attr({ opacity: 1 })
  45282. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  45283. }
  45284. else if (dataLabel.visibility === 'hidden') {
  45285. dataLabel.show();
  45286. dataLabel
  45287. .attr({ opacity: 0 })
  45288. .animate({ opacity: 1 });
  45289. }
  45290. // Save start position on first render, but do not change position
  45291. if (!chart.hasRendered) {
  45292. return;
  45293. }
  45294. // Set start position
  45295. if (isNew) {
  45296. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  45297. }
  45298. dataLabel.placed = true;
  45299. };
  45300. /**
  45301. * If data labels fall partly outside the plot area, align them back in, in a
  45302. * way that doesn't hide the point.
  45303. *
  45304. * @private
  45305. * @function Highcharts.Series#justifyDataLabel
  45306. * @param {Highcharts.SVGElement} dataLabel
  45307. * @param {Highcharts.DataLabelsOptions} options
  45308. * @param {Highcharts.SVGAttributes} alignAttr
  45309. * @param {Highcharts.BBoxObject} bBox
  45310. * @param {Highcharts.BBoxObject} [alignTo]
  45311. * @param {boolean} [isNew]
  45312. * @return {boolean|undefined}
  45313. */
  45314. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  45315. var chart = this.chart,
  45316. align = options.align,
  45317. verticalAlign = options.verticalAlign,
  45318. off,
  45319. justified,
  45320. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  45321. var _a = options.x,
  45322. x = _a === void 0 ? 0 : _a,
  45323. _b = options.y,
  45324. y = _b === void 0 ? 0 : _b;
  45325. // Off left
  45326. off = (alignAttr.x || 0) + padding;
  45327. if (off < 0) {
  45328. if (align === 'right' && x >= 0) {
  45329. options.align = 'left';
  45330. options.inside = true;
  45331. }
  45332. else {
  45333. x -= off;
  45334. }
  45335. justified = true;
  45336. }
  45337. // Off right
  45338. off = (alignAttr.x || 0) + bBox.width - padding;
  45339. if (off > chart.plotWidth) {
  45340. if (align === 'left' && x <= 0) {
  45341. options.align = 'right';
  45342. options.inside = true;
  45343. }
  45344. else {
  45345. x += chart.plotWidth - off;
  45346. }
  45347. justified = true;
  45348. }
  45349. // Off top
  45350. off = alignAttr.y + padding;
  45351. if (off < 0) {
  45352. if (verticalAlign === 'bottom' && y >= 0) {
  45353. options.verticalAlign = 'top';
  45354. options.inside = true;
  45355. }
  45356. else {
  45357. y -= off;
  45358. }
  45359. justified = true;
  45360. }
  45361. // Off bottom
  45362. off = (alignAttr.y || 0) + bBox.height - padding;
  45363. if (off > chart.plotHeight) {
  45364. if (verticalAlign === 'top' && y <= 0) {
  45365. options.verticalAlign = 'bottom';
  45366. options.inside = true;
  45367. }
  45368. else {
  45369. y += chart.plotHeight - off;
  45370. }
  45371. justified = true;
  45372. }
  45373. if (justified) {
  45374. options.x = x;
  45375. options.y = y;
  45376. dataLabel.placed = !isNew;
  45377. dataLabel.align(options, void 0, alignTo);
  45378. }
  45379. return justified;
  45380. };
  45381. if (seriesTypes.pie) {
  45382. seriesTypes.pie.prototype.dataLabelPositioners = {
  45383. // Based on the value computed in Highcharts' distribute algorithm.
  45384. radialDistributionY: function (point) {
  45385. return point.top + point.distributeBox.pos;
  45386. },
  45387. // get the x - use the natural x position for labels near the
  45388. // top and bottom, to prevent the top and botton slice
  45389. // connectors from touching each other on either side
  45390. // Based on the value computed in Highcharts' distribute algorithm.
  45391. radialDistributionX: function (series, point, y, naturalY) {
  45392. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  45393. naturalY :
  45394. y, point.half, point);
  45395. },
  45396. // dataLabels.distance determines the x position of the label
  45397. justify: function (point, radius, seriesCenter) {
  45398. return seriesCenter[0] + (point.half ? -1 : 1) *
  45399. (radius + point.labelDistance);
  45400. },
  45401. // Left edges of the left-half labels touch the left edge of the plot
  45402. // area. Right edges of the right-half labels touch the right edge of
  45403. // the plot area.
  45404. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  45405. var dataLabelWidth = dataLabel.getBBox().width;
  45406. return half ? dataLabelWidth + plotLeft :
  45407. plotWidth - dataLabelWidth - plotLeft;
  45408. },
  45409. // Connectors of each side end in the same x position. Labels are
  45410. // aligned to them. Left edge of the widest left-half label touches the
  45411. // left edge of the plot area. Right edge of the widest right-half label
  45412. // touches the right edge of the plot area.
  45413. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  45414. var maxDataLabelWidth = 0,
  45415. dataLabelWidth;
  45416. // find widest data label
  45417. points.forEach(function (point) {
  45418. dataLabelWidth = point.dataLabel.getBBox().width;
  45419. if (dataLabelWidth > maxDataLabelWidth) {
  45420. maxDataLabelWidth = dataLabelWidth;
  45421. }
  45422. });
  45423. return half ? maxDataLabelWidth + plotLeft :
  45424. plotWidth - maxDataLabelWidth - plotLeft;
  45425. }
  45426. };
  45427. /**
  45428. * Override the base drawDataLabels method by pie specific functionality
  45429. *
  45430. * @private
  45431. * @function Highcharts.seriesTypes.pie#drawDataLabels
  45432. * @return {void}
  45433. */
  45434. seriesTypes.pie.prototype.drawDataLabels = function () {
  45435. var series = this,
  45436. data = series.data,
  45437. point,
  45438. chart = series.chart,
  45439. options = series.options.dataLabels || {},
  45440. connectorPadding = options.connectorPadding,
  45441. connectorWidth,
  45442. plotWidth = chart.plotWidth,
  45443. plotHeight = chart.plotHeight,
  45444. plotLeft = chart.plotLeft,
  45445. maxWidth = Math.round(chart.chartWidth / 3),
  45446. connector,
  45447. seriesCenter = series.center,
  45448. radius = seriesCenter[2] / 2,
  45449. centerY = seriesCenter[1],
  45450. dataLabel,
  45451. dataLabelWidth,
  45452. // labelPos,
  45453. labelPosition,
  45454. labelHeight,
  45455. // divide the points into right and left halves for anti collision
  45456. halves = [
  45457. [],
  45458. [] // left
  45459. ],
  45460. x,
  45461. y,
  45462. visibility,
  45463. j,
  45464. overflow = [0, 0, 0, 0], // top, right, bottom, left
  45465. dataLabelPositioners = series.dataLabelPositioners,
  45466. pointDataLabelsOptions;
  45467. // get out if not enabled
  45468. if (!series.visible ||
  45469. (!options.enabled &&
  45470. !series._hasPointLabels)) {
  45471. return;
  45472. }
  45473. // Reset all labels that have been shortened
  45474. data.forEach(function (point) {
  45475. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  45476. point.dataLabel
  45477. .attr({
  45478. width: 'auto'
  45479. }).css({
  45480. width: 'auto',
  45481. textOverflow: 'clip'
  45482. });
  45483. point.dataLabel.shortened = false;
  45484. }
  45485. });
  45486. // run parent method
  45487. Series.prototype.drawDataLabels.apply(series);
  45488. data.forEach(function (point) {
  45489. if (point.dataLabel) {
  45490. if (point.visible) { // #407, #2510
  45491. // Arrange points for detection collision
  45492. halves[point.half].push(point);
  45493. // Reset positions (#4905)
  45494. point.dataLabel._pos = null;
  45495. // Avoid long labels squeezing the pie size too far down
  45496. if (!defined(options.style.width) &&
  45497. !defined(point.options.dataLabels &&
  45498. point.options.dataLabels.style &&
  45499. point.options.dataLabels.style.width)) {
  45500. if (point.dataLabel.getBBox().width > maxWidth) {
  45501. point.dataLabel.css({
  45502. // Use a fraction of the maxWidth to avoid
  45503. // wrapping close to the end of the string.
  45504. width: Math.round(maxWidth * 0.7) + 'px'
  45505. });
  45506. point.dataLabel.shortened = true;
  45507. }
  45508. }
  45509. }
  45510. else {
  45511. point.dataLabel = point.dataLabel.destroy();
  45512. // Workaround to make pies destroy multiple datalabels
  45513. // correctly. This logic needs rewriting to support multiple
  45514. // datalabels fully.
  45515. if (point.dataLabels && point.dataLabels.length === 1) {
  45516. delete point.dataLabels;
  45517. }
  45518. }
  45519. }
  45520. });
  45521. /* Loop over the points in each half, starting from the top and bottom
  45522. * of the pie to detect overlapping labels.
  45523. */
  45524. halves.forEach(function (points, i) {
  45525. var top,
  45526. bottom,
  45527. length = points.length,
  45528. positions = [],
  45529. naturalY,
  45530. sideOverflow,
  45531. size,
  45532. distributionLength;
  45533. if (!length) {
  45534. return;
  45535. }
  45536. // Sort by angle
  45537. series.sortByAngle(points, i - 0.5);
  45538. // Only do anti-collision when we have dataLabels outside the pie
  45539. // and have connectors. (#856)
  45540. if (series.maxLabelDistance > 0) {
  45541. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  45542. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  45543. points.forEach(function (point) {
  45544. // check if specific points' label is outside the pie
  45545. if (point.labelDistance > 0 && point.dataLabel) {
  45546. // point.top depends on point.labelDistance value
  45547. // Used for calculation of y value in getX method
  45548. point.top = Math.max(0, centerY - radius - point.labelDistance);
  45549. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  45550. size = point.dataLabel.getBBox().height || 21;
  45551. // point.positionsIndex is needed for getting index of
  45552. // parameter related to specific point inside positions
  45553. // array - not every point is in positions array.
  45554. point.distributeBox = {
  45555. target: point.labelPosition.natural.y -
  45556. point.top + size / 2,
  45557. size: size,
  45558. rank: point.y
  45559. };
  45560. positions.push(point.distributeBox);
  45561. }
  45562. });
  45563. distributionLength = bottom + size - top;
  45564. H.distribute(positions, distributionLength, distributionLength / 5);
  45565. }
  45566. // Now the used slots are sorted, fill them up sequentially
  45567. for (j = 0; j < length; j++) {
  45568. point = points[j];
  45569. // labelPos = point.labelPos;
  45570. labelPosition = point.labelPosition;
  45571. dataLabel = point.dataLabel;
  45572. visibility = point.visible === false ? 'hidden' : 'inherit';
  45573. naturalY = labelPosition.natural.y;
  45574. y = naturalY;
  45575. if (positions && defined(point.distributeBox)) {
  45576. if (typeof point.distributeBox.pos === 'undefined') {
  45577. visibility = 'hidden';
  45578. }
  45579. else {
  45580. labelHeight = point.distributeBox.size;
  45581. // Find label's y position
  45582. y = dataLabelPositioners
  45583. .radialDistributionY(point);
  45584. }
  45585. }
  45586. // It is needed to delete point.positionIndex for
  45587. // dynamically added points etc.
  45588. delete point.positionIndex; // @todo unused
  45589. // Find label's x position
  45590. // justify is undocumented in the API - preserve support for it
  45591. if (options.justify) {
  45592. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  45593. }
  45594. else {
  45595. switch (options.alignTo) {
  45596. case 'connectors':
  45597. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  45598. break;
  45599. case 'plotEdges':
  45600. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  45601. break;
  45602. default:
  45603. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  45604. }
  45605. }
  45606. // Record the placement and visibility
  45607. dataLabel._attr = {
  45608. visibility: visibility,
  45609. align: labelPosition.alignment
  45610. };
  45611. pointDataLabelsOptions = point.options.dataLabels || {};
  45612. dataLabel._pos = {
  45613. x: (x +
  45614. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  45615. ({
  45616. left: connectorPadding,
  45617. right: -connectorPadding
  45618. }[labelPosition.alignment] || 0)),
  45619. // 10 is for the baseline (label vs text)
  45620. y: (y +
  45621. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  45622. 10)
  45623. };
  45624. // labelPos.x = x;
  45625. // labelPos.y = y;
  45626. labelPosition.final.x = x;
  45627. labelPosition.final.y = y;
  45628. // Detect overflowing data labels
  45629. if (pick(options.crop, true)) {
  45630. dataLabelWidth = dataLabel.getBBox().width;
  45631. sideOverflow = null;
  45632. // Overflow left
  45633. if (x - dataLabelWidth < connectorPadding &&
  45634. i === 1 // left half
  45635. ) {
  45636. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  45637. overflow[3] = Math.max(sideOverflow, overflow[3]);
  45638. // Overflow right
  45639. }
  45640. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  45641. i === 0 // right half
  45642. ) {
  45643. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  45644. overflow[1] = Math.max(sideOverflow, overflow[1]);
  45645. }
  45646. // Overflow top
  45647. if (y - labelHeight / 2 < 0) {
  45648. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  45649. // Overflow left
  45650. }
  45651. else if (y + labelHeight / 2 > plotHeight) {
  45652. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  45653. }
  45654. dataLabel.sideOverflow = sideOverflow;
  45655. }
  45656. } // for each point
  45657. }); // for each half
  45658. // Do not apply the final placement and draw the connectors until we
  45659. // have verified that labels are not spilling over.
  45660. if (arrayMax(overflow) === 0 ||
  45661. this.verifyDataLabelOverflow(overflow)) {
  45662. // Place the labels in the final position
  45663. this.placeDataLabels();
  45664. this.points.forEach(function (point) {
  45665. // #8864: every connector can have individual options
  45666. pointDataLabelsOptions =
  45667. merge(options, point.options.dataLabels);
  45668. connectorWidth =
  45669. pick(pointDataLabelsOptions.connectorWidth, 1);
  45670. // Draw the connector
  45671. if (connectorWidth) {
  45672. var isNew = void 0;
  45673. connector = point.connector;
  45674. dataLabel = point.dataLabel;
  45675. if (dataLabel &&
  45676. dataLabel._pos &&
  45677. point.visible &&
  45678. point.labelDistance > 0) {
  45679. visibility = dataLabel._attr.visibility;
  45680. isNew = !connector;
  45681. if (isNew) {
  45682. point.connector = connector = chart.renderer
  45683. .path()
  45684. .addClass('highcharts-data-label-connector ' +
  45685. ' highcharts-color-' + point.colorIndex +
  45686. (point.className ?
  45687. ' ' + point.className :
  45688. ''))
  45689. .add(series.dataLabelsGroup);
  45690. if (!chart.styledMode) {
  45691. connector.attr({
  45692. 'stroke-width': connectorWidth,
  45693. 'stroke': (pointDataLabelsOptions.connectorColor ||
  45694. point.color ||
  45695. palette.neutralColor60)
  45696. });
  45697. }
  45698. }
  45699. connector[isNew ? 'attr' : 'animate']({
  45700. d: point.getConnectorPath()
  45701. });
  45702. connector.attr('visibility', visibility);
  45703. }
  45704. else if (connector) {
  45705. point.connector = connector.destroy();
  45706. }
  45707. }
  45708. });
  45709. }
  45710. };
  45711. /**
  45712. * Extendable method for getting the path of the connector between the data
  45713. * label and the pie slice.
  45714. *
  45715. * @private
  45716. * @function Highcharts.seriesTypes.pie#connectorPath
  45717. *
  45718. * @param {*} labelPos
  45719. *
  45720. * @return {Highcharts.SVGPathArray}
  45721. */
  45722. // TODO: depracated - remove it
  45723. /*
  45724. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  45725. let x = labelPos.x,
  45726. y = labelPos.y;
  45727. return pick(this.options.dataLabels.softConnector, true) ? [
  45728. 'M',
  45729. // end of the string at the label
  45730. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45731. 'C',
  45732. x, y, // first break, next to the label
  45733. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  45734. labelPos[2], labelPos[3], // second break
  45735. 'L',
  45736. labelPos[4], labelPos[5] // base
  45737. ] : [
  45738. 'M',
  45739. // end of the string at the label
  45740. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45741. 'L',
  45742. labelPos[2], labelPos[3], // second break
  45743. 'L',
  45744. labelPos[4], labelPos[5] // base
  45745. ];
  45746. };
  45747. */
  45748. /**
  45749. * Perform the final placement of the data labels after we have verified
  45750. * that they fall within the plot area.
  45751. *
  45752. * @private
  45753. * @function Highcharts.seriesTypes.pie#placeDataLabels
  45754. * @return {void}
  45755. */
  45756. seriesTypes.pie.prototype.placeDataLabels = function () {
  45757. this.points.forEach(function (point) {
  45758. var dataLabel = point.dataLabel,
  45759. _pos;
  45760. if (dataLabel && point.visible) {
  45761. _pos = dataLabel._pos;
  45762. if (_pos) {
  45763. // Shorten data labels with ellipsis if they still overflow
  45764. // after the pie has reached minSize (#223).
  45765. if (dataLabel.sideOverflow) {
  45766. dataLabel._attr.width =
  45767. Math.max(dataLabel.getBBox().width -
  45768. dataLabel.sideOverflow, 0);
  45769. dataLabel.css({
  45770. width: dataLabel._attr.width + 'px',
  45771. textOverflow: ((this.options.dataLabels.style || {})
  45772. .textOverflow ||
  45773. 'ellipsis')
  45774. });
  45775. dataLabel.shortened = true;
  45776. }
  45777. dataLabel.attr(dataLabel._attr);
  45778. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  45779. dataLabel.moved = true;
  45780. }
  45781. else if (dataLabel) {
  45782. dataLabel.attr({ y: -9999 });
  45783. }
  45784. }
  45785. // Clear for update
  45786. delete point.distributeBox;
  45787. }, this);
  45788. };
  45789. seriesTypes.pie.prototype.alignDataLabel = noop;
  45790. /**
  45791. * Verify whether the data labels are allowed to draw, or we should run more
  45792. * translation and data label positioning to keep them inside the plot area.
  45793. * Returns true when data labels are ready to draw.
  45794. *
  45795. * @private
  45796. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  45797. * @param {Array<number>} overflow
  45798. * @return {boolean}
  45799. */
  45800. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  45801. var center = this.center,
  45802. options = this.options,
  45803. centerOption = options.center,
  45804. minSize = options.minSize || 80,
  45805. newSize = minSize,
  45806. // If a size is set, return true and don't try to shrink the pie
  45807. // to fit the labels.
  45808. ret = options.size !== null;
  45809. if (!ret) {
  45810. // Handle horizontal size and center
  45811. if (centerOption[0] !== null) { // Fixed center
  45812. newSize = Math.max(center[2] -
  45813. Math.max(overflow[1], overflow[3]), minSize);
  45814. }
  45815. else { // Auto center
  45816. newSize = Math.max(
  45817. // horizontal overflow
  45818. center[2] - overflow[1] - overflow[3], minSize);
  45819. // horizontal center
  45820. center[0] += (overflow[3] - overflow[1]) / 2;
  45821. }
  45822. // Handle vertical size and center
  45823. if (centerOption[1] !== null) { // Fixed center
  45824. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  45825. }
  45826. else { // Auto center
  45827. newSize = clamp(newSize, minSize,
  45828. // vertical overflow
  45829. center[2] - overflow[0] - overflow[2]);
  45830. // vertical center
  45831. center[1] += (overflow[0] - overflow[2]) / 2;
  45832. }
  45833. // If the size must be decreased, we need to run translate and
  45834. // drawDataLabels again
  45835. if (newSize < center[2]) {
  45836. center[2] = newSize;
  45837. center[3] = Math.min(// #3632
  45838. relativeLength(options.innerSize || 0, newSize), newSize);
  45839. this.translate(center);
  45840. if (this.drawDataLabels) {
  45841. this.drawDataLabels();
  45842. }
  45843. // Else, return true to indicate that the pie and its labels is
  45844. // within the plot area
  45845. }
  45846. else {
  45847. ret = true;
  45848. }
  45849. }
  45850. return ret;
  45851. };
  45852. }
  45853. if (seriesTypes.column) {
  45854. /**
  45855. * Override the basic data label alignment by adjusting for the position of
  45856. * the column.
  45857. *
  45858. * @private
  45859. * @function Highcharts.seriesTypes.column#alignDataLabel
  45860. * @param {Highcharts.Point} point
  45861. * @param {Highcharts.SVGElement} dataLabel
  45862. * @param {Highcharts.DataLabelsOptions} options
  45863. * @param {Highcharts.BBoxObject} alignTo
  45864. * @param {boolean} [isNew]
  45865. * @return {void}
  45866. */
  45867. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45868. var inverted = this.chart.inverted,
  45869. series = point.series,
  45870. // data label box for alignment
  45871. dlBox = point.dlBox || point.shapeArgs,
  45872. below = pick(point.below, // range series
  45873. point.plotY >
  45874. pick(this.translatedThreshold,
  45875. series.yAxis.len)),
  45876. // draw it inside the box?
  45877. inside = pick(options.inside, !!this.options.stacking),
  45878. overshoot;
  45879. // Align to the column itself, or the top of it
  45880. if (dlBox) { // Area range uses this method but not alignTo
  45881. alignTo = merge(dlBox);
  45882. if (alignTo.y < 0) {
  45883. alignTo.height += alignTo.y;
  45884. alignTo.y = 0;
  45885. }
  45886. // If parts of the box overshoots outside the plot area, modify the
  45887. // box to center the label inside
  45888. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  45889. if (overshoot > 0 && overshoot < alignTo.height) {
  45890. alignTo.height -= overshoot;
  45891. }
  45892. if (inverted) {
  45893. alignTo = {
  45894. x: series.yAxis.len - alignTo.y - alignTo.height,
  45895. y: series.xAxis.len - alignTo.x - alignTo.width,
  45896. width: alignTo.height,
  45897. height: alignTo.width
  45898. };
  45899. }
  45900. // Compute the alignment box
  45901. if (!inside) {
  45902. if (inverted) {
  45903. alignTo.x += below ? 0 : alignTo.width;
  45904. alignTo.width = 0;
  45905. }
  45906. else {
  45907. alignTo.y += below ? alignTo.height : 0;
  45908. alignTo.height = 0;
  45909. }
  45910. }
  45911. }
  45912. // When alignment is undefined (typically columns and bars), display the
  45913. // individual point below or above the point depending on the threshold
  45914. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  45915. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  45916. // Call the parent method
  45917. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  45918. // If label was justified and we have contrast, set it:
  45919. if (options.inside && point.contrastColor) {
  45920. dataLabel.css({
  45921. color: point.contrastColor
  45922. });
  45923. }
  45924. };
  45925. }
  45926. });
  45927. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  45928. /* *
  45929. *
  45930. * Highcharts module to hide overlapping data labels.
  45931. * This module is included in Highcharts.
  45932. *
  45933. * (c) 2009-2021 Torstein Honsi
  45934. *
  45935. * License: www.highcharts.com/license
  45936. *
  45937. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  45938. *
  45939. * */
  45940. var addEvent = U.addEvent,
  45941. fireEvent = U.fireEvent,
  45942. isArray = U.isArray,
  45943. isNumber = U.isNumber,
  45944. objectEach = U.objectEach,
  45945. pick = U.pick;
  45946. /**
  45947. * Internal type
  45948. * @private
  45949. */
  45950. /* eslint-disable no-invalid-this */
  45951. // Collect potensial overlapping data labels. Stack labels probably don't need
  45952. // to be considered because they are usually accompanied by data labels that lie
  45953. // inside the columns.
  45954. addEvent(Chart, 'render', function collectAndHide() {
  45955. var chart = this,
  45956. labels = [];
  45957. // Consider external label collectors
  45958. (this.labelCollectors || []).forEach(function (collector) {
  45959. labels = labels.concat(collector());
  45960. });
  45961. (this.yAxis || []).forEach(function (yAxis) {
  45962. if (yAxis.stacking &&
  45963. yAxis.options.stackLabels &&
  45964. !yAxis.options.stackLabels.allowOverlap) {
  45965. objectEach(yAxis.stacking.stacks, function (stack) {
  45966. objectEach(stack, function (stackItem) {
  45967. labels.push(stackItem.label);
  45968. });
  45969. });
  45970. }
  45971. });
  45972. (this.series || []).forEach(function (series) {
  45973. var dlOptions = series.options.dataLabels;
  45974. if (series.visible &&
  45975. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  45976. var push = function (points) {
  45977. return points.forEach(function (point) {
  45978. if (point.visible) {
  45979. var dataLabels = (isArray(point.dataLabels) ?
  45980. point.dataLabels :
  45981. (point.dataLabel ? [point.dataLabel] : []));
  45982. dataLabels.forEach(function (label) {
  45983. var options = label.options;
  45984. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  45985. if (!options.allowOverlap) {
  45986. labels.push(label);
  45987. }
  45988. else { // #13449
  45989. label.oldOpacity = label.opacity;
  45990. label.newOpacity = 1;
  45991. hideOrShow(label, chart);
  45992. }
  45993. });
  45994. }
  45995. });
  45996. };
  45997. push(series.nodes || []);
  45998. push(series.points);
  45999. }
  46000. });
  46001. this.hideOverlappingLabels(labels);
  46002. });
  46003. /**
  46004. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  46005. * provide a smooth visual imression.
  46006. *
  46007. * @private
  46008. * @function Highcharts.Chart#hideOverlappingLabels
  46009. * @param {Array<Highcharts.SVGElement>} labels
  46010. * Rendered data labels
  46011. * @requires modules/overlapping-datalabels
  46012. */
  46013. Chart.prototype.hideOverlappingLabels = function (labels) {
  46014. var chart = this,
  46015. len = labels.length,
  46016. ren = chart.renderer,
  46017. label,
  46018. i,
  46019. j,
  46020. label1,
  46021. label2,
  46022. box1,
  46023. box2,
  46024. isLabelAffected = false,
  46025. isIntersectRect = function (box1,
  46026. box2) {
  46027. return !(box2.x >= box1.x + box1.width ||
  46028. box2.x + box2.width <= box1.x ||
  46029. box2.y >= box1.y + box1.height ||
  46030. box2.y + box2.height <= box1.y);
  46031. },
  46032. // Get the box with its position inside the chart, as opposed to getBBox
  46033. // that only reports the position relative to the parent.
  46034. getAbsoluteBox = function (label) {
  46035. var pos,
  46036. parent,
  46037. bBox,
  46038. // Substract the padding if no background or border (#4333)
  46039. padding = label.box ? 0 : (label.padding || 0),
  46040. lineHeightCorrection = 0,
  46041. xOffset = 0,
  46042. boxWidth,
  46043. alignValue;
  46044. if (label &&
  46045. (!label.alignAttr || label.placed)) {
  46046. pos = label.alignAttr || {
  46047. x: label.attr('x'),
  46048. y: label.attr('y')
  46049. };
  46050. parent = label.parentGroup;
  46051. // Get width and height if pure text nodes (stack labels)
  46052. if (!label.width) {
  46053. bBox = label.getBBox();
  46054. label.width = bBox.width;
  46055. label.height = bBox.height;
  46056. // Labels positions are computed from top left corner, so
  46057. // we need to substract the text height from text nodes too.
  46058. lineHeightCorrection = ren
  46059. .fontMetrics(null, label.element).h;
  46060. }
  46061. boxWidth = label.width - 2 * padding;
  46062. alignValue = {
  46063. left: '0',
  46064. center: '0.5',
  46065. right: '1'
  46066. }[label.alignValue];
  46067. if (alignValue) {
  46068. xOffset = +alignValue * boxWidth;
  46069. }
  46070. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  46071. xOffset = label.x - label.translateX;
  46072. }
  46073. return {
  46074. x: pos.x + (parent.translateX || 0) + padding -
  46075. (xOffset || 0),
  46076. y: pos.y + (parent.translateY || 0) + padding -
  46077. lineHeightCorrection,
  46078. width: label.width - 2 * padding,
  46079. height: label.height - 2 * padding
  46080. };
  46081. }
  46082. };
  46083. for (i = 0; i < len; i++) {
  46084. label = labels[i];
  46085. if (label) {
  46086. // Mark with initial opacity
  46087. label.oldOpacity = label.opacity;
  46088. label.newOpacity = 1;
  46089. label.absoluteBox = getAbsoluteBox(label);
  46090. }
  46091. }
  46092. // Prevent a situation in a gradually rising slope, that each label will
  46093. // hide the previous one because the previous one always has lower rank.
  46094. labels.sort(function (a, b) {
  46095. return (b.labelrank || 0) - (a.labelrank || 0);
  46096. });
  46097. // Detect overlapping labels
  46098. for (i = 0; i < len; i++) {
  46099. label1 = labels[i];
  46100. box1 = label1 && label1.absoluteBox;
  46101. for (j = i + 1; j < len; ++j) {
  46102. label2 = labels[j];
  46103. box2 = label2 && label2.absoluteBox;
  46104. if (box1 &&
  46105. box2 &&
  46106. label1 !== label2 && // #6465, polar chart with connectEnds
  46107. label1.newOpacity !== 0 &&
  46108. label2.newOpacity !== 0) {
  46109. if (isIntersectRect(box1, box2)) {
  46110. (label1.labelrank < label2.labelrank ? label1 : label2)
  46111. .newOpacity = 0;
  46112. }
  46113. }
  46114. }
  46115. }
  46116. // Hide or show
  46117. labels.forEach(function (label) {
  46118. if (hideOrShow(label, chart)) {
  46119. isLabelAffected = true;
  46120. }
  46121. });
  46122. if (isLabelAffected) {
  46123. fireEvent(chart, 'afterHideAllOverlappingLabels');
  46124. }
  46125. };
  46126. /**
  46127. * Hide or show labels based on opacity.
  46128. *
  46129. * @private
  46130. * @function hideOrShow
  46131. * @param {Highcharts.SVGElement} label
  46132. * The label.
  46133. * @param {Highcharts.Chart} chart
  46134. * The chart that contains the label.
  46135. * @return {boolean}
  46136. */
  46137. function hideOrShow(label, chart) {
  46138. var complete,
  46139. newOpacity,
  46140. isLabelAffected = false;
  46141. if (label) {
  46142. newOpacity = label.newOpacity;
  46143. if (label.oldOpacity !== newOpacity) {
  46144. // Make sure the label is completely hidden to avoid catching
  46145. // clicks (#4362)
  46146. if (label.alignAttr && label.placed) { // data labels
  46147. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  46148. complete = function () {
  46149. if (!chart.styledMode) {
  46150. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  46151. }
  46152. label.visibility = newOpacity ? 'inherit' : 'hidden';
  46153. };
  46154. isLabelAffected = true;
  46155. // Animate or set the opacity
  46156. label.alignAttr.opacity = newOpacity;
  46157. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  46158. fireEvent(chart, 'afterHideOverlappingLabel');
  46159. }
  46160. else { // other labels, tick labels
  46161. label.attr({
  46162. opacity: newOpacity
  46163. });
  46164. }
  46165. }
  46166. label.isOld = true;
  46167. }
  46168. return isLabelAffected;
  46169. }
  46170. });
  46171. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  46172. /* *
  46173. *
  46174. * (c) 2010-2021 Torstein Honsi
  46175. *
  46176. * License: www.highcharts.com/license
  46177. *
  46178. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46179. *
  46180. * */
  46181. var find = U.find,
  46182. isArray = U.isArray,
  46183. isObject = U.isObject,
  46184. merge = U.merge,
  46185. objectEach = U.objectEach,
  46186. pick = U.pick,
  46187. splat = U.splat,
  46188. uniqueKey = U.uniqueKey;
  46189. /**
  46190. * A callback function to gain complete control on when the responsive rule
  46191. * applies.
  46192. *
  46193. * @callback Highcharts.ResponsiveCallbackFunction
  46194. *
  46195. * @param {Highcharts.Chart} this
  46196. * Chart context.
  46197. *
  46198. * @return {boolean}
  46199. * Return `true` if it applies.
  46200. */
  46201. /**
  46202. * Allows setting a set of rules to apply for different screen or chart
  46203. * sizes. Each rule specifies additional chart options.
  46204. *
  46205. * @sample {highstock} stock/demo/responsive/
  46206. * Stock chart
  46207. * @sample highcharts/responsive/axis/
  46208. * Axis
  46209. * @sample highcharts/responsive/legend/
  46210. * Legend
  46211. * @sample highcharts/responsive/classname/
  46212. * Class name
  46213. *
  46214. * @since 5.0.0
  46215. * @apioption responsive
  46216. */
  46217. /**
  46218. * A set of rules for responsive settings. The rules are executed from
  46219. * the top down.
  46220. *
  46221. * @sample {highcharts} highcharts/responsive/axis/
  46222. * Axis changes
  46223. * @sample {highstock} highcharts/responsive/axis/
  46224. * Axis changes
  46225. * @sample {highmaps} highcharts/responsive/axis/
  46226. * Axis changes
  46227. *
  46228. * @type {Array<*>}
  46229. * @since 5.0.0
  46230. * @apioption responsive.rules
  46231. */
  46232. /**
  46233. * A full set of chart options to apply as overrides to the general
  46234. * chart options. The chart options are applied when the given rule
  46235. * is active.
  46236. *
  46237. * A special case is configuration objects that take arrays, for example
  46238. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  46239. * collections, an `id` option is used to map the new option set to
  46240. * an existing object. If an existing object of the same id is not found,
  46241. * the item of the same indexupdated. So for example, setting `chartOptions`
  46242. * with two series items without an `id`, will cause the existing chart's
  46243. * two series to be updated with respective options.
  46244. *
  46245. * @sample {highstock} stock/demo/responsive/
  46246. * Stock chart
  46247. * @sample highcharts/responsive/axis/
  46248. * Axis
  46249. * @sample highcharts/responsive/legend/
  46250. * Legend
  46251. * @sample highcharts/responsive/classname/
  46252. * Class name
  46253. *
  46254. * @type {Highcharts.Options}
  46255. * @since 5.0.0
  46256. * @apioption responsive.rules.chartOptions
  46257. */
  46258. /**
  46259. * Under which conditions the rule applies.
  46260. *
  46261. * @since 5.0.0
  46262. * @apioption responsive.rules.condition
  46263. */
  46264. /**
  46265. * A callback function to gain complete control on when the responsive
  46266. * rule applies. Return `true` if it applies. This opens for checking
  46267. * against other metrics than the chart size, for example the document
  46268. * size or other elements.
  46269. *
  46270. * @type {Highcharts.ResponsiveCallbackFunction}
  46271. * @since 5.0.0
  46272. * @context Highcharts.Chart
  46273. * @apioption responsive.rules.condition.callback
  46274. */
  46275. /**
  46276. * The responsive rule applies if the chart height is less than this.
  46277. *
  46278. * @type {number}
  46279. * @since 5.0.0
  46280. * @apioption responsive.rules.condition.maxHeight
  46281. */
  46282. /**
  46283. * The responsive rule applies if the chart width is less than this.
  46284. *
  46285. * @sample highcharts/responsive/axis/
  46286. * Max width is 500
  46287. *
  46288. * @type {number}
  46289. * @since 5.0.0
  46290. * @apioption responsive.rules.condition.maxWidth
  46291. */
  46292. /**
  46293. * The responsive rule applies if the chart height is greater than this.
  46294. *
  46295. * @type {number}
  46296. * @default 0
  46297. * @since 5.0.0
  46298. * @apioption responsive.rules.condition.minHeight
  46299. */
  46300. /**
  46301. * The responsive rule applies if the chart width is greater than this.
  46302. *
  46303. * @type {number}
  46304. * @default 0
  46305. * @since 5.0.0
  46306. * @apioption responsive.rules.condition.minWidth
  46307. */
  46308. /* eslint-disable no-invalid-this, valid-jsdoc */
  46309. /**
  46310. * Update the chart based on the current chart/document size and options for
  46311. * responsiveness.
  46312. *
  46313. * @private
  46314. * @function Highcharts.Chart#setResponsive
  46315. * @param {boolean} [redraw=true]
  46316. * @param {boolean} [reset=false]
  46317. * Reset by un-applying all rules. Chart.update resets all rules before applying
  46318. * updated options.
  46319. */
  46320. Chart.prototype.setResponsive = function (redraw, reset) {
  46321. var options = this.options.responsive,
  46322. ruleIds = [],
  46323. currentResponsive = this.currentResponsive,
  46324. currentRuleIds,
  46325. undoOptions;
  46326. if (!reset && options && options.rules) {
  46327. options.rules.forEach(function (rule) {
  46328. if (typeof rule._id === 'undefined') {
  46329. rule._id = uniqueKey();
  46330. }
  46331. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  46332. }, this);
  46333. }
  46334. // Merge matching rules
  46335. var mergedOptions = merge.apply(0,
  46336. ruleIds.map(function (ruleId) {
  46337. return find(options.rules,
  46338. function (rule) {
  46339. return rule._id === ruleId;
  46340. }).chartOptions;
  46341. }));
  46342. mergedOptions.isResponsiveOptions = true;
  46343. // Stringified key for the rules that currently apply.
  46344. ruleIds = (ruleIds.toString() || void 0);
  46345. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  46346. // Changes in what rules apply
  46347. if (ruleIds !== currentRuleIds) {
  46348. // Undo previous rules. Before we apply a new set of rules, we need to
  46349. // roll back completely to base options (#6291).
  46350. if (currentResponsive) {
  46351. this.update(currentResponsive.undoOptions, redraw, true);
  46352. }
  46353. if (ruleIds) {
  46354. // Get undo-options for matching rules
  46355. undoOptions = this.currentOptions(mergedOptions);
  46356. undoOptions.isResponsiveOptions = true;
  46357. this.currentResponsive = {
  46358. ruleIds: ruleIds,
  46359. mergedOptions: mergedOptions,
  46360. undoOptions: undoOptions
  46361. };
  46362. this.update(mergedOptions, redraw, true);
  46363. }
  46364. else {
  46365. this.currentResponsive = void 0;
  46366. }
  46367. }
  46368. };
  46369. /**
  46370. * Handle a single responsiveness rule.
  46371. *
  46372. * @private
  46373. * @function Highcharts.Chart#matchResponsiveRule
  46374. * @param {Highcharts.ResponsiveRulesOptions} rule
  46375. * @param {Array<string>} matches
  46376. */
  46377. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  46378. var condition = rule.condition,
  46379. fn = condition.callback || function () {
  46380. return (this.chartWidth <= pick(condition.maxWidth,
  46381. Number.MAX_VALUE) &&
  46382. this.chartHeight <=
  46383. pick(condition.maxHeight,
  46384. Number.MAX_VALUE) &&
  46385. this.chartWidth >= pick(condition.minWidth, 0) &&
  46386. this.chartHeight >= pick(condition.minHeight, 0));
  46387. };
  46388. if (fn.call(this)) {
  46389. matches.push(rule._id);
  46390. }
  46391. };
  46392. /**
  46393. * Get the current values for a given set of options. Used before we update
  46394. * the chart with a new responsiveness rule.
  46395. *
  46396. * @todo Restore axis options (by id?). The matching of items in collections
  46397. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  46398. * refactor out that matching and reuse it in both functions.
  46399. *
  46400. * @private
  46401. * @function Highcharts.Chart#currentOptions
  46402. * @param {Highcharts.Options} options
  46403. * @return {Highcharts.Options}
  46404. */
  46405. Chart.prototype.currentOptions = function (options) {
  46406. var chart = this,
  46407. ret = {};
  46408. /**
  46409. * Recurse over a set of options and its current values,
  46410. * and store the current values in the ret object.
  46411. */
  46412. function getCurrent(options, curr, ret, depth) {
  46413. var i;
  46414. objectEach(options, function (val, key) {
  46415. if (!depth &&
  46416. chart.collectionsWithUpdate.indexOf(key) > -1 &&
  46417. curr[key]) {
  46418. val = splat(val);
  46419. ret[key] = [];
  46420. // Iterate over collections like series, xAxis or yAxis and map
  46421. // the items by index.
  46422. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  46423. // Item exists in current data (#6347)
  46424. if (curr[key][i]) {
  46425. // If the item is missing from the new data, we need to
  46426. // save the whole config structure. Like when
  46427. // responsively updating from a dual axis layout to a
  46428. // single axis and back (#13544).
  46429. if (val[i] === void 0) {
  46430. ret[key][i] = curr[key][i];
  46431. // Otherwise, proceed
  46432. }
  46433. else {
  46434. ret[key][i] = {};
  46435. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  46436. }
  46437. }
  46438. }
  46439. }
  46440. else if (isObject(val)) {
  46441. ret[key] = isArray(val) ? [] : {};
  46442. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  46443. }
  46444. else if (typeof curr[key] === 'undefined') { // #10286
  46445. ret[key] = null;
  46446. }
  46447. else {
  46448. ret[key] = curr[key];
  46449. }
  46450. });
  46451. }
  46452. getCurrent(options, this.options, ret, 0);
  46453. return ret;
  46454. };
  46455. });
  46456. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Options.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Series/Series.js']], function (Highcharts, Utilities, Options, Fx, Animation, AST, FormatUtilities, SVGElement, Series) {
  46457. var G = Highcharts;
  46458. // Animation
  46459. G.animate = Animation.animate;
  46460. G.animObject = Animation.animObject;
  46461. G.getDeferredAnimation = Animation.getDeferredAnimation;
  46462. G.setAnimation = Animation.setAnimation;
  46463. G.stop = Animation.stop;
  46464. G.timers = Fx.timers;
  46465. // Classes
  46466. G.AST = AST;
  46467. G.Fx = Fx;
  46468. G.Series = Series;
  46469. G.SVGElement = SVGElement;
  46470. // Format Utilities
  46471. G.dateFormat = FormatUtilities.dateFormat;
  46472. G.format = FormatUtilities.format;
  46473. G.numberFormat = FormatUtilities.numberFormat;
  46474. // Options
  46475. G.defaultOptions = Options.defaultOptions;
  46476. G.getOptions = Options.getOptions;
  46477. G.time = Options.defaultTime;
  46478. G.setOptions = Options.setOptions;
  46479. // Utilities
  46480. G.addEvent = Utilities.addEvent;
  46481. G.arrayMax = Utilities.arrayMax;
  46482. G.arrayMin = Utilities.arrayMin;
  46483. G.attr = Utilities.attr;
  46484. G.clearTimeout = Utilities.clearTimeout;
  46485. G.correctFloat = Utilities.correctFloat;
  46486. G.createElement = Utilities.createElement;
  46487. G.css = Utilities.css;
  46488. G.defined = Utilities.defined;
  46489. G.destroyObjectProperties = Utilities.destroyObjectProperties;
  46490. G.discardElement = Utilities.discardElement;
  46491. G.erase = Utilities.erase;
  46492. G.error = Utilities.error;
  46493. G.extend = Utilities.extend;
  46494. G.extendClass = Utilities.extendClass;
  46495. G.find = Utilities.find;
  46496. G.fireEvent = Utilities.fireEvent;
  46497. G.getMagnitude = Utilities.getMagnitude;
  46498. G.getStyle = Utilities.getStyle;
  46499. G.inArray = Utilities.inArray;
  46500. G.isArray = Utilities.isArray;
  46501. G.isClass = Utilities.isClass;
  46502. G.isDOMElement = Utilities.isDOMElement;
  46503. G.isFunction = Utilities.isFunction;
  46504. G.isNumber = Utilities.isNumber;
  46505. G.isObject = Utilities.isObject;
  46506. G.isString = Utilities.isString;
  46507. G.keys = Utilities.keys;
  46508. G.merge = Utilities.merge;
  46509. G.normalizeTickInterval = Utilities.normalizeTickInterval;
  46510. G.objectEach = Utilities.objectEach;
  46511. G.offset = Utilities.offset;
  46512. G.pad = Utilities.pad;
  46513. G.pick = Utilities.pick;
  46514. G.pInt = Utilities.pInt;
  46515. G.relativeLength = Utilities.relativeLength;
  46516. G.removeEvent = Utilities.removeEvent;
  46517. G.splat = Utilities.splat;
  46518. G.stableSort = Utilities.stableSort;
  46519. G.syncTimeout = Utilities.syncTimeout;
  46520. G.timeUnits = Utilities.timeUnits;
  46521. G.uniqueKey = Utilities.uniqueKey;
  46522. G.useSerialIds = Utilities.useSerialIds;
  46523. G.wrap = Utilities.wrap;
  46524. return G;
  46525. });
  46526. _registerModule(_modules, 'Core/Axis/MapAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  46527. /* *
  46528. *
  46529. * (c) 2010-2021 Torstein Honsi
  46530. *
  46531. * License: www.highcharts.com/license
  46532. *
  46533. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46534. *
  46535. * */
  46536. var addEvent = U.addEvent,
  46537. pick = U.pick;
  46538. /**
  46539. * Map support for axes.
  46540. * @private
  46541. * @class
  46542. */
  46543. var MapAxisAdditions = /** @class */ (function () {
  46544. /* *
  46545. *
  46546. * Constructors
  46547. *
  46548. * */
  46549. function MapAxisAdditions(axis) {
  46550. this.axis = axis;
  46551. }
  46552. return MapAxisAdditions;
  46553. }());
  46554. /**
  46555. * Axis with map support.
  46556. * @private
  46557. * @class
  46558. */
  46559. var MapAxis = /** @class */ (function () {
  46560. function MapAxis() {
  46561. }
  46562. /**
  46563. * Extends axes with map support.
  46564. * @private
  46565. *
  46566. * @param {Highcharts.Axis} AxisClass
  46567. * Axis class to extend.
  46568. */
  46569. MapAxis.compose = function (AxisClass) {
  46570. AxisClass.keepProps.push('mapAxis');
  46571. /* eslint-disable no-invalid-this */
  46572. addEvent(AxisClass, 'init', function () {
  46573. var axis = this;
  46574. if (!axis.mapAxis) {
  46575. axis.mapAxis = new MapAxisAdditions(axis);
  46576. }
  46577. });
  46578. // Override to use the extreme coordinates from the SVG shape, not the
  46579. // data values
  46580. addEvent(AxisClass, 'getSeriesExtremes', function () {
  46581. if (!this.mapAxis) {
  46582. return;
  46583. }
  46584. var axis = this;
  46585. var xData = [];
  46586. // Remove the xData array and cache it locally so that the proceed
  46587. // method doesn't use it
  46588. if (axis.isXAxis) {
  46589. axis.series.forEach(function (series, i) {
  46590. if (series.useMapGeometry) {
  46591. xData[i] = series.xData;
  46592. series.xData = [];
  46593. }
  46594. });
  46595. axis.mapAxis.seriesXData = xData;
  46596. }
  46597. });
  46598. addEvent(AxisClass, 'afterGetSeriesExtremes', function () {
  46599. if (!this.mapAxis) {
  46600. return;
  46601. }
  46602. var axis = this;
  46603. var xData = axis.mapAxis.seriesXData || [];
  46604. var dataMin,
  46605. dataMax,
  46606. useMapGeometry;
  46607. // Run extremes logic for map and mapline
  46608. if (axis.isXAxis) {
  46609. dataMin = pick(axis.dataMin, Number.MAX_VALUE);
  46610. dataMax = pick(axis.dataMax, -Number.MAX_VALUE);
  46611. axis.series.forEach(function (series, i) {
  46612. if (series.useMapGeometry) {
  46613. dataMin = Math.min(dataMin, pick(series.minX, dataMin));
  46614. dataMax = Math.max(dataMax, pick(series.maxX, dataMax));
  46615. series.xData = xData[i]; // Reset xData array
  46616. useMapGeometry = true;
  46617. }
  46618. });
  46619. if (useMapGeometry) {
  46620. axis.dataMin = dataMin;
  46621. axis.dataMax = dataMax;
  46622. }
  46623. axis.mapAxis.seriesXData = void 0;
  46624. }
  46625. });
  46626. // Override axis translation to make sure the aspect ratio is always
  46627. // kept
  46628. addEvent(AxisClass, 'afterSetAxisTranslation', function () {
  46629. if (!this.mapAxis) {
  46630. return;
  46631. }
  46632. var axis = this;
  46633. var chart = axis.chart;
  46634. var plotRatio = chart.plotWidth / chart.plotHeight;
  46635. var xAxis = chart.xAxis[0];
  46636. var mapRatio,
  46637. adjustedAxisLength,
  46638. padAxis,
  46639. fixTo,
  46640. fixDiff,
  46641. preserveAspectRatio;
  46642. // Check for map-like series
  46643. if (axis.coll === 'yAxis' && typeof xAxis.transA !== 'undefined') {
  46644. axis.series.forEach(function (series) {
  46645. if (series.preserveAspectRatio) {
  46646. preserveAspectRatio = true;
  46647. }
  46648. });
  46649. }
  46650. // On Y axis, handle both
  46651. if (preserveAspectRatio) {
  46652. // Use the same translation for both axes
  46653. axis.transA = xAxis.transA = Math.min(axis.transA, xAxis.transA);
  46654. mapRatio = plotRatio / ((xAxis.max - xAxis.min) /
  46655. (axis.max - axis.min));
  46656. // What axis to pad to put the map in the middle
  46657. padAxis = mapRatio < 1 ? axis : xAxis;
  46658. // Pad it
  46659. adjustedAxisLength =
  46660. (padAxis.max - padAxis.min) * padAxis.transA;
  46661. padAxis.mapAxis.pixelPadding = padAxis.len - adjustedAxisLength;
  46662. padAxis.minPixelPadding = padAxis.mapAxis.pixelPadding / 2;
  46663. fixTo = padAxis.mapAxis.fixTo;
  46664. if (fixTo) {
  46665. fixDiff = fixTo[1] - padAxis.toValue(fixTo[0], true);
  46666. fixDiff *= padAxis.transA;
  46667. if (Math.abs(fixDiff) > padAxis.minPixelPadding ||
  46668. (padAxis.min === padAxis.dataMin &&
  46669. padAxis.max === padAxis.dataMax)) { // zooming out again, keep within restricted area
  46670. fixDiff = 0;
  46671. }
  46672. padAxis.minPixelPadding -= fixDiff;
  46673. }
  46674. }
  46675. });
  46676. // Override Axis.render in order to delete the fixTo prop
  46677. addEvent(AxisClass, 'render', function () {
  46678. var axis = this;
  46679. if (axis.mapAxis) {
  46680. axis.mapAxis.fixTo = void 0;
  46681. }
  46682. });
  46683. /* eslint-enable no-invalid-this */
  46684. };
  46685. return MapAxis;
  46686. }());
  46687. MapAxis.compose(Axis); // @todo move to factory functions
  46688. return MapAxis;
  46689. });
  46690. _registerModule(_modules, 'Mixins/ColorSeries.js', [], function () {
  46691. /* *
  46692. *
  46693. * (c) 2010-2021 Torstein Honsi
  46694. *
  46695. * License: www.highcharts.com/license
  46696. *
  46697. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46698. *
  46699. * */
  46700. /**
  46701. * Mixin for maps and heatmaps
  46702. *
  46703. * @private
  46704. * @mixin Highcharts.colorPointMixin
  46705. */
  46706. var colorPointMixin = {
  46707. /* eslint-disable valid-jsdoc */
  46708. /**
  46709. * Set the visibility of a single point
  46710. * @private
  46711. * @function Highcharts.colorPointMixin.setVisible
  46712. * @param {boolean} visible
  46713. * @return {void}
  46714. */
  46715. setVisible: function (vis) {
  46716. var point = this,
  46717. method = vis ? 'show' : 'hide';
  46718. point.visible = point.options.visible = Boolean(vis);
  46719. // Show and hide associated elements
  46720. ['graphic', 'dataLabel'].forEach(function (key) {
  46721. if (point[key]) {
  46722. point[key][method]();
  46723. }
  46724. });
  46725. this.series.buildKDTree(); // rebuild kdtree #13195
  46726. }
  46727. /* eslint-enable valid-jsdoc */
  46728. };
  46729. /**
  46730. * @private
  46731. * @mixin Highcharts.colorSeriesMixin
  46732. */
  46733. var colorSeriesMixin = {
  46734. optionalAxis: 'colorAxis',
  46735. colorAxis: 0,
  46736. /* eslint-disable valid-jsdoc */
  46737. /**
  46738. * In choropleth maps,
  46739. the color is a result of the value,
  46740. so this needs
  46741. * translation too
  46742. * @private
  46743. * @function Highcharts.colorSeriesMixin.translateColors
  46744. * @return {void}
  46745. */
  46746. translateColors: function () {
  46747. var series = this,
  46748. points = this.data.length ? this.data : this.points,
  46749. nullColor = this.options.nullColor,
  46750. colorAxis = this.colorAxis,
  46751. colorKey = this.colorKey;
  46752. points.forEach(function (point) {
  46753. var value = point.getNestedProperty(colorKey),
  46754. color;
  46755. color = point.options.color ||
  46756. (point.isNull || point.value === null ?
  46757. nullColor :
  46758. (colorAxis && typeof value !== 'undefined') ?
  46759. colorAxis.toColor(value, point) :
  46760. point.color || series.color);
  46761. if (color && point.color !== color) {
  46762. point.color = color;
  46763. if (series.options.legendType === 'point' && point.legendItem) {
  46764. series.chart.legend.colorizeItem(point, point.visible);
  46765. }
  46766. }
  46767. });
  46768. }
  46769. /* eslint-enable valid-jsdoc */
  46770. };
  46771. var exports = {
  46772. colorPointMixin: colorPointMixin,
  46773. colorSeriesMixin: colorSeriesMixin
  46774. };
  46775. return exports;
  46776. });
  46777. _registerModule(_modules, 'Core/Axis/ColorAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Mixins/ColorSeries.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Axis, Chart, Color, ColorSeriesModule, Fx, H, Legend, LegendSymbolMixin, palette, Point, Series, U) {
  46778. /* *
  46779. *
  46780. * (c) 2010-2021 Torstein Honsi
  46781. *
  46782. * License: www.highcharts.com/license
  46783. *
  46784. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46785. *
  46786. * */
  46787. var __extends = (this && this.__extends) || (function () {
  46788. var extendStatics = function (d,
  46789. b) {
  46790. extendStatics = Object.setPrototypeOf ||
  46791. ({ __proto__: [] } instanceof Array && function (d,
  46792. b) { d.__proto__ = b; }) ||
  46793. function (d,
  46794. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  46795. return extendStatics(d, b);
  46796. };
  46797. return function (d, b) {
  46798. extendStatics(d, b);
  46799. function __() { this.constructor = d; }
  46800. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46801. };
  46802. })();
  46803. var color = Color.parse;
  46804. var colorPointMixin = ColorSeriesModule.colorPointMixin,
  46805. colorSeriesMixin = ColorSeriesModule.colorSeriesMixin;
  46806. var noop = H.noop;
  46807. var addEvent = U.addEvent,
  46808. erase = U.erase,
  46809. extend = U.extend,
  46810. isNumber = U.isNumber,
  46811. merge = U.merge,
  46812. pick = U.pick,
  46813. splat = U.splat;
  46814. /**
  46815. * Color axis types
  46816. *
  46817. * @typedef {"linear"|"logarithmic"} Highcharts.ColorAxisTypeValue
  46818. */
  46819. ''; // detach doclet above
  46820. extend(Series.prototype, colorSeriesMixin);
  46821. extend(Point.prototype, colorPointMixin);
  46822. Chart.prototype.collectionsWithUpdate.push('colorAxis');
  46823. Chart.prototype.collectionsWithInit.colorAxis = [Chart.prototype.addColorAxis];
  46824. /* eslint-disable no-invalid-this, valid-jsdoc */
  46825. /**
  46826. * The ColorAxis object for inclusion in gradient legends.
  46827. *
  46828. * @class
  46829. * @name Highcharts.ColorAxis
  46830. * @augments Highcharts.Axis
  46831. *
  46832. * @param {Highcharts.Chart} chart
  46833. * The related chart of the color axis.
  46834. *
  46835. * @param {Highcharts.ColorAxisOptions} userOptions
  46836. * The color axis options for initialization.
  46837. */
  46838. var ColorAxis = /** @class */ (function (_super) {
  46839. __extends(ColorAxis, _super);
  46840. /* *
  46841. *
  46842. * Constructors
  46843. *
  46844. * */
  46845. /**
  46846. * @private
  46847. */
  46848. function ColorAxis(chart, userOptions) {
  46849. var _this = _super.call(this,
  46850. chart,
  46851. userOptions) || this;
  46852. _this.beforePadding = false; // Prevents unnecessary padding with `hc-more`
  46853. _this.chart = void 0;
  46854. _this.coll = 'colorAxis';
  46855. _this.dataClasses = void 0;
  46856. _this.legendItem = void 0;
  46857. _this.legendItems = void 0;
  46858. _this.name = ''; // Prevents 'undefined' in legend in IE8
  46859. _this.options = void 0;
  46860. _this.stops = void 0;
  46861. _this.visible = true;
  46862. _this.init(chart, userOptions);
  46863. return _this;
  46864. }
  46865. /* *
  46866. *
  46867. * Functions
  46868. *
  46869. * */
  46870. /**
  46871. * Initializes the color axis.
  46872. *
  46873. * @function Highcharts.ColorAxis#init
  46874. *
  46875. * @param {Highcharts.Chart} chart
  46876. * The related chart of the color axis.
  46877. *
  46878. * @param {Highcharts.ColorAxisOptions} userOptions
  46879. * The color axis options for initialization.
  46880. */
  46881. ColorAxis.prototype.init = function (chart, userOptions) {
  46882. var axis = this;
  46883. var legend = chart.options.legend || {},
  46884. horiz = userOptions.layout ?
  46885. userOptions.layout !== 'vertical' :
  46886. legend.layout !== 'vertical';
  46887. var options = merge(ColorAxis.defaultColorAxisOptions,
  46888. userOptions, {
  46889. showEmpty: false,
  46890. title: null,
  46891. visible: legend.enabled &&
  46892. (userOptions ? userOptions.visible !== false : true)
  46893. });
  46894. axis.coll = 'colorAxis';
  46895. axis.side = userOptions.side || horiz ? 2 : 1;
  46896. axis.reversed = userOptions.reversed || !horiz;
  46897. axis.opposite = !horiz;
  46898. _super.prototype.init.call(this, chart, options);
  46899. // Base init() pushes it to the xAxis array, now pop it again
  46900. // chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
  46901. // Prepare data classes
  46902. if (userOptions.dataClasses) {
  46903. axis.initDataClasses(userOptions);
  46904. }
  46905. axis.initStops();
  46906. // Override original axis properties
  46907. axis.horiz = horiz;
  46908. axis.zoomEnabled = false;
  46909. };
  46910. /**
  46911. * @private
  46912. */
  46913. ColorAxis.prototype.initDataClasses = function (userOptions) {
  46914. var axis = this;
  46915. var chart = axis.chart,
  46916. dataClasses,
  46917. colorCounter = 0,
  46918. colorCount = chart.options.chart.colorCount,
  46919. options = axis.options,
  46920. len = userOptions.dataClasses.length;
  46921. axis.dataClasses = dataClasses = [];
  46922. axis.legendItems = [];
  46923. userOptions.dataClasses.forEach(function (dataClass, i) {
  46924. var colors;
  46925. dataClass = merge(dataClass);
  46926. dataClasses.push(dataClass);
  46927. if (!chart.styledMode && dataClass.color) {
  46928. return;
  46929. }
  46930. if (options.dataClassColor === 'category') {
  46931. if (!chart.styledMode) {
  46932. colors = chart.options.colors;
  46933. colorCount = colors.length;
  46934. dataClass.color = colors[colorCounter];
  46935. }
  46936. dataClass.colorIndex = colorCounter;
  46937. // increase and loop back to zero
  46938. colorCounter++;
  46939. if (colorCounter === colorCount) {
  46940. colorCounter = 0;
  46941. }
  46942. }
  46943. else {
  46944. dataClass.color = color(options.minColor).tweenTo(color(options.maxColor), len < 2 ? 0.5 : i / (len - 1) // #3219
  46945. );
  46946. }
  46947. });
  46948. };
  46949. /**
  46950. * Returns true if the series has points at all.
  46951. *
  46952. * @function Highcharts.ColorAxis#hasData
  46953. *
  46954. * @return {boolean}
  46955. * True, if the series has points, otherwise false.
  46956. */
  46957. ColorAxis.prototype.hasData = function () {
  46958. return !!(this.tickPositions || []).length;
  46959. };
  46960. /**
  46961. * Override so that ticks are not added in data class axes (#6914)
  46962. * @private
  46963. */
  46964. ColorAxis.prototype.setTickPositions = function () {
  46965. if (!this.dataClasses) {
  46966. return _super.prototype.setTickPositions.call(this);
  46967. }
  46968. };
  46969. /**
  46970. * @private
  46971. */
  46972. ColorAxis.prototype.initStops = function () {
  46973. var axis = this;
  46974. axis.stops = axis.options.stops || [
  46975. [0, axis.options.minColor],
  46976. [1, axis.options.maxColor]
  46977. ];
  46978. axis.stops.forEach(function (stop) {
  46979. stop.color = color(stop[1]);
  46980. });
  46981. };
  46982. /**
  46983. * Extend the setOptions method to process extreme colors and color stops.
  46984. * @private
  46985. */
  46986. ColorAxis.prototype.setOptions = function (userOptions) {
  46987. var axis = this;
  46988. _super.prototype.setOptions.call(this, userOptions);
  46989. axis.options.crosshair = axis.options.marker;
  46990. };
  46991. /**
  46992. * @private
  46993. */
  46994. ColorAxis.prototype.setAxisSize = function () {
  46995. var axis = this;
  46996. var symbol = axis.legendSymbol;
  46997. var chart = axis.chart;
  46998. var legendOptions = chart.options.legend || {};
  46999. var x,
  47000. y,
  47001. width,
  47002. height;
  47003. if (symbol) {
  47004. this.left = x = symbol.attr('x');
  47005. this.top = y = symbol.attr('y');
  47006. this.width = width = symbol.attr('width');
  47007. this.height = height = symbol.attr('height');
  47008. this.right = chart.chartWidth - x - width;
  47009. this.bottom = chart.chartHeight - y - height;
  47010. this.len = this.horiz ? width : height;
  47011. this.pos = this.horiz ? x : y;
  47012. }
  47013. else {
  47014. // Fake length for disabled legend to avoid tick issues
  47015. // and such (#5205)
  47016. this.len = (this.horiz ?
  47017. legendOptions.symbolWidth :
  47018. legendOptions.symbolHeight) || ColorAxis.defaultLegendLength;
  47019. }
  47020. };
  47021. /**
  47022. * @private
  47023. */
  47024. ColorAxis.prototype.normalizedValue = function (value) {
  47025. var axis = this;
  47026. if (axis.logarithmic) {
  47027. value = axis.logarithmic.log2lin(value);
  47028. }
  47029. return 1 - ((axis.max - value) /
  47030. ((axis.max - axis.min) || 1));
  47031. };
  47032. /**
  47033. * Translate from a value to a color.
  47034. * @private
  47035. */
  47036. ColorAxis.prototype.toColor = function (value, point) {
  47037. var axis = this;
  47038. var dataClasses = axis.dataClasses;
  47039. var stops = axis.stops;
  47040. var pos,
  47041. from,
  47042. to,
  47043. color,
  47044. dataClass,
  47045. i;
  47046. if (dataClasses) {
  47047. i = dataClasses.length;
  47048. while (i--) {
  47049. dataClass = dataClasses[i];
  47050. from = dataClass.from;
  47051. to = dataClass.to;
  47052. if ((typeof from === 'undefined' || value >= from) &&
  47053. (typeof to === 'undefined' || value <= to)) {
  47054. color = dataClass.color;
  47055. if (point) {
  47056. point.dataClass = i;
  47057. point.colorIndex = dataClass.colorIndex;
  47058. }
  47059. break;
  47060. }
  47061. }
  47062. }
  47063. else {
  47064. pos = axis.normalizedValue(value);
  47065. i = stops.length;
  47066. while (i--) {
  47067. if (pos > stops[i][0]) {
  47068. break;
  47069. }
  47070. }
  47071. from = stops[i] || stops[i + 1];
  47072. to = stops[i + 1] || from;
  47073. // The position within the gradient
  47074. pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
  47075. color = from.color.tweenTo(to.color, pos);
  47076. }
  47077. return color;
  47078. };
  47079. /**
  47080. * Override the getOffset method to add the whole axis groups inside the
  47081. * legend.
  47082. * @private
  47083. */
  47084. ColorAxis.prototype.getOffset = function () {
  47085. var axis = this;
  47086. var group = axis.legendGroup;
  47087. var sideOffset = axis.chart.axisOffset[axis.side];
  47088. if (group) {
  47089. // Hook for the getOffset method to add groups to this parent
  47090. // group
  47091. axis.axisParent = group;
  47092. // Call the base
  47093. _super.prototype.getOffset.call(this);
  47094. // First time only
  47095. if (!axis.added) {
  47096. axis.added = true;
  47097. axis.labelLeft = 0;
  47098. axis.labelRight = axis.width;
  47099. }
  47100. // Reset it to avoid color axis reserving space
  47101. axis.chart.axisOffset[axis.side] = sideOffset;
  47102. }
  47103. };
  47104. /**
  47105. * Create the color gradient.
  47106. * @private
  47107. */
  47108. ColorAxis.prototype.setLegendColor = function () {
  47109. var axis = this;
  47110. var horiz = axis.horiz;
  47111. var reversed = axis.reversed;
  47112. var one = reversed ? 1 : 0;
  47113. var zero = reversed ? 0 : 1;
  47114. var grad = horiz ? [one, 0,
  47115. zero, 0] : [0,
  47116. zero, 0,
  47117. one]; // #3190
  47118. axis.legendColor = {
  47119. linearGradient: {
  47120. x1: grad[0],
  47121. y1: grad[1],
  47122. x2: grad[2],
  47123. y2: grad[3]
  47124. },
  47125. stops: axis.stops
  47126. };
  47127. };
  47128. /**
  47129. * The color axis appears inside the legend and has its own legend symbol.
  47130. * @private
  47131. */
  47132. ColorAxis.prototype.drawLegendSymbol = function (legend, item) {
  47133. var axis = this;
  47134. var padding = legend.padding;
  47135. var legendOptions = legend.options;
  47136. var horiz = axis.horiz;
  47137. var width = pick(legendOptions.symbolWidth,
  47138. horiz ? ColorAxis.defaultLegendLength : 12);
  47139. var height = pick(legendOptions.symbolHeight,
  47140. horiz ? 12 : ColorAxis.defaultLegendLength);
  47141. var labelPadding = pick(legendOptions.labelPadding,
  47142. horiz ? 16 : 30);
  47143. var itemDistance = pick(legendOptions.itemDistance, 10);
  47144. this.setLegendColor();
  47145. // Create the gradient
  47146. item.legendSymbol = this.chart.renderer.rect(0, legend.baseline - 11, width, height).attr({
  47147. zIndex: 1
  47148. }).add(item.legendGroup);
  47149. // Set how much space this legend item takes up
  47150. axis.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
  47151. axis.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
  47152. };
  47153. /**
  47154. * Fool the legend.
  47155. * @private
  47156. */
  47157. ColorAxis.prototype.setState = function (state) {
  47158. this.series.forEach(function (series) {
  47159. series.setState(state);
  47160. });
  47161. };
  47162. /**
  47163. * @private
  47164. */
  47165. ColorAxis.prototype.setVisible = function () {
  47166. };
  47167. /**
  47168. * @private
  47169. */
  47170. ColorAxis.prototype.getSeriesExtremes = function () {
  47171. var axis = this;
  47172. var series = axis.series;
  47173. var colorValArray,
  47174. colorKey,
  47175. colorValIndex,
  47176. pointArrayMap,
  47177. calculatedExtremes,
  47178. cSeries,
  47179. i = series.length,
  47180. yData,
  47181. j;
  47182. this.dataMin = Infinity;
  47183. this.dataMax = -Infinity;
  47184. while (i--) { // x, y, value, other
  47185. cSeries = series[i];
  47186. colorKey = cSeries.colorKey = pick(cSeries.options.colorKey, cSeries.colorKey, cSeries.pointValKey, cSeries.zoneAxis, 'y');
  47187. pointArrayMap = cSeries.pointArrayMap;
  47188. calculatedExtremes = cSeries[colorKey + 'Min'] &&
  47189. cSeries[colorKey + 'Max'];
  47190. if (cSeries[colorKey + 'Data']) {
  47191. colorValArray = cSeries[colorKey + 'Data'];
  47192. }
  47193. else {
  47194. if (!pointArrayMap) {
  47195. colorValArray = cSeries.yData;
  47196. }
  47197. else {
  47198. colorValArray = [];
  47199. colorValIndex = pointArrayMap.indexOf(colorKey);
  47200. yData = cSeries.yData;
  47201. if (colorValIndex >= 0 && yData) {
  47202. for (j = 0; j < yData.length; j++) {
  47203. colorValArray.push(pick(yData[j][colorValIndex], yData[j]));
  47204. }
  47205. }
  47206. }
  47207. }
  47208. // If color key extremes are already calculated, use them.
  47209. if (calculatedExtremes) {
  47210. cSeries.minColorValue = cSeries[colorKey + 'Min'];
  47211. cSeries.maxColorValue = cSeries[colorKey + 'Max'];
  47212. }
  47213. else {
  47214. var cExtremes = Series.prototype.getExtremes.call(cSeries,
  47215. colorValArray);
  47216. cSeries.minColorValue = cExtremes.dataMin;
  47217. cSeries.maxColorValue = cExtremes.dataMax;
  47218. }
  47219. if (typeof cSeries.minColorValue !== 'undefined') {
  47220. this.dataMin =
  47221. Math.min(this.dataMin, cSeries.minColorValue);
  47222. this.dataMax =
  47223. Math.max(this.dataMax, cSeries.maxColorValue);
  47224. }
  47225. if (!calculatedExtremes) {
  47226. Series.prototype.applyExtremes.call(cSeries);
  47227. }
  47228. }
  47229. };
  47230. /**
  47231. * Internal function to draw a crosshair.
  47232. *
  47233. * @function Highcharts.ColorAxis#drawCrosshair
  47234. *
  47235. * @param {Highcharts.PointerEventObject} [e]
  47236. * The event arguments from the modified pointer event, extended with
  47237. * `chartX` and `chartY`
  47238. *
  47239. * @param {Highcharts.Point} [point]
  47240. * The Point object if the crosshair snaps to points.
  47241. *
  47242. * @fires Highcharts.ColorAxis#event:afterDrawCrosshair
  47243. * @fires Highcharts.ColorAxis#event:drawCrosshair
  47244. */
  47245. ColorAxis.prototype.drawCrosshair = function (e, point) {
  47246. var axis = this;
  47247. var plotX = point && point.plotX;
  47248. var plotY = point && point.plotY;
  47249. var axisPos = axis.pos;
  47250. var axisLen = axis.len;
  47251. var crossPos;
  47252. if (point) {
  47253. crossPos = axis.toPixels(point.getNestedProperty(point.series.colorKey));
  47254. if (crossPos < axisPos) {
  47255. crossPos = axisPos - 2;
  47256. }
  47257. else if (crossPos > axisPos + axisLen) {
  47258. crossPos = axisPos + axisLen + 2;
  47259. }
  47260. point.plotX = crossPos;
  47261. point.plotY = axis.len - crossPos;
  47262. _super.prototype.drawCrosshair.call(this, e, point);
  47263. point.plotX = plotX;
  47264. point.plotY = plotY;
  47265. if (axis.cross &&
  47266. !axis.cross.addedToColorAxis &&
  47267. axis.legendGroup) {
  47268. axis.cross
  47269. .addClass('highcharts-coloraxis-marker')
  47270. .add(axis.legendGroup);
  47271. axis.cross.addedToColorAxis = true;
  47272. if (!axis.chart.styledMode &&
  47273. typeof axis.crosshair === 'object') {
  47274. axis.cross.attr({
  47275. fill: axis.crosshair.color
  47276. });
  47277. }
  47278. }
  47279. }
  47280. };
  47281. /**
  47282. * @private
  47283. */
  47284. ColorAxis.prototype.getPlotLinePath = function (options) {
  47285. var axis = this,
  47286. left = axis.left,
  47287. pos = options.translatedValue,
  47288. top = axis.top;
  47289. // crosshairs only
  47290. return isNumber(pos) ? // pos can be 0 (#3969)
  47291. (axis.horiz ? [
  47292. ['M', pos - 4, top - 6],
  47293. ['L', pos + 4, top - 6],
  47294. ['L', pos, top],
  47295. ['Z']
  47296. ] : [
  47297. ['M', left, pos],
  47298. ['L', left - 6, pos + 6],
  47299. ['L', left - 6, pos - 6],
  47300. ['Z']
  47301. ]) :
  47302. _super.prototype.getPlotLinePath.call(this, options);
  47303. };
  47304. /**
  47305. * Updates a color axis instance with a new set of options. The options are
  47306. * merged with the existing options, so only new or altered options need to
  47307. * be specified.
  47308. *
  47309. * @function Highcharts.ColorAxis#update
  47310. *
  47311. * @param {Highcharts.ColorAxisOptions} newOptions
  47312. * The new options that will be merged in with existing options on the color
  47313. * axis.
  47314. *
  47315. * @param {boolean} [redraw]
  47316. * Whether to redraw the chart after the color axis is altered. If doing
  47317. * more operations on the chart, it is a good idea to set redraw to `false`
  47318. * and call {@link Highcharts.Chart#redraw} after.
  47319. */
  47320. ColorAxis.prototype.update = function (newOptions, redraw) {
  47321. var axis = this,
  47322. chart = axis.chart,
  47323. legend = chart.legend;
  47324. this.series.forEach(function (series) {
  47325. // Needed for Axis.update when choropleth colors change
  47326. series.isDirtyData = true;
  47327. });
  47328. // When updating data classes, destroy old items and make sure new
  47329. // ones are created (#3207)
  47330. if (newOptions.dataClasses && legend.allItems || axis.dataClasses) {
  47331. axis.destroyItems();
  47332. }
  47333. _super.prototype.update.call(this, newOptions, redraw);
  47334. if (axis.legendItem) {
  47335. axis.setLegendColor();
  47336. legend.colorizeItem(this, true);
  47337. }
  47338. };
  47339. /**
  47340. * Destroy color axis legend items.
  47341. * @private
  47342. */
  47343. ColorAxis.prototype.destroyItems = function () {
  47344. var axis = this;
  47345. var chart = axis.chart;
  47346. if (axis.legendItem) {
  47347. chart.legend.destroyItem(axis);
  47348. }
  47349. else if (axis.legendItems) {
  47350. axis.legendItems.forEach(function (item) {
  47351. chart.legend.destroyItem(item);
  47352. });
  47353. }
  47354. chart.isDirtyLegend = true;
  47355. };
  47356. // Removing the whole axis (#14283)
  47357. ColorAxis.prototype.destroy = function () {
  47358. this.chart.isDirtyLegend = true;
  47359. this.destroyItems();
  47360. _super.prototype.destroy.apply(this, [].slice.call(arguments));
  47361. };
  47362. /**
  47363. * Removes the color axis and the related legend item.
  47364. *
  47365. * @function Highcharts.ColorAxis#remove
  47366. *
  47367. * @param {boolean} [redraw=true]
  47368. * Whether to redraw the chart following the remove.
  47369. */
  47370. ColorAxis.prototype.remove = function (redraw) {
  47371. this.destroyItems();
  47372. _super.prototype.remove.call(this, redraw);
  47373. };
  47374. /**
  47375. * Get the legend item symbols for data classes.
  47376. * @private
  47377. */
  47378. ColorAxis.prototype.getDataClassLegendSymbols = function () {
  47379. var axis = this;
  47380. var chart = axis.chart;
  47381. var legendItems = axis.legendItems;
  47382. var legendOptions = chart.options.legend;
  47383. var valueDecimals = legendOptions.valueDecimals;
  47384. var valueSuffix = legendOptions.valueSuffix || '';
  47385. var name;
  47386. if (!legendItems.length) {
  47387. axis.dataClasses.forEach(function (dataClass, i) {
  47388. var vis = true,
  47389. from = dataClass.from,
  47390. to = dataClass.to;
  47391. var numberFormatter = chart.numberFormatter;
  47392. // Assemble the default name. This can be overridden
  47393. // by legend.options.labelFormatter
  47394. name = '';
  47395. if (typeof from === 'undefined') {
  47396. name = '< ';
  47397. }
  47398. else if (typeof to === 'undefined') {
  47399. name = '> ';
  47400. }
  47401. if (typeof from !== 'undefined') {
  47402. name += numberFormatter(from, valueDecimals) + valueSuffix;
  47403. }
  47404. if (typeof from !== 'undefined' && typeof to !== 'undefined') {
  47405. name += ' - ';
  47406. }
  47407. if (typeof to !== 'undefined') {
  47408. name += numberFormatter(to, valueDecimals) + valueSuffix;
  47409. }
  47410. // Add a mock object to the legend items
  47411. legendItems.push(extend({
  47412. chart: chart,
  47413. name: name,
  47414. options: {},
  47415. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  47416. visible: true,
  47417. setState: noop,
  47418. isDataClass: true,
  47419. setVisible: function () {
  47420. vis = axis.visible = !vis;
  47421. axis.series.forEach(function (series) {
  47422. series.points.forEach(function (point) {
  47423. if (point.dataClass === i) {
  47424. point.setVisible(vis);
  47425. }
  47426. });
  47427. });
  47428. chart.legend.colorizeItem(this, vis);
  47429. }
  47430. }, dataClass));
  47431. });
  47432. }
  47433. return legendItems;
  47434. };
  47435. /* *
  47436. *
  47437. * Static Functions
  47438. *
  47439. * */
  47440. ColorAxis.defaultLegendLength = 200;
  47441. /**
  47442. * A color axis for series. Visually, the color
  47443. * axis will appear as a gradient or as separate items inside the
  47444. * legend, depending on whether the axis is scalar or based on data
  47445. * classes.
  47446. *
  47447. * For supported color formats, see the
  47448. * [docs article about colors](https://www.highcharts.com/docs/chart-design-and-style/colors).
  47449. *
  47450. * A scalar color axis is represented by a gradient. The colors either
  47451. * range between the [minColor](#colorAxis.minColor) and the
  47452. * [maxColor](#colorAxis.maxColor), or for more fine grained control the
  47453. * colors can be defined in [stops](#colorAxis.stops). Often times, the
  47454. * color axis needs to be adjusted to get the right color spread for the
  47455. * data. In addition to stops, consider using a logarithmic
  47456. * [axis type](#colorAxis.type), or setting [min](#colorAxis.min) and
  47457. * [max](#colorAxis.max) to avoid the colors being determined by
  47458. * outliers.
  47459. *
  47460. * When [dataClasses](#colorAxis.dataClasses) are used, the ranges are
  47461. * subdivided into separate classes like categories based on their
  47462. * values. This can be used for ranges between two values, but also for
  47463. * a true category. However, when your data is categorized, it may be as
  47464. * convenient to add each category to a separate series.
  47465. *
  47466. * Color axis does not work with: `sankey`, `sunburst`, `dependencywheel`,
  47467. * `networkgraph`, `wordcloud`, `venn`, `gauge` and `solidgauge` series
  47468. * types.
  47469. *
  47470. * Since v7.2.0 `colorAxis` can also be an array of options objects.
  47471. *
  47472. * See [the Axis object](/class-reference/Highcharts.Axis) for
  47473. * programmatic access to the axis.
  47474. *
  47475. * @sample {highcharts} highcharts/coloraxis/custom-color-key
  47476. * Column chart with color axis
  47477. * @sample {highcharts} highcharts/coloraxis/horizontal-layout
  47478. * Horizontal layout
  47479. * @sample {highmaps} maps/coloraxis/dataclasscolor
  47480. * With data classes
  47481. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor
  47482. * Min color and max color
  47483. *
  47484. * @extends xAxis
  47485. * @excluding alignTicks, allowDecimals, alternateGridColor, breaks,
  47486. * categories, crosshair, dateTimeLabelFormats, height, left,
  47487. * lineWidth, linkedTo, maxZoom, minRange, minTickInterval,
  47488. * offset, opposite, pane, plotBands, plotLines,
  47489. * reversedStacks, showEmpty, title, top, width, zoomEnabled
  47490. * @product highcharts highstock highmaps
  47491. * @type {*|Array<*>}
  47492. * @optionparent colorAxis
  47493. * @ignore
  47494. */
  47495. ColorAxis.defaultColorAxisOptions = {
  47496. /**
  47497. * Whether to allow decimals on the color axis.
  47498. * @type {boolean}
  47499. * @default true
  47500. * @product highcharts highstock highmaps
  47501. * @apioption colorAxis.allowDecimals
  47502. */
  47503. /**
  47504. * Determines how to set each data class' color if no individual
  47505. * color is set. The default value, `tween`, computes intermediate
  47506. * colors between `minColor` and `maxColor`. The other possible
  47507. * value, `category`, pulls colors from the global or chart specific
  47508. * [colors](#colors) array.
  47509. *
  47510. * @sample {highmaps} maps/coloraxis/dataclasscolor/
  47511. * Category colors
  47512. *
  47513. * @type {string}
  47514. * @default tween
  47515. * @product highcharts highstock highmaps
  47516. * @validvalue ["tween", "category"]
  47517. * @apioption colorAxis.dataClassColor
  47518. */
  47519. /**
  47520. * An array of data classes or ranges for the choropleth map. If
  47521. * none given, the color axis is scalar and values are distributed
  47522. * as a gradient between the minimum and maximum colors.
  47523. *
  47524. * @sample {highmaps} maps/demo/data-class-ranges/
  47525. * Multiple ranges
  47526. *
  47527. * @sample {highmaps} maps/demo/data-class-two-ranges/
  47528. * Two ranges
  47529. *
  47530. * @type {Array<*>}
  47531. * @product highcharts highstock highmaps
  47532. * @apioption colorAxis.dataClasses
  47533. */
  47534. /**
  47535. * The layout of the color axis. Can be `'horizontal'` or `'vertical'`.
  47536. * If none given, the color axis has the same layout as the legend.
  47537. *
  47538. * @sample highcharts/coloraxis/horizontal-layout/
  47539. * Horizontal color axis layout with vertical legend
  47540. *
  47541. * @type {string|undefined}
  47542. * @since 7.2.0
  47543. * @product highcharts highstock highmaps
  47544. * @apioption colorAxis.layout
  47545. */
  47546. /**
  47547. * The color of each data class. If not set, the color is pulled
  47548. * from the global or chart-specific [colors](#colors) array. In
  47549. * styled mode, this option is ignored. Instead, use colors defined
  47550. * in CSS.
  47551. *
  47552. * @sample {highmaps} maps/demo/data-class-two-ranges/
  47553. * Explicit colors
  47554. *
  47555. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47556. * @product highcharts highstock highmaps
  47557. * @apioption colorAxis.dataClasses.color
  47558. */
  47559. /**
  47560. * The start of the value range that the data class represents,
  47561. * relating to the point value.
  47562. *
  47563. * The range of each `dataClass` is closed in both ends, but can be
  47564. * overridden by the next `dataClass`.
  47565. *
  47566. * @type {number}
  47567. * @product highcharts highstock highmaps
  47568. * @apioption colorAxis.dataClasses.from
  47569. */
  47570. /**
  47571. * The name of the data class as it appears in the legend.
  47572. * If no name is given, it is automatically created based on the
  47573. * `from` and `to` values. For full programmatic control,
  47574. * [legend.labelFormatter](#legend.labelFormatter) can be used.
  47575. * In the formatter, `this.from` and `this.to` can be accessed.
  47576. *
  47577. * @sample {highmaps} maps/coloraxis/dataclasses-name/
  47578. * Named data classes
  47579. *
  47580. * @sample {highmaps} maps/coloraxis/dataclasses-labelformatter/
  47581. * Formatted data classes
  47582. *
  47583. * @type {string}
  47584. * @product highcharts highstock highmaps
  47585. * @apioption colorAxis.dataClasses.name
  47586. */
  47587. /**
  47588. * The end of the value range that the data class represents,
  47589. * relating to the point value.
  47590. *
  47591. * The range of each `dataClass` is closed in both ends, but can be
  47592. * overridden by the next `dataClass`.
  47593. *
  47594. * @type {number}
  47595. * @product highcharts highstock highmaps
  47596. * @apioption colorAxis.dataClasses.to
  47597. */
  47598. /** @ignore-option */
  47599. lineWidth: 0,
  47600. /**
  47601. * Padding of the min value relative to the length of the axis. A
  47602. * padding of 0.05 will make a 100px axis 5px longer.
  47603. *
  47604. * @product highcharts highstock highmaps
  47605. */
  47606. minPadding: 0,
  47607. /**
  47608. * The maximum value of the axis in terms of map point values. If
  47609. * `null`, the max value is automatically calculated. If the
  47610. * `endOnTick` option is true, the max value might be rounded up.
  47611. *
  47612. * @sample {highmaps} maps/coloraxis/gridlines/
  47613. * Explicit min and max to reduce the effect of outliers
  47614. *
  47615. * @type {number}
  47616. * @product highcharts highstock highmaps
  47617. * @apioption colorAxis.max
  47618. */
  47619. /**
  47620. * The minimum value of the axis in terms of map point values. If
  47621. * `null`, the min value is automatically calculated. If the
  47622. * `startOnTick` option is true, the min value might be rounded
  47623. * down.
  47624. *
  47625. * @sample {highmaps} maps/coloraxis/gridlines/
  47626. * Explicit min and max to reduce the effect of outliers
  47627. *
  47628. * @type {number}
  47629. * @product highcharts highstock highmaps
  47630. * @apioption colorAxis.min
  47631. */
  47632. /**
  47633. * Padding of the max value relative to the length of the axis. A
  47634. * padding of 0.05 will make a 100px axis 5px longer.
  47635. *
  47636. * @product highcharts highstock highmaps
  47637. */
  47638. maxPadding: 0,
  47639. /**
  47640. * Color of the grid lines extending from the axis across the
  47641. * gradient.
  47642. *
  47643. * @sample {highmaps} maps/coloraxis/gridlines/
  47644. * Grid lines demonstrated
  47645. *
  47646. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47647. * @default #e6e6e6
  47648. * @product highcharts highstock highmaps
  47649. * @apioption colorAxis.gridLineColor
  47650. */
  47651. /**
  47652. * The width of the grid lines extending from the axis across the
  47653. * gradient of a scalar color axis.
  47654. *
  47655. * @sample {highmaps} maps/coloraxis/gridlines/
  47656. * Grid lines demonstrated
  47657. *
  47658. * @product highcharts highstock highmaps
  47659. */
  47660. gridLineWidth: 1,
  47661. /**
  47662. * The interval of the tick marks in axis units. When `null`, the
  47663. * tick interval is computed to approximately follow the
  47664. * `tickPixelInterval`.
  47665. *
  47666. * @type {number}
  47667. * @product highcharts highstock highmaps
  47668. * @apioption colorAxis.tickInterval
  47669. */
  47670. /**
  47671. * If [tickInterval](#colorAxis.tickInterval) is `null` this option
  47672. * sets the approximate pixel interval of the tick marks.
  47673. *
  47674. * @product highcharts highstock highmaps
  47675. */
  47676. tickPixelInterval: 72,
  47677. /**
  47678. * Whether to force the axis to start on a tick. Use this option
  47679. * with the `maxPadding` option to control the axis start.
  47680. *
  47681. * @product highcharts highstock highmaps
  47682. */
  47683. startOnTick: true,
  47684. /**
  47685. * Whether to force the axis to end on a tick. Use this option with
  47686. * the [maxPadding](#colorAxis.maxPadding) option to control the
  47687. * axis end.
  47688. *
  47689. * @product highcharts highstock highmaps
  47690. */
  47691. endOnTick: true,
  47692. /** @ignore */
  47693. offset: 0,
  47694. /**
  47695. * The triangular marker on a scalar color axis that points to the
  47696. * value of the hovered area. To disable the marker, set
  47697. * `marker: null`.
  47698. *
  47699. * @sample {highmaps} maps/coloraxis/marker/
  47700. * Black marker
  47701. *
  47702. * @declare Highcharts.PointMarkerOptionsObject
  47703. * @product highcharts highstock highmaps
  47704. */
  47705. marker: {
  47706. /**
  47707. * Animation for the marker as it moves between values. Set to
  47708. * `false` to disable animation. Defaults to `{ duration: 50 }`.
  47709. *
  47710. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  47711. * @product highcharts highstock highmaps
  47712. */
  47713. animation: {
  47714. /** @internal */
  47715. duration: 50
  47716. },
  47717. /** @internal */
  47718. width: 0.01,
  47719. /**
  47720. * The color of the marker.
  47721. *
  47722. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47723. * @product highcharts highstock highmaps
  47724. */
  47725. color: palette.neutralColor40
  47726. },
  47727. /**
  47728. * The axis labels show the number for each tick.
  47729. *
  47730. * For more live examples on label options, see [xAxis.labels in the
  47731. * Highcharts API.](/highcharts#xAxis.labels)
  47732. *
  47733. * @extends xAxis.labels
  47734. * @product highcharts highstock highmaps
  47735. */
  47736. labels: {
  47737. /**
  47738. * How to handle overflowing labels on horizontal color axis. If set
  47739. * to `"allow"`, it will not be aligned at all. By default it
  47740. * `"justify"` labels inside the chart area. If there is room to
  47741. * move it, it will be aligned to the edge, else it will be removed.
  47742. *
  47743. * @validvalue ["allow", "justify"]
  47744. * @product highcharts highstock highmaps
  47745. */
  47746. overflow: 'justify',
  47747. rotation: 0
  47748. },
  47749. /**
  47750. * The color to represent the minimum of the color axis. Unless
  47751. * [dataClasses](#colorAxis.dataClasses) or
  47752. * [stops](#colorAxis.stops) are set, the gradient starts at this
  47753. * value.
  47754. *
  47755. * If dataClasses are set, the color is based on minColor and
  47756. * maxColor unless a color is set for each data class, or the
  47757. * [dataClassColor](#colorAxis.dataClassColor) is set.
  47758. *
  47759. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  47760. * Min and max colors on scalar (gradient) axis
  47761. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  47762. * On data classes
  47763. *
  47764. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47765. * @product highcharts highstock highmaps
  47766. */
  47767. minColor: palette.highlightColor10,
  47768. /**
  47769. * The color to represent the maximum of the color axis. Unless
  47770. * [dataClasses](#colorAxis.dataClasses) or
  47771. * [stops](#colorAxis.stops) are set, the gradient ends at this
  47772. * value.
  47773. *
  47774. * If dataClasses are set, the color is based on minColor and
  47775. * maxColor unless a color is set for each data class, or the
  47776. * [dataClassColor](#colorAxis.dataClassColor) is set.
  47777. *
  47778. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  47779. * Min and max colors on scalar (gradient) axis
  47780. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  47781. * On data classes
  47782. *
  47783. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47784. * @product highcharts highstock highmaps
  47785. */
  47786. maxColor: palette.highlightColor100,
  47787. /**
  47788. * Color stops for the gradient of a scalar color axis. Use this in
  47789. * cases where a linear gradient between a `minColor` and `maxColor`
  47790. * is not sufficient. The stops is an array of tuples, where the
  47791. * first item is a float between 0 and 1 assigning the relative
  47792. * position in the gradient, and the second item is the color.
  47793. *
  47794. * @sample {highmaps} maps/demo/heatmap/
  47795. * Heatmap with three color stops
  47796. *
  47797. * @type {Array<Array<number,Highcharts.ColorString>>}
  47798. * @product highcharts highstock highmaps
  47799. * @apioption colorAxis.stops
  47800. */
  47801. /**
  47802. * The pixel length of the main tick marks on the color axis.
  47803. */
  47804. tickLength: 5,
  47805. /**
  47806. * The type of interpolation to use for the color axis. Can be
  47807. * `linear` or `logarithmic`.
  47808. *
  47809. * @sample highcharts/coloraxis/logarithmic-with-emulate-negative-values/
  47810. * Logarithmic color axis with extension to emulate negative
  47811. * values
  47812. *
  47813. * @type {Highcharts.ColorAxisTypeValue}
  47814. * @default linear
  47815. * @product highcharts highstock highmaps
  47816. * @apioption colorAxis.type
  47817. */
  47818. /**
  47819. * Whether to reverse the axis so that the highest number is closest
  47820. * to the origin. Defaults to `false` in a horizontal legend and
  47821. * `true` in a vertical legend, where the smallest value starts on
  47822. * top.
  47823. *
  47824. * @type {boolean}
  47825. * @product highcharts highstock highmaps
  47826. * @apioption colorAxis.reversed
  47827. */
  47828. /**
  47829. * @product highcharts highstock highmaps
  47830. * @excluding afterBreaks, pointBreak, pointInBreak
  47831. * @apioption colorAxis.events
  47832. */
  47833. /**
  47834. * Fires when the legend item belonging to the colorAxis is clicked.
  47835. * One parameter, `event`, is passed to the function.
  47836. *
  47837. * @type {Function}
  47838. * @product highcharts highstock highmaps
  47839. * @apioption colorAxis.events.legendItemClick
  47840. */
  47841. /**
  47842. * Whether to display the colorAxis in the legend.
  47843. *
  47844. * @sample highcharts/coloraxis/hidden-coloraxis-with-3d-chart/
  47845. * Hidden color axis with 3d chart
  47846. *
  47847. * @see [heatmap.showInLegend](#series.heatmap.showInLegend)
  47848. *
  47849. * @since 4.2.7
  47850. * @product highcharts highstock highmaps
  47851. */
  47852. showInLegend: true
  47853. };
  47854. /**
  47855. * @private
  47856. */
  47857. ColorAxis.keepProps = [
  47858. 'legendGroup',
  47859. 'legendItemHeight',
  47860. 'legendItemWidth',
  47861. 'legendItem',
  47862. 'legendSymbol'
  47863. ];
  47864. return ColorAxis;
  47865. }(Axis));
  47866. // Properties to preserve after destroy, for Axis.update (#5881, #6025).
  47867. Array.prototype.push.apply(Axis.keepProps, ColorAxis.keepProps);
  47868. H.ColorAxis = ColorAxis;
  47869. /**
  47870. * Handle animation of the color attributes directly
  47871. *
  47872. * @private
  47873. * @function Highcharts.Fx#fillSetter
  47874. */ /**
  47875. * Handle animation of the color attributes directly
  47876. *
  47877. * @private
  47878. * @function Highcharts.Fx#strokeSetter
  47879. */
  47880. ['fill', 'stroke'].forEach(function (prop) {
  47881. Fx.prototype[prop + 'Setter'] = function () {
  47882. this.elem.attr(prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  47883. };
  47884. });
  47885. // Extend the chart getAxes method to also get the color axis
  47886. addEvent(Chart, 'afterGetAxes', function () {
  47887. var chart = this,
  47888. options = chart.options;
  47889. this.colorAxis = [];
  47890. if (options.colorAxis) {
  47891. options.colorAxis = splat(options.colorAxis);
  47892. options.colorAxis.forEach(function (axisOptions, i) {
  47893. axisOptions.index = i;
  47894. new ColorAxis(chart, axisOptions); // eslint-disable-line no-new
  47895. });
  47896. }
  47897. });
  47898. // Add colorAxis to series axisTypes
  47899. addEvent(Series, 'bindAxes', function () {
  47900. var axisTypes = this.axisTypes;
  47901. if (!axisTypes) {
  47902. this.axisTypes = ['colorAxis'];
  47903. }
  47904. else if (axisTypes.indexOf('colorAxis') === -1) {
  47905. axisTypes.push('colorAxis');
  47906. }
  47907. });
  47908. // Add the color axis. This also removes the axis' own series to prevent
  47909. // them from showing up individually.
  47910. addEvent(Legend, 'afterGetAllItems', function (e) {
  47911. var _this = this;
  47912. var colorAxisItems = [],
  47913. colorAxes = this.chart.colorAxis || [],
  47914. options,
  47915. i;
  47916. var destroyItem = function (item) {
  47917. var i = e.allItems.indexOf(item);
  47918. if (i !== -1) {
  47919. // #15436
  47920. _this.destroyItem(e.allItems[i]);
  47921. e.allItems.splice(i, 1);
  47922. }
  47923. };
  47924. colorAxes.forEach(function (colorAxis) {
  47925. options = colorAxis.options;
  47926. if (options && options.showInLegend) {
  47927. // Data classes
  47928. if (options.dataClasses && options.visible) {
  47929. colorAxisItems = colorAxisItems.concat(colorAxis.getDataClassLegendSymbols());
  47930. // Gradient legend
  47931. }
  47932. else if (options.visible) {
  47933. // Add this axis on top
  47934. colorAxisItems.push(colorAxis);
  47935. }
  47936. // If dataClasses are defined or showInLegend option is not set to
  47937. // true, do not add color axis' series to legend.
  47938. colorAxis.series.forEach(function (series) {
  47939. if (!series.options.showInLegend || options.dataClasses) {
  47940. if (series.options.legendType === 'point') {
  47941. series.points.forEach(function (point) {
  47942. destroyItem(point);
  47943. });
  47944. }
  47945. else {
  47946. destroyItem(series);
  47947. }
  47948. }
  47949. });
  47950. }
  47951. });
  47952. i = colorAxisItems.length;
  47953. while (i--) {
  47954. e.allItems.unshift(colorAxisItems[i]);
  47955. }
  47956. });
  47957. addEvent(Legend, 'afterColorizeItem', function (e) {
  47958. if (e.visible && e.item.legendColor) {
  47959. e.item.legendSymbol.attr({
  47960. fill: e.item.legendColor
  47961. });
  47962. }
  47963. });
  47964. // Updates in the legend need to be reflected in the color axis (6888)
  47965. addEvent(Legend, 'afterUpdate', function () {
  47966. var colorAxes = this.chart.colorAxis;
  47967. if (colorAxes) {
  47968. colorAxes.forEach(function (colorAxis) {
  47969. colorAxis.update({}, arguments[2]);
  47970. });
  47971. }
  47972. });
  47973. // Calculate and set colors for points
  47974. addEvent(Series, 'afterTranslate', function () {
  47975. if (this.chart.colorAxis &&
  47976. this.chart.colorAxis.length ||
  47977. this.colorAttribs) {
  47978. this.translateColors();
  47979. }
  47980. });
  47981. return ColorAxis;
  47982. });
  47983. _registerModule(_modules, 'Mixins/ColorMapSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  47984. /* *
  47985. *
  47986. * (c) 2010-2021 Torstein Honsi
  47987. *
  47988. * License: www.highcharts.com/license
  47989. *
  47990. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47991. *
  47992. * */
  47993. var defined = U.defined,
  47994. addEvent = U.addEvent;
  47995. var noop = H.noop,
  47996. seriesTypes = H.seriesTypes;
  47997. // Move points to the top of the z-index order when hovered
  47998. addEvent(Point, 'afterSetState', function (e) {
  47999. var point = this; // eslint-disable-line no-invalid-this
  48000. if (point.moveToTopOnHover && point.graphic) {
  48001. point.graphic.attr({
  48002. zIndex: e && e.state === 'hover' ? 1 : 0
  48003. });
  48004. }
  48005. });
  48006. /**
  48007. * Mixin for maps and heatmaps
  48008. *
  48009. * @private
  48010. * @mixin Highcharts.colorMapPointMixin
  48011. */
  48012. var colorMapPointMixin = {
  48013. dataLabelOnNull: true,
  48014. moveToTopOnHover: true,
  48015. /* eslint-disable valid-jsdoc */
  48016. /**
  48017. * Color points have a value option that determines whether or not it is
  48018. * a null point
  48019. * @private
  48020. */
  48021. isValid: function () {
  48022. // undefined is allowed
  48023. return (this.value !== null &&
  48024. this.value !== Infinity &&
  48025. this.value !== -Infinity);
  48026. }
  48027. /* eslint-enable valid-jsdoc */
  48028. };
  48029. /**
  48030. * @private
  48031. * @mixin Highcharts.colorMapSeriesMixin
  48032. */
  48033. var colorMapSeriesMixin = {
  48034. pointArrayMap: ['value'],
  48035. axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
  48036. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  48037. getSymbol: noop,
  48038. parallelArrays: ['x', 'y', 'value'],
  48039. colorKey: 'value',
  48040. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  48041. /* eslint-disable valid-jsdoc */
  48042. /**
  48043. * Get the color attibutes to apply on the graphic
  48044. * @private
  48045. * @function Highcharts.colorMapSeriesMixin.colorAttribs
  48046. * @param {Highcharts.Point} point
  48047. * @return {Highcharts.SVGAttributes}
  48048. */
  48049. colorAttribs: function (point) {
  48050. var ret = {};
  48051. if (defined(point.color)) {
  48052. ret[this.colorProp || 'fill'] = point.color;
  48053. }
  48054. return ret;
  48055. }
  48056. };
  48057. var exports = {
  48058. colorMapPointMixin: colorMapPointMixin,
  48059. colorMapSeriesMixin: colorMapSeriesMixin
  48060. };
  48061. return exports;
  48062. });
  48063. _registerModule(_modules, 'Maps/MapNavigationOptionsDefault.js', [_modules['Core/Options.js'], _modules['Core/Utilities.js']], function (O, U) {
  48064. /* *
  48065. *
  48066. * (c) 2010-2021 Torstein Honsi
  48067. *
  48068. * License: www.highcharts.com/license
  48069. *
  48070. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48071. *
  48072. * */
  48073. var extend = U.extend;
  48074. /* *
  48075. *
  48076. * Constants
  48077. *
  48078. * */
  48079. /**
  48080. * @product highmaps
  48081. * @optionparent mapNavigation
  48082. */
  48083. var defaultOptions = {
  48084. /**
  48085. * General options for the map navigation buttons. Individual options
  48086. * can be given from the [mapNavigation.buttons](#mapNavigation.buttons)
  48087. * option set.
  48088. *
  48089. * @sample {highmaps} maps/mapnavigation/button-theme/
  48090. * Theming the navigation buttons
  48091. */
  48092. buttonOptions: {
  48093. /**
  48094. * What box to align the buttons to. Possible values are `plotBox`
  48095. * and `spacingBox`.
  48096. *
  48097. * @type {Highcharts.ButtonRelativeToValue}
  48098. */
  48099. alignTo: 'plotBox',
  48100. /**
  48101. * The alignment of the navigation buttons.
  48102. *
  48103. * @type {Highcharts.AlignValue}
  48104. */
  48105. align: 'left',
  48106. /**
  48107. * The vertical alignment of the buttons. Individual alignment can
  48108. * be adjusted by each button's `y` offset.
  48109. *
  48110. * @type {Highcharts.VerticalAlignValue}
  48111. */
  48112. verticalAlign: 'top',
  48113. /**
  48114. * The X offset of the buttons relative to its `align` setting.
  48115. */
  48116. x: 0,
  48117. /**
  48118. * The width of the map navigation buttons.
  48119. */
  48120. width: 18,
  48121. /**
  48122. * The pixel height of the map navigation buttons.
  48123. */
  48124. height: 18,
  48125. /**
  48126. * Padding for the navigation buttons.
  48127. *
  48128. * @since 5.0.0
  48129. */
  48130. padding: 5,
  48131. /**
  48132. * Text styles for the map navigation buttons.
  48133. *
  48134. * @type {Highcharts.CSSObject}
  48135. * @default {"fontSize": "15px", "fontWeight": "bold"}
  48136. */
  48137. style: {
  48138. /** @ignore */
  48139. fontSize: '15px',
  48140. /** @ignore */
  48141. fontWeight: 'bold'
  48142. },
  48143. /**
  48144. * A configuration object for the button theme. The object accepts
  48145. * SVG properties like `stroke-width`, `stroke` and `fill`. Tri-state
  48146. * button styles are supported by the `states.hover` and `states.select`
  48147. * objects.
  48148. *
  48149. * @sample {highmaps} maps/mapnavigation/button-theme/
  48150. * Themed navigation buttons
  48151. *
  48152. * @type {Highcharts.SVGAttributes}
  48153. * @default {"stroke-width": 1, "text-align": "center"}
  48154. */
  48155. theme: {
  48156. /** @ignore */
  48157. 'stroke-width': 1,
  48158. /** @ignore */
  48159. 'text-align': 'center'
  48160. }
  48161. },
  48162. /**
  48163. * The individual buttons for the map navigation. This usually includes
  48164. * the zoom in and zoom out buttons. Properties for each button is
  48165. * inherited from
  48166. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  48167. * individual options can be overridden. But default, the `onclick`, `text`
  48168. * and `y` options are individual.
  48169. */
  48170. buttons: {
  48171. /**
  48172. * Options for the zoom in button. Properties for the zoom in and zoom
  48173. * out buttons are inherited from
  48174. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  48175. * individual options can be overridden. By default, the `onclick`,
  48176. * `text` and `y` options are individual.
  48177. *
  48178. * @extends mapNavigation.buttonOptions
  48179. */
  48180. zoomIn: {
  48181. // eslint-disable-next-line valid-jsdoc
  48182. /**
  48183. * Click handler for the button.
  48184. *
  48185. * @type {Function}
  48186. * @default function () { this.mapZoom(0.5); }
  48187. */
  48188. onclick: function () {
  48189. this.mapZoom(0.5);
  48190. },
  48191. /**
  48192. * The text for the button. The tooltip (title) is a language option
  48193. * given by [lang.zoomIn](#lang.zoomIn).
  48194. */
  48195. text: '+',
  48196. /**
  48197. * The position of the zoomIn button relative to the vertical
  48198. * alignment.
  48199. */
  48200. y: 0
  48201. },
  48202. /**
  48203. * Options for the zoom out button. Properties for the zoom in and
  48204. * zoom out buttons are inherited from
  48205. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  48206. * individual options can be overridden. By default, the `onclick`,
  48207. * `text` and `y` options are individual.
  48208. *
  48209. * @extends mapNavigation.buttonOptions
  48210. */
  48211. zoomOut: {
  48212. // eslint-disable-next-line valid-jsdoc
  48213. /**
  48214. * Click handler for the button.
  48215. *
  48216. * @type {Function}
  48217. * @default function () { this.mapZoom(2); }
  48218. */
  48219. onclick: function () {
  48220. this.mapZoom(2);
  48221. },
  48222. /**
  48223. * The text for the button. The tooltip (title) is a language option
  48224. * given by [lang.zoomOut](#lang.zoomIn).
  48225. */
  48226. text: '-',
  48227. /**
  48228. * The position of the zoomOut button relative to the vertical
  48229. * alignment.
  48230. */
  48231. y: 28
  48232. }
  48233. },
  48234. /**
  48235. * Whether to enable navigation buttons. By default it inherits the
  48236. * [enabled](#mapNavigation.enabled) setting.
  48237. *
  48238. * @type {boolean}
  48239. * @apioption mapNavigation.enableButtons
  48240. */
  48241. /**
  48242. * Whether to enable map navigation. The default is not to enable
  48243. * navigation, as many choropleth maps are simple and don't need it.
  48244. * Additionally, when touch zoom and mousewheel zoom is enabled, it breaks
  48245. * the default behaviour of these interactions in the website, and the
  48246. * implementer should be aware of this.
  48247. *
  48248. * Individual interactions can be enabled separately, namely buttons,
  48249. * multitouch zoom, double click zoom, double click zoom to element and
  48250. * mousewheel zoom.
  48251. *
  48252. * @type {boolean}
  48253. * @default false
  48254. * @apioption mapNavigation.enabled
  48255. */
  48256. /**
  48257. * Enables zooming in on an area on double clicking in the map. By default
  48258. * it inherits the [enabled](#mapNavigation.enabled) setting.
  48259. *
  48260. * @type {boolean}
  48261. * @apioption mapNavigation.enableDoubleClickZoom
  48262. */
  48263. /**
  48264. * Whether to zoom in on an area when that area is double clicked.
  48265. *
  48266. * @sample {highmaps} maps/mapnavigation/doubleclickzoomto/
  48267. * Enable double click zoom to
  48268. *
  48269. * @type {boolean}
  48270. * @default false
  48271. * @apioption mapNavigation.enableDoubleClickZoomTo
  48272. */
  48273. /**
  48274. * Enables zooming by mouse wheel. By default it inherits the [enabled](
  48275. * #mapNavigation.enabled) setting.
  48276. *
  48277. * @type {boolean}
  48278. * @apioption mapNavigation.enableMouseWheelZoom
  48279. */
  48280. /**
  48281. * Whether to enable multitouch zooming. Note that if the chart covers the
  48282. * viewport, this prevents the user from using multitouch and touchdrag on
  48283. * the web page, so you should make sure the user is not trapped inside the
  48284. * chart. By default it inherits the [enabled](#mapNavigation.enabled)
  48285. * setting.
  48286. *
  48287. * @type {boolean}
  48288. * @apioption mapNavigation.enableTouchZoom
  48289. */
  48290. /**
  48291. * Sensitivity of mouse wheel or trackpad scrolling. 1 is no sensitivity,
  48292. * while with 2, one mousewheel delta will zoom in 50%.
  48293. *
  48294. * @since 4.2.4
  48295. */
  48296. mouseWheelSensitivity: 1.1
  48297. // enabled: false,
  48298. // enableButtons: null, // inherit from enabled
  48299. // enableTouchZoom: null, // inherit from enabled
  48300. // enableDoubleClickZoom: null, // inherit from enabled
  48301. // enableDoubleClickZoomTo: false
  48302. // enableMouseWheelZoom: null, // inherit from enabled
  48303. };
  48304. /* *
  48305. *
  48306. * Composition
  48307. *
  48308. * */
  48309. // Add language
  48310. extend(O.defaultOptions.lang, {
  48311. zoomIn: 'Zoom in',
  48312. zoomOut: 'Zoom out'
  48313. });
  48314. // Set the default map navigation options
  48315. O.defaultOptions.mapNavigation = defaultOptions;
  48316. /* *
  48317. *
  48318. * Default Export
  48319. *
  48320. * */
  48321. return defaultOptions;
  48322. });
  48323. _registerModule(_modules, 'Maps/MapNavigation.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, H, U) {
  48324. /* *
  48325. *
  48326. * (c) 2010-2021 Torstein Honsi
  48327. *
  48328. * License: www.highcharts.com/license
  48329. *
  48330. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48331. *
  48332. * */
  48333. var doc = H.doc;
  48334. var addEvent = U.addEvent,
  48335. extend = U.extend,
  48336. merge = U.merge,
  48337. objectEach = U.objectEach,
  48338. pick = U.pick;
  48339. /* eslint-disable no-invalid-this, valid-jsdoc */
  48340. /**
  48341. * @private
  48342. */
  48343. function stopEvent(e) {
  48344. if (e) {
  48345. if (e.preventDefault) {
  48346. e.preventDefault();
  48347. }
  48348. if (e.stopPropagation) {
  48349. e.stopPropagation();
  48350. }
  48351. e.cancelBubble = true;
  48352. }
  48353. }
  48354. /**
  48355. * The MapNavigation handles buttons for navigation in addition to mousewheel
  48356. * and doubleclick handlers for chart zooming.
  48357. *
  48358. * @private
  48359. * @class
  48360. * @name MapNavigation
  48361. *
  48362. * @param {Highcharts.Chart} chart
  48363. * The Chart instance.
  48364. */
  48365. function MapNavigation(chart) {
  48366. this.init(chart);
  48367. }
  48368. /**
  48369. * Initialize function.
  48370. *
  48371. * @function MapNavigation#init
  48372. *
  48373. * @param {Highcharts.Chart} chart
  48374. * The Chart instance.
  48375. *
  48376. * @return {void}
  48377. */
  48378. MapNavigation.prototype.init = function (chart) {
  48379. this.chart = chart;
  48380. chart.mapNavButtons = [];
  48381. };
  48382. /**
  48383. * Update the map navigation with new options. Calling this is the same as
  48384. * calling `chart.update({ mapNavigation: {} })`.
  48385. *
  48386. * @function MapNavigation#update
  48387. *
  48388. * @param {Highcharts.MapNavigationOptions} [options]
  48389. * New options for the map navigation.
  48390. *
  48391. * @return {void}
  48392. */
  48393. MapNavigation.prototype.update = function (options) {
  48394. var chart = this.chart,
  48395. o = chart.options.mapNavigation,
  48396. attr,
  48397. states,
  48398. hoverStates,
  48399. selectStates,
  48400. outerHandler = function (e) {
  48401. this.handler.call(chart,
  48402. e);
  48403. stopEvent(e); // Stop default click event (#4444)
  48404. }, mapNavButtons = chart.mapNavButtons;
  48405. // Merge in new options in case of update, and register back to chart
  48406. // options.
  48407. if (options) {
  48408. o = chart.options.mapNavigation =
  48409. merge(chart.options.mapNavigation, options);
  48410. }
  48411. // Destroy buttons in case of dynamic update
  48412. while (mapNavButtons.length) {
  48413. mapNavButtons.pop().destroy();
  48414. }
  48415. if (pick(o.enableButtons, o.enabled) && !chart.renderer.forExport) {
  48416. objectEach(o.buttons, function (buttonOptions, n) {
  48417. buttonOptions = merge(o.buttonOptions, buttonOptions);
  48418. // Presentational
  48419. if (!chart.styledMode && buttonOptions.theme) {
  48420. attr = buttonOptions.theme;
  48421. attr.style = merge(buttonOptions.theme.style, buttonOptions.style // #3203
  48422. );
  48423. states = attr.states;
  48424. hoverStates = states && states.hover;
  48425. selectStates = states && states.select;
  48426. delete attr.states;
  48427. }
  48428. var button = chart.renderer
  48429. .button(buttonOptions.text || '', 0, 0, outerHandler, attr, hoverStates, selectStates, void 0, n === 'zoomIn' ? 'topbutton' : 'bottombutton')
  48430. .addClass('highcharts-map-navigation highcharts-' + {
  48431. zoomIn: 'zoom-in',
  48432. zoomOut: 'zoom-out'
  48433. }[n])
  48434. .attr({
  48435. width: buttonOptions.width,
  48436. height: buttonOptions.height,
  48437. title: chart.options.lang[n],
  48438. padding: buttonOptions.padding,
  48439. zIndex: 5
  48440. })
  48441. .add();
  48442. button.handler = buttonOptions.onclick;
  48443. // Stop double click event (#4444)
  48444. addEvent(button.element, 'dblclick', stopEvent);
  48445. mapNavButtons.push(button);
  48446. extend(buttonOptions, {
  48447. width: button.width,
  48448. height: 2 * button.height
  48449. });
  48450. if (!chart.hasLoaded) {
  48451. // Align it after the plotBox is known (#12776)
  48452. var unbind_1 = addEvent(chart, 'load',
  48453. function () {
  48454. // #15406: Make sure button hasnt been destroyed
  48455. if (button.element) {
  48456. button.align(buttonOptions,
  48457. false,
  48458. buttonOptions.alignTo);
  48459. }
  48460. unbind_1();
  48461. });
  48462. }
  48463. else {
  48464. button.align(buttonOptions, false, buttonOptions.alignTo);
  48465. }
  48466. });
  48467. }
  48468. this.updateEvents(o);
  48469. };
  48470. /**
  48471. * Update events, called internally from the update function. Add new event
  48472. * handlers, or unbinds events if disabled.
  48473. *
  48474. * @function MapNavigation#updateEvents
  48475. *
  48476. * @param {Highcharts.MapNavigationOptions} options
  48477. * Options for map navigation.
  48478. *
  48479. * @return {void}
  48480. */
  48481. MapNavigation.prototype.updateEvents = function (options) {
  48482. var chart = this.chart;
  48483. // Add the double click event
  48484. if (pick(options.enableDoubleClickZoom, options.enabled) ||
  48485. options.enableDoubleClickZoomTo) {
  48486. this.unbindDblClick = this.unbindDblClick || addEvent(chart.container, 'dblclick', function (e) {
  48487. chart.pointer.onContainerDblClick(e);
  48488. });
  48489. }
  48490. else if (this.unbindDblClick) {
  48491. // Unbind and set unbinder to undefined
  48492. this.unbindDblClick = this.unbindDblClick();
  48493. }
  48494. // Add the mousewheel event
  48495. if (pick(options.enableMouseWheelZoom, options.enabled)) {
  48496. this.unbindMouseWheel = this.unbindMouseWheel || addEvent(chart.container, doc.onwheel !== void 0 ? 'wheel' : // Newer Firefox
  48497. doc.onmousewheel !== void 0 ? 'mousewheel' :
  48498. 'DOMMouseScroll', function (e) {
  48499. // Prevent scrolling when the pointer is over the element
  48500. // with that class, for example anotation popup #12100.
  48501. if (!chart.pointer.inClass(e.target, 'highcharts-no-mousewheel')) {
  48502. chart.pointer.onContainerMouseWheel(e);
  48503. // Issue #5011, returning false from non-jQuery event does
  48504. // not prevent default
  48505. stopEvent(e);
  48506. }
  48507. return false;
  48508. });
  48509. }
  48510. else if (this.unbindMouseWheel) {
  48511. // Unbind and set unbinder to undefined
  48512. this.unbindMouseWheel = this.unbindMouseWheel();
  48513. }
  48514. };
  48515. // Add events to the Chart object itself
  48516. extend(Chart.prototype, /** @lends Chart.prototype */ {
  48517. /**
  48518. * Fit an inner box to an outer. If the inner box overflows left or right,
  48519. * align it to the sides of the outer. If it overflows both sides, fit it
  48520. * within the outer. This is a pattern that occurs more places in
  48521. * Highcharts, perhaps it should be elevated to a common utility function.
  48522. *
  48523. * @ignore
  48524. * @function Highcharts.Chart#fitToBox
  48525. *
  48526. * @param {Highcharts.BBoxObject} inner
  48527. *
  48528. * @param {Highcharts.BBoxObject} outer
  48529. *
  48530. * @return {Highcharts.BBoxObject}
  48531. * The inner box
  48532. */
  48533. fitToBox: function (inner, outer) {
  48534. [['x', 'width'], ['y', 'height']].forEach(function (dim) {
  48535. var pos = dim[0],
  48536. size = dim[1];
  48537. if (inner[pos] + inner[size] >
  48538. outer[pos] + outer[size]) { // right
  48539. // the general size is greater, fit fully to outer
  48540. if (inner[size] > outer[size]) {
  48541. inner[size] = outer[size];
  48542. inner[pos] = outer[pos];
  48543. }
  48544. else { // align right
  48545. inner[pos] = outer[pos] +
  48546. outer[size] - inner[size];
  48547. }
  48548. }
  48549. if (inner[size] > outer[size]) {
  48550. inner[size] = outer[size];
  48551. }
  48552. if (inner[pos] < outer[pos]) {
  48553. inner[pos] = outer[pos];
  48554. }
  48555. });
  48556. return inner;
  48557. },
  48558. /**
  48559. * Highmaps only. Zoom in or out of the map. See also {@link Point#zoomTo}.
  48560. * See {@link Chart#fromLatLonToPoint} for how to get the `centerX` and
  48561. * `centerY` parameters for a geographic location.
  48562. *
  48563. * @function Highcharts.Chart#mapZoom
  48564. *
  48565. * @param {number} [howMuch]
  48566. * How much to zoom the map. Values less than 1 zooms in. 0.5 zooms
  48567. * in to half the current view. 2 zooms to twice the current view. If
  48568. * omitted, the zoom is reset.
  48569. *
  48570. * @param {number} [centerX]
  48571. * The X axis position to center around if available space.
  48572. *
  48573. * @param {number} [centerY]
  48574. * The Y axis position to center around if available space.
  48575. *
  48576. * @param {number} [mouseX]
  48577. * Fix the zoom to this position if possible. This is used for
  48578. * example in mousewheel events, where the area under the mouse
  48579. * should be fixed as we zoom in.
  48580. *
  48581. * @param {number} [mouseY]
  48582. * Fix the zoom to this position if possible.
  48583. *
  48584. * @return {void}
  48585. */
  48586. mapZoom: function (howMuch, centerXArg, centerYArg, mouseX, mouseY, animation) {
  48587. var chart = this,
  48588. xAxis = chart.xAxis[0],
  48589. xRange = xAxis.max - xAxis.min,
  48590. centerX = pick(centerXArg,
  48591. xAxis.min + xRange / 2),
  48592. newXRange = xRange * howMuch,
  48593. yAxis = chart.yAxis[0],
  48594. yRange = yAxis.max - yAxis.min,
  48595. centerY = pick(centerYArg,
  48596. yAxis.min + yRange / 2),
  48597. newYRange = yRange * howMuch,
  48598. fixToX = mouseX ? ((mouseX - xAxis.pos) / xAxis.len) : 0.5,
  48599. fixToY = mouseY ? ((mouseY - yAxis.pos) / yAxis.len) : 0.5,
  48600. newXMin = centerX - newXRange * fixToX,
  48601. newYMin = centerY - newYRange * fixToY,
  48602. newExt = chart.fitToBox({
  48603. x: newXMin,
  48604. y: newYMin,
  48605. width: newXRange,
  48606. height: newYRange
  48607. }, {
  48608. x: xAxis.dataMin,
  48609. y: yAxis.dataMin,
  48610. width: xAxis.dataMax - xAxis.dataMin,
  48611. height: yAxis.dataMax - yAxis.dataMin
  48612. }),
  48613. zoomOut = (newExt.x <= xAxis.dataMin &&
  48614. newExt.width >=
  48615. xAxis.dataMax - xAxis.dataMin &&
  48616. newExt.y <= yAxis.dataMin &&
  48617. newExt.height >= yAxis.dataMax - yAxis.dataMin);
  48618. // When mousewheel zooming, fix the point under the mouse
  48619. if (mouseX && xAxis.mapAxis) {
  48620. xAxis.mapAxis.fixTo = [mouseX - xAxis.pos, centerXArg];
  48621. }
  48622. if (mouseY && yAxis.mapAxis) {
  48623. yAxis.mapAxis.fixTo = [mouseY - yAxis.pos, centerYArg];
  48624. }
  48625. // Zoom
  48626. if (typeof howMuch !== 'undefined' && !zoomOut) {
  48627. xAxis.setExtremes(newExt.x, newExt.x + newExt.width, false);
  48628. yAxis.setExtremes(newExt.y, newExt.y + newExt.height, false);
  48629. // Reset zoom
  48630. }
  48631. else {
  48632. xAxis.setExtremes(void 0, void 0, false);
  48633. yAxis.setExtremes(void 0, void 0, false);
  48634. }
  48635. // Prevent zooming until this one is finished animating
  48636. /*
  48637. chart.holdMapZoom = true;
  48638. setTimeout(function () {
  48639. chart.holdMapZoom = false;
  48640. }, 200);
  48641. */
  48642. /*
  48643. delay = animation ? animation.duration || 500 : 0;
  48644. if (delay) {
  48645. chart.isMapZooming = true;
  48646. setTimeout(function () {
  48647. chart.isMapZooming = false;
  48648. if (chart.mapZoomQueue) {
  48649. chart.mapZoom.apply(chart, chart.mapZoomQueue);
  48650. }
  48651. chart.mapZoomQueue = null;
  48652. }, delay);
  48653. }
  48654. */
  48655. chart.redraw(animation);
  48656. }
  48657. });
  48658. // Extend the Chart.render method to add zooming and panning
  48659. addEvent(Chart, 'beforeRender', function () {
  48660. // Render the plus and minus buttons. Doing this before the shapes makes
  48661. // getBBox much quicker, at least in Chrome.
  48662. this.mapNavigation = new MapNavigation(this);
  48663. this.mapNavigation.update();
  48664. });
  48665. H.MapNavigation = MapNavigation;
  48666. });
  48667. _registerModule(_modules, 'Maps/MapPointer.js', [_modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (Pointer, U) {
  48668. /* *
  48669. *
  48670. * (c) 2010-2021 Torstein Honsi
  48671. *
  48672. * License: www.highcharts.com/license
  48673. *
  48674. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48675. *
  48676. * */
  48677. var extend = U.extend,
  48678. pick = U.pick,
  48679. wrap = U.wrap;
  48680. /* eslint-disable no-invalid-this */
  48681. var totalWheelDelta = 0;
  48682. var totalWheelDeltaTimer;
  48683. // Extend the Pointer
  48684. extend(Pointer.prototype, {
  48685. // The event handler for the doubleclick event
  48686. onContainerDblClick: function (e) {
  48687. var chart = this.chart;
  48688. e = this.normalize(e);
  48689. if (chart.options.mapNavigation.enableDoubleClickZoomTo) {
  48690. if (chart.pointer.inClass(e.target, 'highcharts-tracker') &&
  48691. chart.hoverPoint) {
  48692. chart.hoverPoint.zoomTo();
  48693. }
  48694. }
  48695. else if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
  48696. chart.mapZoom(0.5, chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY);
  48697. }
  48698. },
  48699. // The event handler for the mouse scroll event
  48700. onContainerMouseWheel: function (e) {
  48701. var chart = this.chart;
  48702. e = this.normalize(e);
  48703. // Firefox uses e.deltaY or e.detail, WebKit and IE uses wheelDelta
  48704. var delta = e.deltaY || e.detail || -(e.wheelDelta / 120);
  48705. // Wheel zooming on trackpads have different behaviours in Firefox vs
  48706. // WebKit. In Firefox the delta increments in steps by 1, so it is not
  48707. // distinguishable from true mouse wheel. Therefore we use this timer
  48708. // to avoid trackpad zooming going too fast and out of control. In
  48709. // WebKit however, the delta is < 1, so we simply disable animation in
  48710. // the `chart.mapZoom` call below.
  48711. if (Math.abs(delta) >= 1) {
  48712. totalWheelDelta += Math.abs(delta);
  48713. if (totalWheelDeltaTimer) {
  48714. clearTimeout(totalWheelDeltaTimer);
  48715. }
  48716. totalWheelDeltaTimer = setTimeout(function () {
  48717. totalWheelDelta = 0;
  48718. }, 50);
  48719. }
  48720. if (totalWheelDelta < 10 && chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
  48721. chart.mapZoom(Math.pow(chart.options.mapNavigation.mouseWheelSensitivity, delta), chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY,
  48722. // Delta less than 1 indicates stepless/trackpad zooming, avoid
  48723. // animation delaying the zoom
  48724. Math.abs(delta) < 1 ? false : void 0);
  48725. }
  48726. }
  48727. });
  48728. // The pinchType is inferred from mapNavigation options.
  48729. wrap(Pointer.prototype, 'zoomOption', function (proceed) {
  48730. var mapNavigation = this.chart.options.mapNavigation;
  48731. // Pinch status
  48732. if (pick(mapNavigation.enableTouchZoom, mapNavigation.enabled)) {
  48733. this.chart.options.chart.pinchType = 'xy';
  48734. }
  48735. proceed.apply(this, [].slice.call(arguments, 1));
  48736. });
  48737. // Extend the pinchTranslate method to preserve fixed ratio when zooming
  48738. wrap(Pointer.prototype, 'pinchTranslate', function (proceed, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  48739. var xBigger;
  48740. proceed.call(this, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  48741. // Keep ratio
  48742. if (this.chart.options.chart.type === 'map' && this.hasZoom) {
  48743. xBigger = transform.scaleX > transform.scaleY;
  48744. this.pinchTranslateDirection(!xBigger, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, xBigger ? transform.scaleX : transform.scaleY);
  48745. }
  48746. });
  48747. });
  48748. _registerModule(_modules, 'Maps/MapSymbols.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGRenderer.js']], function (H, SVGRenderer) {
  48749. /* *
  48750. *
  48751. * (c) 2010-2021 Torstein Honsi
  48752. *
  48753. * License: www.highcharts.com/license
  48754. *
  48755. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48756. *
  48757. * */
  48758. var Renderer = H.Renderer,
  48759. VMLRenderer = H.VMLRenderer;
  48760. /* *
  48761. *
  48762. * Functions
  48763. *
  48764. * */
  48765. // eslint-disable-next-line valid-jsdoc
  48766. /**
  48767. * Create symbols for the zoom buttons
  48768. * @private
  48769. */
  48770. function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
  48771. return [
  48772. ['M', x + rTopLeft, y],
  48773. // top side
  48774. ['L', x + w - rTopRight, y],
  48775. // top right corner
  48776. ['C', x + w - rTopRight / 2, y, x + w, y + rTopRight / 2, x + w, y + rTopRight],
  48777. // right side
  48778. ['L', x + w, y + h - rBottomRight],
  48779. // bottom right corner
  48780. ['C', x + w, y + h - rBottomRight / 2, x + w - rBottomRight / 2, y + h, x + w - rBottomRight, y + h],
  48781. // bottom side
  48782. ['L', x + rBottomLeft, y + h],
  48783. // bottom left corner
  48784. ['C', x + rBottomLeft / 2, y + h, x, y + h - rBottomLeft / 2, x, y + h - rBottomLeft],
  48785. // left side
  48786. ['L', x, y + rTopLeft],
  48787. // top left corner
  48788. ['C', x, y + rTopLeft / 2, x + rTopLeft / 2, y, x + rTopLeft, y],
  48789. ['Z']
  48790. ];
  48791. }
  48792. SVGRenderer.prototype.symbols.topbutton = function (x, y, w, h, options) {
  48793. var r = (options && options.r) || 0;
  48794. return selectiveRoundedRect(x - 1, y - 1, w, h, r, r, 0, 0);
  48795. };
  48796. SVGRenderer.prototype.symbols.bottombutton = function (x, y, w, h, options) {
  48797. var r = (options && options.r) || 0;
  48798. return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, r, r);
  48799. };
  48800. // The symbol callbacks are generated on the SVGRenderer object in all browsers.
  48801. // Even VML browsers need this in order to generate shapes in export. Now share
  48802. // them with the VMLRenderer.
  48803. if (Renderer !== SVGRenderer) {
  48804. ['topbutton', 'bottombutton'].forEach(function (shape) {
  48805. Renderer.prototype.symbols[shape] = SVGRenderer.prototype.symbols[shape];
  48806. });
  48807. }
  48808. return SVGRenderer.prototype.symbols;
  48809. });
  48810. _registerModule(_modules, 'Core/Chart/MapChart.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Options.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (Chart, O, SVGRenderer, U) {
  48811. /* *
  48812. *
  48813. * (c) 2010-2021 Torstein Honsi
  48814. *
  48815. * License: www.highcharts.com/license
  48816. *
  48817. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48818. *
  48819. * */
  48820. var __extends = (this && this.__extends) || (function () {
  48821. var extendStatics = function (d,
  48822. b) {
  48823. extendStatics = Object.setPrototypeOf ||
  48824. ({ __proto__: [] } instanceof Array && function (d,
  48825. b) { d.__proto__ = b; }) ||
  48826. function (d,
  48827. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  48828. return extendStatics(d, b);
  48829. };
  48830. return function (d, b) {
  48831. extendStatics(d, b);
  48832. function __() { this.constructor = d; }
  48833. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  48834. };
  48835. })();
  48836. var getOptions = O.getOptions;
  48837. var merge = U.merge,
  48838. pick = U.pick;
  48839. /**
  48840. * Map-optimized chart. Use {@link Highcharts.Chart|Chart} for common charts.
  48841. *
  48842. * @requires modules/map
  48843. *
  48844. * @class
  48845. * @name Highcharts.MapChart
  48846. * @extends Highcharts.Chart
  48847. */
  48848. var MapChart = /** @class */ (function (_super) {
  48849. __extends(MapChart, _super);
  48850. function MapChart() {
  48851. return _super !== null && _super.apply(this, arguments) || this;
  48852. }
  48853. /**
  48854. * Initializes the chart. The constructor's arguments are passed on
  48855. * directly.
  48856. *
  48857. * @function Highcharts.MapChart#init
  48858. *
  48859. * @param {Highcharts.Options} userOptions
  48860. * Custom options.
  48861. *
  48862. * @param {Function} [callback]
  48863. * Function to run when the chart has loaded and and all external
  48864. * images are loaded.
  48865. *
  48866. * @return {void}
  48867. *
  48868. * @fires Highcharts.MapChart#event:init
  48869. * @fires Highcharts.MapChart#event:afterInit
  48870. */
  48871. MapChart.prototype.init = function (userOptions, callback) {
  48872. var hiddenAxis = {
  48873. endOnTick: false,
  48874. visible: false,
  48875. minPadding: 0,
  48876. maxPadding: 0,
  48877. startOnTick: false
  48878. },
  48879. seriesOptions = userOptions.series,
  48880. defaultCreditsOptions = getOptions().credits;
  48881. /* For visual testing
  48882. hiddenAxis.gridLineWidth = 1;
  48883. hiddenAxis.gridZIndex = 10;
  48884. hiddenAxis.tickPositions = undefined;
  48885. // */
  48886. // Don't merge the data
  48887. userOptions.series = void 0;
  48888. userOptions = merge({
  48889. chart: {
  48890. panning: {
  48891. enabled: true,
  48892. type: 'xy'
  48893. },
  48894. type: 'map'
  48895. },
  48896. credits: {
  48897. mapText: pick(defaultCreditsOptions.mapText, ' \u00a9 <a href="{geojson.copyrightUrl}">' +
  48898. '{geojson.copyrightShort}</a>'),
  48899. mapTextFull: pick(defaultCreditsOptions.mapTextFull, '{geojson.copyright}')
  48900. },
  48901. tooltip: {
  48902. followTouchMove: false
  48903. },
  48904. xAxis: hiddenAxis,
  48905. yAxis: merge(hiddenAxis, { reversed: true })
  48906. }, userOptions, // user's options
  48907. {
  48908. chart: {
  48909. inverted: false,
  48910. alignTicks: false
  48911. }
  48912. });
  48913. userOptions.series = seriesOptions;
  48914. _super.prototype.init.call(this, userOptions, callback);
  48915. };
  48916. return MapChart;
  48917. }(Chart));
  48918. /* eslint-disable valid-jsdoc */
  48919. (function (MapChart) {
  48920. /**
  48921. * Contains all loaded map data for Highmaps.
  48922. *
  48923. * @requires modules/map
  48924. *
  48925. * @name Highcharts.maps
  48926. * @type {Record<string,*>}
  48927. */
  48928. MapChart.maps = {};
  48929. /**
  48930. * The factory function for creating new map charts. Creates a new {@link
  48931. * Highcharts.MapChart|MapChart} object with different default options than
  48932. * the basic Chart.
  48933. *
  48934. * @requires modules/map
  48935. *
  48936. * @function Highcharts.mapChart
  48937. *
  48938. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  48939. * The DOM element to render to, or its id.
  48940. *
  48941. * @param {Highcharts.Options} options
  48942. * The chart options structure as described in the
  48943. * [options reference](https://api.highcharts.com/highstock).
  48944. *
  48945. * @param {Highcharts.ChartCallbackFunction} [callback]
  48946. * A function to execute when the chart object is finished loading and
  48947. * rendering. In most cases the chart is built in one thread, but in
  48948. * Internet Explorer version 8 or less the chart is sometimes initialized
  48949. * before the document is ready, and in these cases the chart object will
  48950. * not be finished synchronously. As a consequence, code that relies on the
  48951. * newly built Chart object should always run in the callback. Defining a
  48952. * [chart.events.load](https://api.highcharts.com/highstock/chart.events.load)
  48953. * handler is equivalent.
  48954. *
  48955. * @return {Highcharts.MapChart}
  48956. * The chart object.
  48957. */
  48958. function mapChart(a, b, c) {
  48959. return new MapChart(a, b, c);
  48960. }
  48961. MapChart.mapChart = mapChart;
  48962. /**
  48963. * Utility for reading SVG paths directly.
  48964. *
  48965. * @requires modules/map
  48966. *
  48967. * @function Highcharts.splitPath
  48968. *
  48969. * @param {string|Array<string|number>} path
  48970. *
  48971. * @return {Highcharts.SVGPathArray}
  48972. */
  48973. function splitPath(path) {
  48974. var arr;
  48975. if (typeof path === 'string') {
  48976. path = path
  48977. // Move letters apart
  48978. .replace(/([A-Za-z])/g, ' $1 ')
  48979. // Trim
  48980. .replace(/^\s*/, '').replace(/\s*$/, '');
  48981. // Split on spaces and commas. The semicolon is bogus, designed to
  48982. // circumvent string replacement in the pre-v7 assembler that built
  48983. // specific styled mode files.
  48984. var split = path.split(/[ ,;]+/);
  48985. arr = split.map(function (item) {
  48986. if (!/[A-za-z]/.test(item)) {
  48987. return parseFloat(item);
  48988. }
  48989. return item;
  48990. });
  48991. }
  48992. else {
  48993. arr = path;
  48994. }
  48995. return SVGRenderer.prototype.pathToSegments(arr);
  48996. }
  48997. MapChart.splitPath = splitPath;
  48998. })(MapChart || (MapChart = {}));
  48999. /* *
  49000. *
  49001. * Default Export
  49002. *
  49003. * */
  49004. return MapChart;
  49005. });
  49006. _registerModule(_modules, 'Series/Map/MapPoint.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, SeriesRegistry, U) {
  49007. /* *
  49008. *
  49009. * (c) 2010-2021 Torstein Honsi
  49010. *
  49011. * License: www.highcharts.com/license
  49012. *
  49013. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  49014. *
  49015. * */
  49016. var __extends = (this && this.__extends) || (function () {
  49017. var extendStatics = function (d,
  49018. b) {
  49019. extendStatics = Object.setPrototypeOf ||
  49020. ({ __proto__: [] } instanceof Array && function (d,
  49021. b) { d.__proto__ = b; }) ||
  49022. function (d,
  49023. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  49024. return extendStatics(d, b);
  49025. };
  49026. return function (d, b) {
  49027. extendStatics(d, b);
  49028. function __() { this.constructor = d; }
  49029. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  49030. };
  49031. })();
  49032. var colorMapPointMixin = ColorMapMixin.colorMapPointMixin;
  49033. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  49034. var extend = U.extend;
  49035. /* *
  49036. *
  49037. * Class
  49038. *
  49039. * */
  49040. var MapPoint = /** @class */ (function (_super) {
  49041. __extends(MapPoint, _super);
  49042. function MapPoint() {
  49043. /* *
  49044. *
  49045. * Properties
  49046. *
  49047. * */
  49048. var _this = _super !== null && _super.apply(this,
  49049. arguments) || this;
  49050. _this.options = void 0;
  49051. _this.path = void 0;
  49052. _this.series = void 0;
  49053. return _this;
  49054. /* eslint-enable valid-jsdoc */
  49055. }
  49056. /* *
  49057. *
  49058. * Functions
  49059. *
  49060. * */
  49061. /* eslint-disable valid-jsdoc */
  49062. /**
  49063. * Extend the Point object to split paths.
  49064. * @private
  49065. */
  49066. MapPoint.prototype.applyOptions = function (options, x) {
  49067. var series = this.series,
  49068. point = _super.prototype.applyOptions.call(this,
  49069. options,
  49070. x),
  49071. joinBy = series.joinBy,
  49072. mapPoint;
  49073. if (series.mapData && series.mapMap) {
  49074. var joinKey = joinBy[1];
  49075. var mapKey = _super.prototype.getNestedProperty.call(point,
  49076. joinKey);
  49077. mapPoint = typeof mapKey !== 'undefined' &&
  49078. series.mapMap[mapKey];
  49079. if (mapPoint) {
  49080. // This applies only to bubbles
  49081. if (series.xyFromShape) {
  49082. point.x = mapPoint._midX;
  49083. point.y = mapPoint._midY;
  49084. }
  49085. extend(point, mapPoint); // copy over properties
  49086. }
  49087. else {
  49088. point.value = point.value || null;
  49089. }
  49090. }
  49091. return point;
  49092. };
  49093. /**
  49094. * Stop the fade-out
  49095. * @private
  49096. */
  49097. MapPoint.prototype.onMouseOver = function (e) {
  49098. U.clearTimeout(this.colorInterval);
  49099. if (this.value !== null || this.series.options.nullInteraction) {
  49100. _super.prototype.onMouseOver.call(this, e);
  49101. }
  49102. else {
  49103. // #3401 Tooltip doesn't hide when hovering over null points
  49104. this.series.onMouseOut(e);
  49105. }
  49106. };
  49107. /**
  49108. * Highmaps only. Zoom in on the point using the global animation.
  49109. *
  49110. * @sample maps/members/point-zoomto/
  49111. * Zoom to points from butons
  49112. *
  49113. * @requires modules/map
  49114. *
  49115. * @function Highcharts.Point#zoomTo
  49116. */
  49117. MapPoint.prototype.zoomTo = function () {
  49118. var point = this,
  49119. series = point.series;
  49120. series.xAxis.setExtremes(point._minX, point._maxX, false);
  49121. series.yAxis.setExtremes(point._minY, point._maxY, false);
  49122. series.chart.redraw();
  49123. };
  49124. return MapPoint;
  49125. }(ScatterSeries.prototype.pointClass));
  49126. extend(MapPoint.prototype, {
  49127. dataLabelOnNull: colorMapPointMixin.dataLabelOnNull,
  49128. isValid: colorMapPointMixin.isValid,
  49129. moveToTopOnHover: colorMapPointMixin.moveToTopOnHover
  49130. });
  49131. /* *
  49132. *
  49133. * Default Export
  49134. *
  49135. * */
  49136. return MapPoint;
  49137. });
  49138. _registerModule(_modules, 'Series/Map/MapSeries.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Chart/MapChart.js'], _modules['Series/Map/MapPoint.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, H, LegendSymbolMixin, MapChart, MapPoint, palette, Series, SeriesRegistry, SVGRenderer, U) {
  49139. /* *
  49140. *
  49141. * (c) 2010-2021 Torstein Honsi
  49142. *
  49143. * License: www.highcharts.com/license
  49144. *
  49145. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  49146. *
  49147. * */
  49148. var __extends = (this && this.__extends) || (function () {
  49149. var extendStatics = function (d,
  49150. b) {
  49151. extendStatics = Object.setPrototypeOf ||
  49152. ({ __proto__: [] } instanceof Array && function (d,
  49153. b) { d.__proto__ = b; }) ||
  49154. function (d,
  49155. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  49156. return extendStatics(d, b);
  49157. };
  49158. return function (d, b) {
  49159. extendStatics(d, b);
  49160. function __() { this.constructor = d; }
  49161. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  49162. };
  49163. })();
  49164. var colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  49165. var noop = H.noop;
  49166. var maps = MapChart.maps,
  49167. splitPath = MapChart.splitPath;
  49168. var
  49169. // indirect dependency to keep product size low
  49170. _a = SeriesRegistry.seriesTypes,
  49171. ColumnSeries = _a.column,
  49172. ScatterSeries = _a.scatter;
  49173. var extend = U.extend,
  49174. fireEvent = U.fireEvent,
  49175. getNestedProperty = U.getNestedProperty,
  49176. isArray = U.isArray,
  49177. isNumber = U.isNumber,
  49178. merge = U.merge,
  49179. objectEach = U.objectEach,
  49180. pick = U.pick,
  49181. splat = U.splat;
  49182. /* *
  49183. *
  49184. * Class
  49185. *
  49186. * */
  49187. /**
  49188. * @private
  49189. * @class
  49190. * @name Highcharts.seriesTypes.map
  49191. *
  49192. * @augments Highcharts.Series
  49193. */
  49194. var MapSeries = /** @class */ (function (_super) {
  49195. __extends(MapSeries, _super);
  49196. function MapSeries() {
  49197. /* *
  49198. *
  49199. * Static Properties
  49200. *
  49201. * */
  49202. var _this = _super !== null && _super.apply(this,
  49203. arguments) || this;
  49204. /* *
  49205. *
  49206. * Properties
  49207. *
  49208. * */
  49209. _this.baseTrans = void 0;
  49210. _this.chart = void 0;
  49211. _this.data = void 0;
  49212. _this.group = void 0;
  49213. _this.joinBy = void 0;
  49214. _this.options = void 0;
  49215. _this.points = void 0;
  49216. _this.transformGroup = void 0;
  49217. return _this;
  49218. /* eslint-enable valid-jsdoc */
  49219. }
  49220. /* *
  49221. *
  49222. * Functions
  49223. *
  49224. * */
  49225. /* eslint-disable valid-jsdoc */
  49226. /**
  49227. * The initial animation for the map series. By default, animation is
  49228. * disabled. Animation of map shapes is not at all supported in VML
  49229. * browsers.
  49230. * @private
  49231. */
  49232. MapSeries.prototype.animate = function (init) {
  49233. var chart = this.chart,
  49234. animation = this.options.animation,
  49235. group = this.group,
  49236. xAxis = this.xAxis,
  49237. yAxis = this.yAxis,
  49238. left = xAxis.pos,
  49239. top = yAxis.pos;
  49240. if (chart.renderer.isSVG) {
  49241. if (animation === true) {
  49242. animation = {
  49243. duration: 1000
  49244. };
  49245. }
  49246. // Initialize the animation
  49247. if (init) {
  49248. // Scale down the group and place it in the center
  49249. group.attr({
  49250. translateX: left + xAxis.len / 2,
  49251. translateY: top + yAxis.len / 2,
  49252. scaleX: 0.001,
  49253. scaleY: 0.001
  49254. });
  49255. // Run the animation
  49256. }
  49257. else {
  49258. group.animate({
  49259. translateX: left,
  49260. translateY: top,
  49261. scaleX: 1,
  49262. scaleY: 1
  49263. }, animation);
  49264. }
  49265. }
  49266. };
  49267. /**
  49268. * Animate in the new series from the clicked point in the old series.
  49269. * Depends on the drilldown.js module
  49270. * @private
  49271. */
  49272. MapSeries.prototype.animateDrilldown = function (init) {
  49273. var toBox = this.chart.plotBox,
  49274. level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
  49275. fromBox = level.bBox,
  49276. animationOptions = this.chart.options.drilldown.animation,
  49277. scale;
  49278. if (!init) {
  49279. scale = Math.min(fromBox.width / toBox.width, fromBox.height / toBox.height);
  49280. level.shapeArgs = {
  49281. scaleX: scale,
  49282. scaleY: scale,
  49283. translateX: fromBox.x,
  49284. translateY: fromBox.y
  49285. };
  49286. this.points.forEach(function (point) {
  49287. if (point.graphic) {
  49288. point.graphic
  49289. .attr(level.shapeArgs)
  49290. .animate({
  49291. scaleX: 1,
  49292. scaleY: 1,
  49293. translateX: 0,
  49294. translateY: 0
  49295. }, animationOptions);
  49296. }
  49297. });
  49298. }
  49299. };
  49300. /**
  49301. * When drilling up, pull out the individual point graphics from the lower
  49302. * series and animate them into the origin point in the upper series.
  49303. * @private
  49304. */
  49305. MapSeries.prototype.animateDrillupFrom = function (level) {
  49306. ColumnSeries.prototype.animateDrillupFrom.call(this, level);
  49307. };
  49308. /**
  49309. * When drilling up, keep the upper series invisible until the lower series
  49310. * has moved into place.
  49311. * @private
  49312. */
  49313. MapSeries.prototype.animateDrillupTo = function (init) {
  49314. ColumnSeries.prototype.animateDrillupTo.call(this, init);
  49315. };
  49316. /**
  49317. * Allow a quick redraw by just translating the area group. Used for zooming
  49318. * and panning in capable browsers.
  49319. * @private
  49320. */
  49321. MapSeries.prototype.doFullTranslate = function () {
  49322. return (this.isDirtyData ||
  49323. this.chart.isResizing ||
  49324. this.chart.renderer.isVML ||
  49325. !this.baseTrans);
  49326. };
  49327. /**
  49328. * Draw the data labels. Special for maps is the time that the data labels
  49329. * are drawn (after points), and the clipping of the dataLabelsGroup.
  49330. * @private
  49331. */
  49332. MapSeries.prototype.drawMapDataLabels = function () {
  49333. Series.prototype.drawDataLabels.call(this);
  49334. if (this.dataLabelsGroup) {
  49335. this.dataLabelsGroup.clip(this.chart.clipRect);
  49336. }
  49337. };
  49338. /**
  49339. * Use the drawPoints method of column, that is able to handle simple
  49340. * shapeArgs. Extend it by assigning the tooltip position.
  49341. * @private
  49342. */
  49343. MapSeries.prototype.drawPoints = function () {
  49344. var series = this,
  49345. xAxis = series.xAxis,
  49346. yAxis = series.yAxis,
  49347. group = series.group,
  49348. chart = series.chart,
  49349. renderer = chart.renderer,
  49350. scaleX,
  49351. scaleY,
  49352. translateX,
  49353. translateY,
  49354. baseTrans = this.baseTrans,
  49355. transformGroup,
  49356. startTranslateX,
  49357. startTranslateY,
  49358. startScaleX,
  49359. startScaleY;
  49360. // Set a group that handles transform during zooming and panning in
  49361. // order to preserve clipping on series.group
  49362. if (!series.transformGroup) {
  49363. series.transformGroup = renderer.g()
  49364. .attr({
  49365. scaleX: 1,
  49366. scaleY: 1
  49367. })
  49368. .add(group);
  49369. series.transformGroup.survive = true;
  49370. }
  49371. // Draw the shapes again
  49372. if (series.doFullTranslate()) {
  49373. // Individual point actions.
  49374. if (chart.hasRendered && !chart.styledMode) {
  49375. series.points.forEach(function (point) {
  49376. // Restore state color on update/redraw (#3529)
  49377. if (point.shapeArgs) {
  49378. point.shapeArgs.fill = series.pointAttribs(point, point.state).fill;
  49379. }
  49380. });
  49381. }
  49382. // Draw them in transformGroup
  49383. series.group = series.transformGroup;
  49384. ColumnSeries.prototype.drawPoints.apply(series);
  49385. series.group = group; // Reset
  49386. // Add class names
  49387. series.points.forEach(function (point) {
  49388. if (point.graphic) {
  49389. var className = '';
  49390. if (point.name) {
  49391. className +=
  49392. 'highcharts-name-' +
  49393. point.name.replace(/ /g, '-').toLowerCase();
  49394. }
  49395. if (point.properties &&
  49396. point.properties['hc-key']) {
  49397. className +=
  49398. ' highcharts-key-' +
  49399. point.properties['hc-key'].toLowerCase();
  49400. }
  49401. if (className) {
  49402. point.graphic.addClass(className);
  49403. }
  49404. // In styled mode, apply point colors by CSS
  49405. if (chart.styledMode) {
  49406. point.graphic.css(series.pointAttribs(point, point.selected && 'select' || void 0));
  49407. }
  49408. }
  49409. });
  49410. // Set the base for later scale-zooming. The originX and originY
  49411. // properties are the axis values in the plot area's upper left
  49412. // corner.
  49413. this.baseTrans = {
  49414. originX: (xAxis.min -
  49415. xAxis.minPixelPadding / xAxis.transA),
  49416. originY: (yAxis.min -
  49417. yAxis.minPixelPadding / yAxis.transA +
  49418. (yAxis.reversed ? 0 : yAxis.len / yAxis.transA)),
  49419. transAX: xAxis.transA,
  49420. transAY: yAxis.transA
  49421. };
  49422. // Reset transformation in case we're doing a full translate
  49423. // (#3789)
  49424. this.transformGroup.animate({
  49425. translateX: 0,
  49426. translateY: 0,
  49427. scaleX: 1,
  49428. scaleY: 1
  49429. });
  49430. // Just update the scale and transform for better performance
  49431. }
  49432. else {
  49433. scaleX = xAxis.transA / baseTrans.transAX;
  49434. scaleY = yAxis.transA / baseTrans.transAY;
  49435. translateX = xAxis.toPixels(baseTrans.originX, true);
  49436. translateY = yAxis.toPixels(baseTrans.originY, true);
  49437. // Handle rounding errors in normal view (#3789)
  49438. if (scaleX > 0.99 &&
  49439. scaleX < 1.01 &&
  49440. scaleY > 0.99 &&
  49441. scaleY < 1.01) {
  49442. scaleX = 1;
  49443. scaleY = 1;
  49444. translateX = Math.round(translateX);
  49445. translateY = Math.round(translateY);
  49446. }
  49447. /* Animate or move to the new zoom level. In order to prevent
  49448. flickering as the different transform components are set out
  49449. of sync (#5991), we run a fake animator attribute and set
  49450. scale and translation synchronously in the same step.
  49451. A possible improvement to the API would be to handle this in
  49452. the renderer or animation engine itself, to ensure that when
  49453. we are animating multiple properties, we make sure that each
  49454. step for each property is performed in the same step. Also,
  49455. for symbols and for transform properties, it should induce a
  49456. single updateTransform and symbolAttr call. */
  49457. transformGroup = this.transformGroup;
  49458. if (chart.renderer.globalAnimation) {
  49459. startTranslateX = transformGroup.attr('translateX');
  49460. startTranslateY = transformGroup.attr('translateY');
  49461. startScaleX = transformGroup.attr('scaleX');
  49462. startScaleY = transformGroup.attr('scaleY');
  49463. transformGroup
  49464. .attr({ animator: 0 })
  49465. .animate({
  49466. animator: 1
  49467. }, {
  49468. step: function (now, fx) {
  49469. transformGroup.attr({
  49470. translateX: (startTranslateX +
  49471. (translateX - startTranslateX) * fx.pos),
  49472. translateY: (startTranslateY +
  49473. (translateY - startTranslateY) * fx.pos),
  49474. scaleX: (startScaleX +
  49475. (scaleX - startScaleX) *
  49476. fx.pos),
  49477. scaleY: (startScaleY +
  49478. (scaleY - startScaleY) * fx.pos)
  49479. });
  49480. }
  49481. });
  49482. // When dragging, animation is off.
  49483. }
  49484. else {
  49485. transformGroup.attr({
  49486. translateX: translateX,
  49487. translateY: translateY,
  49488. scaleX: scaleX,
  49489. scaleY: scaleY
  49490. });
  49491. }
  49492. }
  49493. /* Set the stroke-width directly on the group element so the
  49494. children inherit it. We need to use setAttribute directly,
  49495. because the stroke-widthSetter method expects a stroke color also
  49496. to be set. */
  49497. if (!chart.styledMode) {
  49498. group.element.setAttribute('stroke-width', (pick(series.options[(series.pointAttrToOptions &&
  49499. series.pointAttrToOptions['stroke-width']) || 'borderWidth'], 1 // Styled mode
  49500. ) / (scaleX || 1)));
  49501. }
  49502. this.drawMapDataLabels();
  49503. };
  49504. /**
  49505. * Get the bounding box of all paths in the map combined.
  49506. * @private
  49507. */
  49508. MapSeries.prototype.getBox = function (paths) {
  49509. var MAX_VALUE = Number.MAX_VALUE,
  49510. maxX = -MAX_VALUE,
  49511. minX = MAX_VALUE,
  49512. maxY = -MAX_VALUE,
  49513. minY = MAX_VALUE,
  49514. minRange = MAX_VALUE,
  49515. xAxis = this.xAxis,
  49516. yAxis = this.yAxis,
  49517. hasBox;
  49518. // Find the bounding box
  49519. (paths || []).forEach(function (point) {
  49520. if (point.path) {
  49521. if (typeof point.path === 'string') {
  49522. point.path = splitPath(point.path);
  49523. // Legacy one-dimensional array
  49524. }
  49525. else if (point.path[0] === 'M') {
  49526. point.path = SVGRenderer.prototype.pathToSegments(point.path);
  49527. }
  49528. var path = point.path || [],
  49529. pointMaxX_1 = -MAX_VALUE,
  49530. pointMinX_1 = MAX_VALUE,
  49531. pointMaxY_1 = -MAX_VALUE,
  49532. pointMinY_1 = MAX_VALUE,
  49533. properties = point.properties;
  49534. // The first time a map point is used, analyze its box
  49535. if (!point._foundBox) {
  49536. path.forEach(function (seg) {
  49537. var x = seg[seg.length - 2];
  49538. var y = seg[seg.length - 1];
  49539. if (typeof x === 'number' && typeof y === 'number') {
  49540. pointMinX_1 = Math.min(pointMinX_1, x);
  49541. pointMaxX_1 = Math.max(pointMaxX_1, x);
  49542. pointMinY_1 = Math.min(pointMinY_1, y);
  49543. pointMaxY_1 = Math.max(pointMaxY_1, y);
  49544. }
  49545. });
  49546. // Cache point bounding box for use to position data
  49547. // labels, bubbles etc
  49548. point._midX = (pointMinX_1 + (pointMaxX_1 - pointMinX_1) * pick(point.middleX, properties &&
  49549. properties['hc-middle-x'], 0.5));
  49550. point._midY = (pointMinY_1 + (pointMaxY_1 - pointMinY_1) * pick(point.middleY, properties &&
  49551. properties['hc-middle-y'], 0.5));
  49552. point._maxX = pointMaxX_1;
  49553. point._minX = pointMinX_1;
  49554. point._maxY = pointMaxY_1;
  49555. point._minY = pointMinY_1;
  49556. point.labelrank = pick(point.labelrank, (pointMaxX_1 - pointMinX_1) * (pointMaxY_1 - pointMinY_1));
  49557. point._foundBox = true;
  49558. }
  49559. maxX = Math.max(maxX, point._maxX);
  49560. minX = Math.min(minX, point._minX);
  49561. maxY = Math.max(maxY, point._maxY);
  49562. minY = Math.min(minY, point._minY);
  49563. minRange = Math.min(point._maxX - point._minX, point._maxY - point._minY, minRange);
  49564. hasBox = true;
  49565. }
  49566. });
  49567. // Set the box for the whole series
  49568. if (hasBox) {
  49569. this.minY = Math.min(minY, pick(this.minY, MAX_VALUE));
  49570. this.maxY = Math.max(maxY, pick(this.maxY, -MAX_VALUE));
  49571. this.minX = Math.min(minX, pick(this.minX, MAX_VALUE));
  49572. this.maxX = Math.max(maxX, pick(this.maxX, -MAX_VALUE));
  49573. // If no minRange option is set, set the default minimum zooming
  49574. // range to 5 times the size of the smallest element
  49575. if (xAxis && typeof xAxis.options.minRange === 'undefined') {
  49576. xAxis.minRange = Math.min(5 * minRange, (this.maxX - this.minX) / 5, xAxis.minRange || MAX_VALUE);
  49577. }
  49578. if (yAxis && typeof yAxis.options.minRange === 'undefined') {
  49579. yAxis.minRange = Math.min(5 * minRange, (this.maxY - this.minY) / 5, yAxis.minRange || MAX_VALUE);
  49580. }
  49581. }
  49582. };
  49583. MapSeries.prototype.getExtremes = function () {
  49584. // Get the actual value extremes for colors
  49585. var _a = Series.prototype.getExtremes
  49586. .call(this,
  49587. this.valueData),
  49588. dataMin = _a.dataMin,
  49589. dataMax = _a.dataMax;
  49590. // Recalculate box on updated data
  49591. if (this.chart.hasRendered && this.isDirtyData) {
  49592. this.getBox(this.options.data);
  49593. }
  49594. if (isNumber(dataMin)) {
  49595. this.valueMin = dataMin;
  49596. }
  49597. if (isNumber(dataMax)) {
  49598. this.valueMax = dataMax;
  49599. }
  49600. // Extremes for the mock Y axis
  49601. return { dataMin: this.minY, dataMax: this.maxY };
  49602. };
  49603. /**
  49604. * Define hasData function for non-cartesian series. Returns true if the
  49605. * series has points at all.
  49606. * @private
  49607. */
  49608. MapSeries.prototype.hasData = function () {
  49609. return !!this.processedXData.length; // != 0
  49610. };
  49611. /**
  49612. * Get presentational attributes. In the maps series this runs in both
  49613. * styled and non-styled mode, because colors hold data when a colorAxis is
  49614. * used.
  49615. * @private
  49616. */
  49617. MapSeries.prototype.pointAttribs = function (point, state) {
  49618. var attr = point.series.chart.styledMode ?
  49619. this.colorAttribs(point) :
  49620. ColumnSeries.prototype.pointAttribs.call(this,
  49621. point,
  49622. state);
  49623. // Set the stroke-width on the group element and let all point
  49624. // graphics inherit. That way we don't have to iterate over all
  49625. // points to update the stroke-width on zooming.
  49626. attr['stroke-width'] = pick(point.options[(this.pointAttrToOptions &&
  49627. this.pointAttrToOptions['stroke-width']) || 'borderWidth'], 'inherit');
  49628. return attr;
  49629. };
  49630. /**
  49631. * Override render to throw in an async call in IE8. Otherwise it chokes on
  49632. * the US counties demo.
  49633. * @private
  49634. */
  49635. MapSeries.prototype.render = function () {
  49636. var series = this,
  49637. render = Series.prototype.render;
  49638. // Give IE8 some time to breathe.
  49639. if (series.chart.renderer.isVML && series.data.length > 3000) {
  49640. setTimeout(function () {
  49641. render.call(series);
  49642. });
  49643. }
  49644. else {
  49645. render.call(series);
  49646. }
  49647. };
  49648. /**
  49649. * Extend setData to join in mapData. If the allAreas option is true, all
  49650. * areas from the mapData are used, and those that don't correspond to a
  49651. * data value are given null values.
  49652. * @private
  49653. */
  49654. MapSeries.prototype.setData = function (data, redraw, animation, updatePoints) {
  49655. var options = this.options,
  49656. chartOptions = this.chart.options.chart,
  49657. globalMapData = chartOptions && chartOptions.map,
  49658. mapData = options.mapData,
  49659. joinBy = this.joinBy,
  49660. pointArrayMap = options.keys || this.pointArrayMap,
  49661. dataUsed = [],
  49662. mapMap = {},
  49663. mapPoint,
  49664. mapTransforms = this.chart.mapTransforms,
  49665. props,
  49666. i;
  49667. // Collect mapData from chart options if not defined on series
  49668. if (!mapData && globalMapData) {
  49669. mapData = typeof globalMapData === 'string' ?
  49670. maps[globalMapData] :
  49671. globalMapData;
  49672. }
  49673. // Pick up numeric values, add index
  49674. // Convert Array point definitions to objects using pointArrayMap
  49675. if (data) {
  49676. data.forEach(function (val, i) {
  49677. var ix = 0;
  49678. if (isNumber(val)) {
  49679. data[i] = {
  49680. value: val
  49681. };
  49682. }
  49683. else if (isArray(val)) {
  49684. data[i] = {};
  49685. // Automatically copy first item to hc-key if there is
  49686. // an extra leading string
  49687. if (!options.keys &&
  49688. val.length > pointArrayMap.length &&
  49689. typeof val[0] === 'string') {
  49690. data[i]['hc-key'] = val[0];
  49691. ++ix;
  49692. }
  49693. // Run through pointArrayMap and what's left of the
  49694. // point data array in parallel, copying over the values
  49695. for (var j = 0; j < pointArrayMap.length; ++j, ++ix) {
  49696. if (pointArrayMap[j] &&
  49697. typeof val[ix] !== 'undefined') {
  49698. if (pointArrayMap[j].indexOf('.') > 0) {
  49699. MapPoint.prototype.setNestedProperty(data[i], val[ix], pointArrayMap[j]);
  49700. }
  49701. else {
  49702. data[i][pointArrayMap[j]] =
  49703. val[ix];
  49704. }
  49705. }
  49706. }
  49707. }
  49708. if (joinBy && joinBy[0] === '_i') {
  49709. data[i]._i = i;
  49710. }
  49711. });
  49712. }
  49713. this.getBox(data);
  49714. // Pick up transform definitions for chart
  49715. this.chart.mapTransforms = mapTransforms =
  49716. chartOptions.mapTransforms ||
  49717. mapData && mapData['hc-transform'] ||
  49718. mapTransforms;
  49719. // Cache cos/sin of transform rotation angle
  49720. if (mapTransforms) {
  49721. objectEach(mapTransforms, function (transform) {
  49722. if (transform.rotation) {
  49723. transform.cosAngle = Math.cos(transform.rotation);
  49724. transform.sinAngle = Math.sin(transform.rotation);
  49725. }
  49726. });
  49727. }
  49728. if (mapData) {
  49729. if (mapData.type === 'FeatureCollection') {
  49730. this.mapTitle = mapData.title;
  49731. mapData = H.geojson(mapData, this.type, this);
  49732. }
  49733. this.mapData = mapData;
  49734. this.mapMap = {};
  49735. for (i = 0; i < mapData.length; i++) {
  49736. mapPoint = mapData[i];
  49737. props = mapPoint.properties;
  49738. mapPoint._i = i;
  49739. // Copy the property over to root for faster access
  49740. if (joinBy[0] && props && props[joinBy[0]]) {
  49741. mapPoint[joinBy[0]] = props[joinBy[0]];
  49742. }
  49743. mapMap[mapPoint[joinBy[0]]] = mapPoint;
  49744. }
  49745. this.mapMap = mapMap;
  49746. // Registered the point codes that actually hold data
  49747. if (data && joinBy[1]) {
  49748. var joinKey_1 = joinBy[1];
  49749. data.forEach(function (pointOptions) {
  49750. var mapKey = getNestedProperty(joinKey_1,
  49751. pointOptions);
  49752. if (mapMap[mapKey]) {
  49753. dataUsed.push(mapMap[mapKey]);
  49754. }
  49755. });
  49756. }
  49757. if (options.allAreas) {
  49758. this.getBox(mapData);
  49759. data = data || [];
  49760. // Registered the point codes that actually hold data
  49761. if (joinBy[1]) {
  49762. var joinKey_2 = joinBy[1];
  49763. data.forEach(function (pointOptions) {
  49764. dataUsed.push(getNestedProperty(joinKey_2, pointOptions));
  49765. });
  49766. }
  49767. // Add those map points that don't correspond to data, which
  49768. // will be drawn as null points
  49769. dataUsed = ('|' + dataUsed.map(function (point) {
  49770. return point && point[joinBy[0]];
  49771. }).join('|') + '|'); // Faster than array.indexOf
  49772. mapData.forEach(function (mapPoint) {
  49773. if (!joinBy[0] ||
  49774. dataUsed.indexOf('|' + mapPoint[joinBy[0]] + '|') === -1) {
  49775. data.push(merge(mapPoint, { value: null }));
  49776. // #5050 - adding all areas causes the update
  49777. // optimization of setData to kick in, even though
  49778. // the point order has changed
  49779. updatePoints = false;
  49780. }
  49781. });
  49782. }
  49783. else {
  49784. this.getBox(dataUsed); // Issue #4784
  49785. }
  49786. }
  49787. Series.prototype.setData.call(this, data, redraw, animation, updatePoints);
  49788. };
  49789. /**
  49790. * Extend setOptions by picking up the joinBy option and applying it to a
  49791. * series property.
  49792. * @private
  49793. */
  49794. MapSeries.prototype.setOptions = function (itemOptions) {
  49795. var options = Series.prototype.setOptions.call(this,
  49796. itemOptions),
  49797. joinBy = options.joinBy,
  49798. joinByNull = joinBy === null;
  49799. if (joinByNull) {
  49800. joinBy = '_i';
  49801. }
  49802. joinBy = this.joinBy = splat(joinBy);
  49803. if (!joinBy[1]) {
  49804. joinBy[1] = joinBy[0];
  49805. }
  49806. return options;
  49807. };
  49808. /**
  49809. * Add the path option for data points. Find the max value for color
  49810. * calculation.
  49811. * @private
  49812. */
  49813. MapSeries.prototype.translate = function () {
  49814. var series = this,
  49815. xAxis = series.xAxis,
  49816. yAxis = series.yAxis,
  49817. doFullTranslate = series.doFullTranslate();
  49818. series.generatePoints();
  49819. series.data.forEach(function (point) {
  49820. // Record the middle point (loosely based on centroid),
  49821. // determined by the middleX and middleY options.
  49822. if (isNumber(point._midX) && isNumber(point._midY)) {
  49823. point.plotX = xAxis.toPixels(point._midX, true);
  49824. point.plotY = yAxis.toPixels(point._midY, true);
  49825. }
  49826. if (doFullTranslate) {
  49827. point.shapeType = 'path';
  49828. point.shapeArgs = {
  49829. d: series.translatePath(point.path)
  49830. };
  49831. }
  49832. });
  49833. fireEvent(series, 'afterTranslate');
  49834. };
  49835. /**
  49836. * Translate the path, so it automatically fits into the plot area box.
  49837. * @private
  49838. */
  49839. MapSeries.prototype.translatePath = function (path) {
  49840. var series = this,
  49841. xAxis = series.xAxis,
  49842. yAxis = series.yAxis,
  49843. xMin = xAxis.min,
  49844. xTransA = xAxis.transA,
  49845. xMinPixelPadding = xAxis.minPixelPadding,
  49846. yMin = yAxis.min,
  49847. yTransA = yAxis.transA,
  49848. yMinPixelPadding = yAxis.minPixelPadding,
  49849. ret = []; // Preserve the original
  49850. // Do the translation
  49851. if (path) {
  49852. path.forEach(function (seg) {
  49853. if (seg[0] === 'M') {
  49854. ret.push([
  49855. 'M',
  49856. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49857. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding
  49858. ]);
  49859. }
  49860. else if (seg[0] === 'L') {
  49861. ret.push([
  49862. 'L',
  49863. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49864. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding
  49865. ]);
  49866. }
  49867. else if (seg[0] === 'C') {
  49868. ret.push([
  49869. 'C',
  49870. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49871. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding,
  49872. (seg[3] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49873. (seg[4] - (yMin || 0)) * yTransA + yMinPixelPadding,
  49874. (seg[5] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49875. (seg[6] - (yMin || 0)) * yTransA + yMinPixelPadding
  49876. ]);
  49877. }
  49878. else if (seg[0] === 'Q') {
  49879. ret.push([
  49880. 'Q',
  49881. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49882. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding,
  49883. (seg[3] - (xMin || 0)) * xTransA + xMinPixelPadding,
  49884. (seg[4] - (yMin || 0)) * yTransA + yMinPixelPadding
  49885. ]);
  49886. }
  49887. else if (seg[0] === 'Z') {
  49888. ret.push(['Z']);
  49889. }
  49890. });
  49891. }
  49892. return ret;
  49893. };
  49894. /**
  49895. * The map series is used for basic choropleth maps, where each map area has
  49896. * a color based on its value.
  49897. *
  49898. * @sample maps/demo/all-maps/
  49899. * Choropleth map
  49900. *
  49901. * @extends plotOptions.scatter
  49902. * @excluding marker, cluster
  49903. * @product highmaps
  49904. * @optionparent plotOptions.map
  49905. */
  49906. MapSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  49907. animation: false,
  49908. dataLabels: {
  49909. crop: false,
  49910. formatter: function () {
  49911. return this.point.value;
  49912. },
  49913. inside: true,
  49914. overflow: false,
  49915. padding: 0,
  49916. verticalAlign: 'middle'
  49917. },
  49918. /**
  49919. * @ignore-option
  49920. *
  49921. * @private
  49922. */
  49923. marker: null,
  49924. /**
  49925. * The color to apply to null points.
  49926. *
  49927. * In styled mode, the null point fill is set in the
  49928. * `.highcharts-null-point` class.
  49929. *
  49930. * @sample maps/demo/all-areas-as-null/
  49931. * Null color
  49932. *
  49933. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  49934. *
  49935. * @private
  49936. */
  49937. nullColor: palette.neutralColor3,
  49938. /**
  49939. * Whether to allow pointer interaction like tooltips and mouse events
  49940. * on null points.
  49941. *
  49942. * @type {boolean}
  49943. * @since 4.2.7
  49944. * @apioption plotOptions.map.nullInteraction
  49945. *
  49946. * @private
  49947. */
  49948. stickyTracking: false,
  49949. tooltip: {
  49950. followPointer: true,
  49951. pointFormat: '{point.name}: {point.value}<br/>'
  49952. },
  49953. /**
  49954. * @ignore-option
  49955. *
  49956. * @private
  49957. */
  49958. turboThreshold: 0,
  49959. /**
  49960. * Whether all areas of the map defined in `mapData` should be rendered.
  49961. * If `true`, areas which don't correspond to a data point, are rendered
  49962. * as `null` points. If `false`, those areas are skipped.
  49963. *
  49964. * @sample maps/plotoptions/series-allareas-false/
  49965. * All areas set to false
  49966. *
  49967. * @type {boolean}
  49968. * @default true
  49969. * @product highmaps
  49970. * @apioption plotOptions.series.allAreas
  49971. *
  49972. * @private
  49973. */
  49974. allAreas: true,
  49975. /**
  49976. * The border color of the map areas.
  49977. *
  49978. * In styled mode, the border stroke is given in the `.highcharts-point`
  49979. * class.
  49980. *
  49981. * @sample {highmaps} maps/plotoptions/series-border/
  49982. * Borders demo
  49983. *
  49984. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  49985. * @default #cccccc
  49986. * @product highmaps
  49987. * @apioption plotOptions.series.borderColor
  49988. *
  49989. * @private
  49990. */
  49991. borderColor: palette.neutralColor20,
  49992. /**
  49993. * The border width of each map area.
  49994. *
  49995. * In styled mode, the border stroke width is given in the
  49996. * `.highcharts-point` class.
  49997. *
  49998. * @sample maps/plotoptions/series-border/
  49999. * Borders demo
  50000. *
  50001. * @type {number}
  50002. * @default 1
  50003. * @product highmaps
  50004. * @apioption plotOptions.series.borderWidth
  50005. *
  50006. * @private
  50007. */
  50008. borderWidth: 1,
  50009. /**
  50010. * @type {string}
  50011. * @default value
  50012. * @apioption plotOptions.map.colorKey
  50013. */
  50014. /**
  50015. * What property to join the `mapData` to the value data. For example,
  50016. * if joinBy is "code", the mapData items with a specific code is merged
  50017. * into the data with the same code. For maps loaded from GeoJSON, the
  50018. * keys may be held in each point's `properties` object.
  50019. *
  50020. * The joinBy option can also be an array of two values, where the first
  50021. * points to a key in the `mapData`, and the second points to another
  50022. * key in the `data`.
  50023. *
  50024. * When joinBy is `null`, the map items are joined by their position in
  50025. * the array, which performs much better in maps with many data points.
  50026. * This is the recommended option if you are printing more than a
  50027. * thousand data points and have a backend that can preprocess the data
  50028. * into a parallel array of the mapData.
  50029. *
  50030. * @sample maps/plotoptions/series-border/
  50031. * Joined by "code"
  50032. * @sample maps/demo/geojson/
  50033. * GeoJSON joined by an array
  50034. * @sample maps/series/joinby-null/
  50035. * Simple data joined by null
  50036. *
  50037. * @type {string|Array<string>}
  50038. * @default hc-key
  50039. * @product highmaps
  50040. * @apioption plotOptions.series.joinBy
  50041. *
  50042. * @private
  50043. */
  50044. joinBy: 'hc-key',
  50045. /**
  50046. * Define the z index of the series.
  50047. *
  50048. * @type {number}
  50049. * @product highmaps
  50050. * @apioption plotOptions.series.zIndex
  50051. */
  50052. /**
  50053. * @apioption plotOptions.series.states
  50054. *
  50055. * @private
  50056. */
  50057. states: {
  50058. /**
  50059. * @apioption plotOptions.series.states.hover
  50060. */
  50061. hover: {
  50062. /** @ignore-option */
  50063. halo: null,
  50064. /**
  50065. * The color of the shape in this state.
  50066. *
  50067. * @sample maps/plotoptions/series-states-hover/
  50068. * Hover options
  50069. *
  50070. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50071. * @product highmaps
  50072. * @apioption plotOptions.series.states.hover.color
  50073. */
  50074. /**
  50075. * The border color of the point in this state.
  50076. *
  50077. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50078. * @product highmaps
  50079. * @apioption plotOptions.series.states.hover.borderColor
  50080. */
  50081. /**
  50082. * The border width of the point in this state
  50083. *
  50084. * @type {number}
  50085. * @product highmaps
  50086. * @apioption plotOptions.series.states.hover.borderWidth
  50087. */
  50088. /**
  50089. * The relative brightness of the point when hovered, relative
  50090. * to the normal point color.
  50091. *
  50092. * @type {number}
  50093. * @product highmaps
  50094. * @default 0.2
  50095. * @apioption plotOptions.series.states.hover.brightness
  50096. */
  50097. brightness: 0.2
  50098. },
  50099. /**
  50100. * @apioption plotOptions.series.states.normal
  50101. */
  50102. normal: {
  50103. /**
  50104. * @productdesc {highmaps}
  50105. * The animation adds some latency in order to reduce the effect
  50106. * of flickering when hovering in and out of for example an
  50107. * uneven coastline.
  50108. *
  50109. * @sample {highmaps} maps/plotoptions/series-states-animation-false/
  50110. * No animation of fill color
  50111. *
  50112. * @apioption plotOptions.series.states.normal.animation
  50113. */
  50114. animation: true
  50115. },
  50116. /**
  50117. * @apioption plotOptions.series.states.select
  50118. */
  50119. select: {
  50120. /**
  50121. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50122. * @default ${palette.neutralColor20}
  50123. * @product highmaps
  50124. * @apioption plotOptions.series.states.select.color
  50125. */
  50126. color: palette.neutralColor20
  50127. },
  50128. inactive: {
  50129. opacity: 1
  50130. }
  50131. }
  50132. });
  50133. return MapSeries;
  50134. }(ScatterSeries));
  50135. extend(MapSeries.prototype, {
  50136. type: 'map',
  50137. axisTypes: colorMapSeriesMixin.axisTypes,
  50138. colorAttribs: colorMapSeriesMixin.colorAttribs,
  50139. colorKey: colorMapSeriesMixin.colorKey,
  50140. // When tooltip is not shared, this series (and derivatives) requires
  50141. // direct touch/hover. KD-tree does not apply.
  50142. directTouch: true,
  50143. // We need the points' bounding boxes in order to draw the data labels,
  50144. // so we skip it now and call it from drawPoints instead.
  50145. drawDataLabels: noop,
  50146. // No graph for the map series
  50147. drawGraph: noop,
  50148. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  50149. forceDL: true,
  50150. getExtremesFromAll: true,
  50151. getSymbol: colorMapSeriesMixin.getSymbol,
  50152. parallelArrays: colorMapSeriesMixin.parallelArrays,
  50153. pointArrayMap: colorMapSeriesMixin.pointArrayMap,
  50154. pointClass: MapPoint,
  50155. // X axis and Y axis must have same translation slope
  50156. preserveAspectRatio: true,
  50157. searchPoint: noop,
  50158. trackerGroups: colorMapSeriesMixin.trackerGroups,
  50159. // Get axis extremes from paths, not values
  50160. useMapGeometry: true
  50161. });
  50162. SeriesRegistry.registerSeriesType('map', MapSeries);
  50163. /* *
  50164. *
  50165. * Default Export
  50166. *
  50167. * */
  50168. /* *
  50169. *
  50170. * API Options
  50171. *
  50172. * */
  50173. /**
  50174. * A map data object containing a `path` definition and optionally additional
  50175. * properties to join in the data as per the `joinBy` option.
  50176. *
  50177. * @sample maps/demo/category-map/
  50178. * Map data and joinBy
  50179. *
  50180. * @type {Array<Highcharts.SeriesMapDataOptions>|*}
  50181. * @product highmaps
  50182. * @apioption series.mapData
  50183. */
  50184. /**
  50185. * A `map` series. If the [type](#series.map.type) option is not specified, it
  50186. * is inherited from [chart.type](#chart.type).
  50187. *
  50188. * @extends series,plotOptions.map
  50189. * @excluding dataParser, dataURL, marker
  50190. * @product highmaps
  50191. * @apioption series.map
  50192. */
  50193. /**
  50194. * An array of data points for the series. For the `map` series type, points can
  50195. * be given in the following ways:
  50196. *
  50197. * 1. An array of numerical values. In this case, the numerical values will be
  50198. * interpreted as `value` options. Example:
  50199. * ```js
  50200. * data: [0, 5, 3, 5]
  50201. * ```
  50202. *
  50203. * 2. An array of arrays with 2 values. In this case, the values correspond to
  50204. * `[hc-key, value]`. Example:
  50205. * ```js
  50206. * data: [
  50207. * ['us-ny', 0],
  50208. * ['us-mi', 5],
  50209. * ['us-tx', 3],
  50210. * ['us-ak', 5]
  50211. * ]
  50212. * ```
  50213. *
  50214. * 3. An array of objects with named values. The following snippet shows only a
  50215. * few settings, see the complete options set below. If the total number of
  50216. * data points exceeds the series'
  50217. * [turboThreshold](#series.map.turboThreshold),
  50218. * this option is not available.
  50219. * ```js
  50220. * data: [{
  50221. * value: 6,
  50222. * name: "Point2",
  50223. * color: "#00FF00"
  50224. * }, {
  50225. * value: 6,
  50226. * name: "Point1",
  50227. * color: "#FF00FF"
  50228. * }]
  50229. * ```
  50230. *
  50231. * @type {Array<number|Array<string,(number|null)>|null|*>}
  50232. * @product highmaps
  50233. * @apioption series.map.data
  50234. */
  50235. /**
  50236. * Individual color for the point. By default the color is either used
  50237. * to denote the value, or pulled from the global `colors` array.
  50238. *
  50239. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50240. * @product highmaps
  50241. * @apioption series.map.data.color
  50242. */
  50243. /**
  50244. * Individual data label for each point. The options are the same as
  50245. * the ones for [plotOptions.series.dataLabels](
  50246. * #plotOptions.series.dataLabels).
  50247. *
  50248. * @sample maps/series/data-datalabels/
  50249. * Disable data labels for individual areas
  50250. *
  50251. * @type {Highcharts.DataLabelsOptions}
  50252. * @product highmaps
  50253. * @apioption series.map.data.dataLabels
  50254. */
  50255. /**
  50256. * The `id` of a series in the [drilldown.series](#drilldown.series)
  50257. * array to use for a drilldown for this point.
  50258. *
  50259. * @sample maps/demo/map-drilldown/
  50260. * Basic drilldown
  50261. *
  50262. * @type {string}
  50263. * @product highmaps
  50264. * @apioption series.map.data.drilldown
  50265. */
  50266. /**
  50267. * An id for the point. This can be used after render time to get a
  50268. * pointer to the point object through `chart.get()`.
  50269. *
  50270. * @sample maps/series/data-id/
  50271. * Highlight a point by id
  50272. *
  50273. * @type {string}
  50274. * @product highmaps
  50275. * @apioption series.map.data.id
  50276. */
  50277. /**
  50278. * When data labels are laid out on a map, Highmaps runs a simplified
  50279. * algorithm to detect collision. When two labels collide, the one with
  50280. * the lowest rank is hidden. By default the rank is computed from the
  50281. * area.
  50282. *
  50283. * @type {number}
  50284. * @product highmaps
  50285. * @apioption series.map.data.labelrank
  50286. */
  50287. /**
  50288. * The relative mid point of an area, used to place the data label.
  50289. * Ranges from 0 to 1\. When `mapData` is used, middleX can be defined
  50290. * there.
  50291. *
  50292. * @type {number}
  50293. * @default 0.5
  50294. * @product highmaps
  50295. * @apioption series.map.data.middleX
  50296. */
  50297. /**
  50298. * The relative mid point of an area, used to place the data label.
  50299. * Ranges from 0 to 1\. When `mapData` is used, middleY can be defined
  50300. * there.
  50301. *
  50302. * @type {number}
  50303. * @default 0.5
  50304. * @product highmaps
  50305. * @apioption series.map.data.middleY
  50306. */
  50307. /**
  50308. * The name of the point as shown in the legend, tooltip, dataLabel
  50309. * etc.
  50310. *
  50311. * @sample maps/series/data-datalabels/
  50312. * Point names
  50313. *
  50314. * @type {string}
  50315. * @product highmaps
  50316. * @apioption series.map.data.name
  50317. */
  50318. /**
  50319. * For map and mapline series types, the SVG path for the shape. For
  50320. * compatibily with old IE, not all SVG path definitions are supported,
  50321. * but M, L and C operators are safe.
  50322. *
  50323. * To achieve a better separation between the structure and the data,
  50324. * it is recommended to use `mapData` to define that paths instead
  50325. * of defining them on the data points themselves.
  50326. *
  50327. * @sample maps/series/data-path/
  50328. * Paths defined in data
  50329. *
  50330. * @type {string}
  50331. * @product highmaps
  50332. * @apioption series.map.data.path
  50333. */
  50334. /**
  50335. * The numeric value of the data point.
  50336. *
  50337. * @type {number|null}
  50338. * @product highmaps
  50339. * @apioption series.map.data.value
  50340. */
  50341. /**
  50342. * Individual point events
  50343. *
  50344. * @extends plotOptions.series.point.events
  50345. * @product highmaps
  50346. * @apioption series.map.data.events
  50347. */
  50348. ''; // adds doclets above to the transpiled file
  50349. return MapSeries;
  50350. });
  50351. _registerModule(_modules, 'Series/MapLine/MapLineSeries.js', [_modules['Series/Map/MapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MapSeries, SeriesRegistry, U) {
  50352. /* *
  50353. *
  50354. * (c) 2010-2021 Torstein Honsi
  50355. *
  50356. * License: www.highcharts.com/license
  50357. *
  50358. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50359. *
  50360. * */
  50361. var __extends = (this && this.__extends) || (function () {
  50362. var extendStatics = function (d,
  50363. b) {
  50364. extendStatics = Object.setPrototypeOf ||
  50365. ({ __proto__: [] } instanceof Array && function (d,
  50366. b) { d.__proto__ = b; }) ||
  50367. function (d,
  50368. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  50369. return extendStatics(d, b);
  50370. };
  50371. return function (d, b) {
  50372. extendStatics(d, b);
  50373. function __() { this.constructor = d; }
  50374. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  50375. };
  50376. })();
  50377. var Series = SeriesRegistry.series;
  50378. var extend = U.extend,
  50379. merge = U.merge;
  50380. /* *
  50381. *
  50382. * Class
  50383. *
  50384. * */
  50385. /**
  50386. * @private
  50387. * @class
  50388. * @name Highcharts.seriesTypes.mapline
  50389. *
  50390. * @augments Highcharts.Series
  50391. */
  50392. var MapLineSeries = /** @class */ (function (_super) {
  50393. __extends(MapLineSeries, _super);
  50394. function MapLineSeries() {
  50395. /* *
  50396. *
  50397. * Static Properties
  50398. *
  50399. * */
  50400. var _this = _super !== null && _super.apply(this,
  50401. arguments) || this;
  50402. /* *
  50403. *
  50404. * Properties
  50405. *
  50406. * */
  50407. _this.data = void 0;
  50408. _this.options = void 0;
  50409. _this.points = void 0;
  50410. return _this;
  50411. /* eslint-enable valid-jsdoc */
  50412. }
  50413. /* *
  50414. *
  50415. * Functions
  50416. *
  50417. * */
  50418. /* eslint-disable valid-jsdoc */
  50419. /**
  50420. * Get presentational attributes
  50421. *
  50422. * @private
  50423. * @function Highcharts.seriesTypes.mapline#pointAttribs
  50424. * @param {Highcharts.Point} point
  50425. * @param {string} state
  50426. * @return {Highcharts.SVGAttributes}
  50427. */
  50428. MapLineSeries.prototype.pointAttribs = function (point, state) {
  50429. var attr = MapSeries.prototype.pointAttribs.call(this,
  50430. point,
  50431. state);
  50432. // The difference from a map series is that the stroke takes the
  50433. // point color
  50434. attr.fill = this.options.fillColor;
  50435. return attr;
  50436. };
  50437. /**
  50438. * A mapline series is a special case of the map series where the value
  50439. * colors are applied to the strokes rather than the fills. It can also be
  50440. * used for freeform drawing, like dividers, in the map.
  50441. *
  50442. * @sample maps/demo/mapline-mappoint/
  50443. * Mapline and map-point chart
  50444. *
  50445. * @extends plotOptions.map
  50446. * @product highmaps
  50447. * @optionparent plotOptions.mapline
  50448. */
  50449. MapLineSeries.defaultOptions = merge(MapSeries.defaultOptions, {
  50450. /**
  50451. * The width of the map line.
  50452. */
  50453. lineWidth: 1,
  50454. /**
  50455. * Fill color for the map line shapes
  50456. *
  50457. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50458. */
  50459. fillColor: 'none'
  50460. });
  50461. return MapLineSeries;
  50462. }(MapSeries));
  50463. extend(MapLineSeries.prototype, {
  50464. type: 'mapline',
  50465. colorProp: 'stroke',
  50466. drawLegendSymbol: Series.prototype.drawLegendSymbol,
  50467. pointAttrToOptions: {
  50468. 'stroke': 'color',
  50469. 'stroke-width': 'lineWidth'
  50470. }
  50471. });
  50472. SeriesRegistry.registerSeriesType('mapline', MapLineSeries);
  50473. /* *
  50474. *
  50475. * Default Export
  50476. *
  50477. * */
  50478. /* *
  50479. *
  50480. * API Options
  50481. *
  50482. * */
  50483. /**
  50484. * A `mapline` series. If the [type](#series.mapline.type) option is
  50485. * not specified, it is inherited from [chart.type](#chart.type).
  50486. *
  50487. * @extends series,plotOptions.mapline
  50488. * @excluding dataParser, dataURL, marker
  50489. * @product highmaps
  50490. * @apioption series.mapline
  50491. */
  50492. /**
  50493. * An array of data points for the series. For the `mapline` series type,
  50494. * points can be given in the following ways:
  50495. *
  50496. * 1. An array of numerical values. In this case, the numerical values
  50497. * will be interpreted as `value` options. Example:
  50498. *
  50499. * ```js
  50500. * data: [0, 5, 3, 5]
  50501. * ```
  50502. *
  50503. * 2. An array of arrays with 2 values. In this case, the values correspond
  50504. * to `[hc-key, value]`. Example:
  50505. *
  50506. * ```js
  50507. * data: [
  50508. * ['us-ny', 0],
  50509. * ['us-mi', 5],
  50510. * ['us-tx', 3],
  50511. * ['us-ak', 5]
  50512. * ]
  50513. * ```
  50514. *
  50515. * 3. An array of objects with named values. The following snippet shows only a
  50516. * few settings, see the complete options set below. If the total number of data
  50517. * points exceeds the series' [turboThreshold](#series.map.turboThreshold),
  50518. * this option is not available.
  50519. *
  50520. * ```js
  50521. * data: [{
  50522. * value: 6,
  50523. * name: "Point2",
  50524. * color: "#00FF00"
  50525. * }, {
  50526. * value: 6,
  50527. * name: "Point1",
  50528. * color: "#FF00FF"
  50529. * }]
  50530. * ```
  50531. *
  50532. * @type {Array<number|Array<string,(number|null)>|null|*>}
  50533. * @product highmaps
  50534. * @apioption series.mapline.data
  50535. */
  50536. ''; // adds doclets above to transpiled file
  50537. return MapLineSeries;
  50538. });
  50539. _registerModule(_modules, 'Series/MapPoint/MapPointPoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  50540. /* *
  50541. *
  50542. * (c) 2010-2021 Torstein Honsi
  50543. *
  50544. * License: www.highcharts.com/license
  50545. *
  50546. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50547. *
  50548. * */
  50549. var __extends = (this && this.__extends) || (function () {
  50550. var extendStatics = function (d,
  50551. b) {
  50552. extendStatics = Object.setPrototypeOf ||
  50553. ({ __proto__: [] } instanceof Array && function (d,
  50554. b) { d.__proto__ = b; }) ||
  50555. function (d,
  50556. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  50557. return extendStatics(d, b);
  50558. };
  50559. return function (d, b) {
  50560. extendStatics(d, b);
  50561. function __() { this.constructor = d; }
  50562. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  50563. };
  50564. })();
  50565. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  50566. var merge = U.merge;
  50567. /* *
  50568. *
  50569. * Class
  50570. *
  50571. * */
  50572. var MapPointPoint = /** @class */ (function (_super) {
  50573. __extends(MapPointPoint, _super);
  50574. function MapPointPoint() {
  50575. /* *
  50576. *
  50577. * Properties
  50578. *
  50579. * */
  50580. var _this = _super !== null && _super.apply(this,
  50581. arguments) || this;
  50582. _this.options = void 0;
  50583. _this.series = void 0;
  50584. return _this;
  50585. /* eslint-enable valid-jsdoc */
  50586. }
  50587. /* *
  50588. *
  50589. * Functions
  50590. *
  50591. * */
  50592. /* eslint-disable valid-jsdoc */
  50593. MapPointPoint.prototype.applyOptions = function (options, x) {
  50594. var mergedOptions = (typeof options.lat !== 'undefined' &&
  50595. typeof options.lon !== 'undefined' ?
  50596. merge(options,
  50597. this.series.chart.fromLatLonToPoint(options)) :
  50598. options);
  50599. return _super.prototype.applyOptions.call(this, mergedOptions, x);
  50600. };
  50601. return MapPointPoint;
  50602. }(ScatterSeries.prototype.pointClass));
  50603. /* *
  50604. *
  50605. * Default Export
  50606. *
  50607. * */
  50608. return MapPointPoint;
  50609. });
  50610. _registerModule(_modules, 'Series/MapPoint/MapPointSeries.js', [_modules['Series/MapPoint/MapPointPoint.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MapPointPoint, palette, SeriesRegistry, U) {
  50611. /* *
  50612. *
  50613. * (c) 2010-2021 Torstein Honsi
  50614. *
  50615. * License: www.highcharts.com/license
  50616. *
  50617. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50618. *
  50619. * */
  50620. var __extends = (this && this.__extends) || (function () {
  50621. var extendStatics = function (d,
  50622. b) {
  50623. extendStatics = Object.setPrototypeOf ||
  50624. ({ __proto__: [] } instanceof Array && function (d,
  50625. b) { d.__proto__ = b; }) ||
  50626. function (d,
  50627. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  50628. return extendStatics(d, b);
  50629. };
  50630. return function (d, b) {
  50631. extendStatics(d, b);
  50632. function __() { this.constructor = d; }
  50633. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  50634. };
  50635. })();
  50636. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  50637. var extend = U.extend,
  50638. merge = U.merge;
  50639. /* *
  50640. *
  50641. * Class
  50642. *
  50643. * */
  50644. /**
  50645. * @private
  50646. * @class
  50647. * @name Highcharts.seriesTypes.mappoint
  50648. *
  50649. * @augments Highcharts.Series
  50650. */
  50651. var MapPointSeries = /** @class */ (function (_super) {
  50652. __extends(MapPointSeries, _super);
  50653. function MapPointSeries() {
  50654. /* *
  50655. *
  50656. * Static Properties
  50657. *
  50658. * */
  50659. var _this = _super !== null && _super.apply(this,
  50660. arguments) || this;
  50661. /* *
  50662. *
  50663. * Properties
  50664. *
  50665. * */
  50666. _this.data = void 0;
  50667. _this.options = void 0;
  50668. _this.points = void 0;
  50669. return _this;
  50670. /* eslint-enable valid-jsdoc */
  50671. }
  50672. /* *
  50673. *
  50674. * Functions
  50675. *
  50676. * */
  50677. /* eslint-disable valid-jsdoc */
  50678. MapPointSeries.prototype.drawDataLabels = function () {
  50679. _super.prototype.drawDataLabels.call(this);
  50680. if (this.dataLabelsGroup) {
  50681. this.dataLabelsGroup.clip(this.chart.clipRect);
  50682. }
  50683. };
  50684. /**
  50685. * A mappoint series is a special form of scatter series where the points
  50686. * can be laid out in map coordinates on top of a map.
  50687. *
  50688. * @sample maps/demo/mapline-mappoint/
  50689. * Map-line and map-point series.
  50690. *
  50691. * @extends plotOptions.scatter
  50692. * @product highmaps
  50693. * @optionparent plotOptions.mappoint
  50694. */
  50695. MapPointSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  50696. dataLabels: {
  50697. crop: false,
  50698. defer: false,
  50699. enabled: true,
  50700. formatter: function () {
  50701. return this.point.name;
  50702. },
  50703. overflow: false,
  50704. style: {
  50705. /** @internal */
  50706. color: palette.neutralColor100
  50707. }
  50708. }
  50709. });
  50710. return MapPointSeries;
  50711. }(ScatterSeries));
  50712. extend(MapPointSeries.prototype, {
  50713. type: 'mappoint',
  50714. forceDL: true,
  50715. pointClass: MapPointPoint
  50716. });
  50717. SeriesRegistry.registerSeriesType('mappoint', MapPointSeries);
  50718. /* *
  50719. *
  50720. * Default Export
  50721. *
  50722. * */
  50723. /* *
  50724. *
  50725. * API Options
  50726. *
  50727. * */
  50728. /**
  50729. * A `mappoint` series. If the [type](#series.mappoint.type) option
  50730. * is not specified, it is inherited from [chart.type](#chart.type).
  50731. *
  50732. *
  50733. * @extends series,plotOptions.mappoint
  50734. * @excluding dataParser, dataURL
  50735. * @product highmaps
  50736. * @apioption series.mappoint
  50737. */
  50738. /**
  50739. * An array of data points for the series. For the `mappoint` series
  50740. * type, points can be given in the following ways:
  50741. *
  50742. * 1. An array of numerical values. In this case, the numerical values will be
  50743. * interpreted as `y` options. The `x` values will be automatically
  50744. * calculated, either starting at 0 and incremented by 1, or from
  50745. * `pointStart` and `pointInterval` given in the series options. If the axis
  50746. * has categories, these will be used. Example:
  50747. * ```js
  50748. * data: [0, 5, 3, 5]
  50749. * ```
  50750. *
  50751. * 2. An array of arrays with 2 values. In this case, the values correspond to
  50752. * `x,y`. If the first value is a string, it is applied as the name of the
  50753. * point, and the `x` value is inferred.
  50754. * ```js
  50755. * data: [
  50756. * [0, 1],
  50757. * [1, 8],
  50758. * [2, 7]
  50759. * ]
  50760. * ```
  50761. *
  50762. * 3. An array of objects with named values. The following snippet shows only a
  50763. * few settings, see the complete options set below. If the total number of
  50764. * data points exceeds the series'
  50765. * [turboThreshold](#series.mappoint.turboThreshold),
  50766. * this option is not available.
  50767. * ```js
  50768. * data: [{
  50769. * x: 1,
  50770. * y: 7,
  50771. * name: "Point2",
  50772. * color: "#00FF00"
  50773. * }, {
  50774. * x: 1,
  50775. * y: 4,
  50776. * name: "Point1",
  50777. * color: "#FF00FF"
  50778. * }]
  50779. * ```
  50780. *
  50781. * @type {Array<number|Array<number,(number|null)>|null|*>}
  50782. * @extends series.map.data
  50783. * @excluding labelrank, middleX, middleY, path, value
  50784. * @product highmaps
  50785. * @apioption series.mappoint.data
  50786. */
  50787. /**
  50788. * The latitude of the point. Must be combined with the `lon` option
  50789. * to work. Overrides `x` and `y` values.
  50790. *
  50791. * @sample {highmaps} maps/demo/mappoint-latlon/
  50792. * Point position by lat/lon
  50793. *
  50794. * @type {number}
  50795. * @since 1.1.0
  50796. * @product highmaps
  50797. * @apioption series.mappoint.data.lat
  50798. */
  50799. /**
  50800. * The longitude of the point. Must be combined with the `lon` option
  50801. * to work. Overrides `x` and `y` values.
  50802. *
  50803. * @sample {highmaps} maps/demo/mappoint-latlon/
  50804. * Point position by lat/lon
  50805. *
  50806. * @type {number}
  50807. * @since 1.1.0
  50808. * @product highmaps
  50809. * @apioption series.mappoint.data.lon
  50810. */
  50811. /**
  50812. * The x coordinate of the point in terms of the map path coordinates.
  50813. *
  50814. * @sample {highmaps} maps/demo/mapline-mappoint/
  50815. * Map point demo
  50816. *
  50817. * @type {number}
  50818. * @product highmaps
  50819. * @apioption series.mappoint.data.x
  50820. */
  50821. /**
  50822. * The x coordinate of the point in terms of the map path coordinates.
  50823. *
  50824. * @sample {highmaps} maps/demo/mapline-mappoint/
  50825. * Map point demo
  50826. *
  50827. * @type {number|null}
  50828. * @product highmaps
  50829. * @apioption series.mappoint.data.y
  50830. */
  50831. ''; // adds doclets above to transpiled file
  50832. return MapPointSeries;
  50833. });
  50834. _registerModule(_modules, 'Series/Bubble/BubblePoint.js', [_modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Point, SeriesRegistry, U) {
  50835. /* *
  50836. *
  50837. * (c) 2010-2021 Torstein Honsi
  50838. *
  50839. * License: www.highcharts.com/license
  50840. *
  50841. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50842. *
  50843. * */
  50844. var __extends = (this && this.__extends) || (function () {
  50845. var extendStatics = function (d,
  50846. b) {
  50847. extendStatics = Object.setPrototypeOf ||
  50848. ({ __proto__: [] } instanceof Array && function (d,
  50849. b) { d.__proto__ = b; }) ||
  50850. function (d,
  50851. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  50852. return extendStatics(d, b);
  50853. };
  50854. return function (d, b) {
  50855. extendStatics(d, b);
  50856. function __() { this.constructor = d; }
  50857. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  50858. };
  50859. })();
  50860. var ScatterPoint = SeriesRegistry.seriesTypes.scatter.prototype.pointClass;
  50861. var extend = U.extend;
  50862. /* *
  50863. *
  50864. * Class
  50865. *
  50866. * */
  50867. var BubblePoint = /** @class */ (function (_super) {
  50868. __extends(BubblePoint, _super);
  50869. function BubblePoint() {
  50870. /* *
  50871. *
  50872. * Properties
  50873. *
  50874. * */
  50875. var _this = _super !== null && _super.apply(this,
  50876. arguments) || this;
  50877. _this.options = void 0;
  50878. _this.series = void 0;
  50879. return _this;
  50880. /* eslint-enable valid-jsdoc */
  50881. }
  50882. /* *
  50883. *
  50884. * Functions
  50885. *
  50886. * */
  50887. /* eslint-disable valid-jsdoc */
  50888. /**
  50889. * @private
  50890. */
  50891. BubblePoint.prototype.haloPath = function (size) {
  50892. return Point.prototype.haloPath.call(this,
  50893. // #6067
  50894. size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size);
  50895. };
  50896. return BubblePoint;
  50897. }(ScatterPoint));
  50898. extend(BubblePoint.prototype, {
  50899. ttBelow: false
  50900. });
  50901. /* *
  50902. *
  50903. * Default Export
  50904. *
  50905. * */
  50906. return BubblePoint;
  50907. });
  50908. _registerModule(_modules, 'Series/Bubble/BubbleLegend.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Chart, Color, F, H, Legend, O, palette, Series, U) {
  50909. /* *
  50910. *
  50911. * (c) 2010-2021 Highsoft AS
  50912. *
  50913. * Author: Paweł Potaczek
  50914. *
  50915. * License: www.highcharts.com/license
  50916. *
  50917. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50918. *
  50919. * */
  50920. var color = Color.parse;
  50921. var noop = H.noop;
  50922. var setOptions = O.setOptions;
  50923. var addEvent = U.addEvent,
  50924. arrayMax = U.arrayMax,
  50925. arrayMin = U.arrayMin,
  50926. isNumber = U.isNumber,
  50927. merge = U.merge,
  50928. objectEach = U.objectEach,
  50929. pick = U.pick,
  50930. stableSort = U.stableSort,
  50931. wrap = U.wrap;
  50932. /**
  50933. * @interface Highcharts.BubbleLegendFormatterContextObject
  50934. */ /**
  50935. * The center y position of the range.
  50936. * @name Highcharts.BubbleLegendFormatterContextObject#center
  50937. * @type {number}
  50938. */ /**
  50939. * The radius of the bubble range.
  50940. * @name Highcharts.BubbleLegendFormatterContextObject#radius
  50941. * @type {number}
  50942. */ /**
  50943. * The bubble value.
  50944. * @name Highcharts.BubbleLegendFormatterContextObject#value
  50945. * @type {number}
  50946. */
  50947. ''; // detach doclets above
  50948. setOptions({
  50949. legend: {
  50950. /**
  50951. * The bubble legend is an additional element in legend which
  50952. * presents the scale of the bubble series. Individual bubble ranges
  50953. * can be defined by user or calculated from series. In the case of
  50954. * automatically calculated ranges, a 1px margin of error is
  50955. * permitted.
  50956. *
  50957. * @since 7.0.0
  50958. * @product highcharts highstock highmaps
  50959. * @requires highcharts-more
  50960. * @optionparent legend.bubbleLegend
  50961. */
  50962. bubbleLegend: {
  50963. /**
  50964. * The color of the ranges borders, can be also defined for an
  50965. * individual range.
  50966. *
  50967. * @sample highcharts/bubble-legend/similartoseries/
  50968. * Similar look to the bubble series
  50969. * @sample highcharts/bubble-legend/bordercolor/
  50970. * Individual bubble border color
  50971. *
  50972. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  50973. */
  50974. borderColor: void 0,
  50975. /**
  50976. * The width of the ranges borders in pixels, can be also
  50977. * defined for an individual range.
  50978. */
  50979. borderWidth: 2,
  50980. /**
  50981. * An additional class name to apply to the bubble legend'
  50982. * circle graphical elements. This option does not replace
  50983. * default class names of the graphical element.
  50984. *
  50985. * @sample {highcharts} highcharts/css/bubble-legend/
  50986. * Styling by CSS
  50987. *
  50988. * @type {string}
  50989. */
  50990. className: void 0,
  50991. /**
  50992. * The main color of the bubble legend. Applies to ranges, if
  50993. * individual color is not defined.
  50994. *
  50995. * @sample highcharts/bubble-legend/similartoseries/
  50996. * Similar look to the bubble series
  50997. * @sample highcharts/bubble-legend/color/
  50998. * Individual bubble color
  50999. *
  51000. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51001. */
  51002. color: void 0,
  51003. /**
  51004. * An additional class name to apply to the bubble legend's
  51005. * connector graphical elements. This option does not replace
  51006. * default class names of the graphical element.
  51007. *
  51008. * @sample {highcharts} highcharts/css/bubble-legend/
  51009. * Styling by CSS
  51010. *
  51011. * @type {string}
  51012. */
  51013. connectorClassName: void 0,
  51014. /**
  51015. * The color of the connector, can be also defined
  51016. * for an individual range.
  51017. *
  51018. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51019. */
  51020. connectorColor: void 0,
  51021. /**
  51022. * The length of the connectors in pixels. If labels are
  51023. * centered, the distance is reduced to 0.
  51024. *
  51025. * @sample highcharts/bubble-legend/connectorandlabels/
  51026. * Increased connector length
  51027. */
  51028. connectorDistance: 60,
  51029. /**
  51030. * The width of the connectors in pixels.
  51031. *
  51032. * @sample highcharts/bubble-legend/connectorandlabels/
  51033. * Increased connector width
  51034. */
  51035. connectorWidth: 1,
  51036. /**
  51037. * Enable or disable the bubble legend.
  51038. */
  51039. enabled: false,
  51040. /**
  51041. * Options for the bubble legend labels.
  51042. */
  51043. labels: {
  51044. /**
  51045. * An additional class name to apply to the bubble legend
  51046. * label graphical elements. This option does not replace
  51047. * default class names of the graphical element.
  51048. *
  51049. * @sample {highcharts} highcharts/css/bubble-legend/
  51050. * Styling by CSS
  51051. *
  51052. * @type {string}
  51053. */
  51054. className: void 0,
  51055. /**
  51056. * Whether to allow data labels to overlap.
  51057. */
  51058. allowOverlap: false,
  51059. /**
  51060. * A format string for the bubble legend labels. Available
  51061. * variables are the same as for `formatter`.
  51062. *
  51063. * @sample highcharts/bubble-legend/format/
  51064. * Add a unit
  51065. *
  51066. * @type {string}
  51067. */
  51068. format: '',
  51069. /**
  51070. * Available `this` properties are:
  51071. *
  51072. * - `this.value`: The bubble value.
  51073. *
  51074. * - `this.radius`: The radius of the bubble range.
  51075. *
  51076. * - `this.center`: The center y position of the range.
  51077. *
  51078. * @type {Highcharts.FormatterCallbackFunction<Highcharts.BubbleLegendFormatterContextObject>}
  51079. */
  51080. formatter: void 0,
  51081. /**
  51082. * The alignment of the labels compared to the bubble
  51083. * legend. Can be one of `left`, `center` or `right`.
  51084. *
  51085. * @sample highcharts/bubble-legend/connectorandlabels/
  51086. * Labels on left
  51087. *
  51088. * @type {Highcharts.AlignValue}
  51089. */
  51090. align: 'right',
  51091. /**
  51092. * CSS styles for the labels.
  51093. *
  51094. * @type {Highcharts.CSSObject}
  51095. */
  51096. style: {
  51097. /** @ignore-option */
  51098. fontSize: '10px',
  51099. /** @ignore-option */
  51100. color: palette.neutralColor100
  51101. },
  51102. /**
  51103. * The x position offset of the label relative to the
  51104. * connector.
  51105. */
  51106. x: 0,
  51107. /**
  51108. * The y position offset of the label relative to the
  51109. * connector.
  51110. */
  51111. y: 0
  51112. },
  51113. /**
  51114. * Miximum bubble legend range size. If values for ranges are
  51115. * not specified, the `minSize` and the `maxSize` are calculated
  51116. * from bubble series.
  51117. */
  51118. maxSize: 60,
  51119. /**
  51120. * Minimum bubble legend range size. If values for ranges are
  51121. * not specified, the `minSize` and the `maxSize` are calculated
  51122. * from bubble series.
  51123. */
  51124. minSize: 10,
  51125. /**
  51126. * The position of the bubble legend in the legend.
  51127. * @sample highcharts/bubble-legend/connectorandlabels/
  51128. * Bubble legend as last item in legend
  51129. */
  51130. legendIndex: 0,
  51131. /**
  51132. * Options for specific range. One range consists of bubble,
  51133. * label and connector.
  51134. *
  51135. * @sample highcharts/bubble-legend/ranges/
  51136. * Manually defined ranges
  51137. * @sample highcharts/bubble-legend/autoranges/
  51138. * Auto calculated ranges
  51139. *
  51140. * @type {Array<*>}
  51141. */
  51142. ranges: {
  51143. /**
  51144. * Range size value, similar to bubble Z data.
  51145. * @type {number}
  51146. */
  51147. value: void 0,
  51148. /**
  51149. * The color of the border for individual range.
  51150. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51151. */
  51152. borderColor: void 0,
  51153. /**
  51154. * The color of the bubble for individual range.
  51155. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51156. */
  51157. color: void 0,
  51158. /**
  51159. * The color of the connector for individual range.
  51160. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51161. */
  51162. connectorColor: void 0
  51163. },
  51164. /**
  51165. * Whether the bubble legend range value should be represented
  51166. * by the area or the width of the bubble. The default, area,
  51167. * corresponds best to the human perception of the size of each
  51168. * bubble.
  51169. *
  51170. * @sample highcharts/bubble-legend/ranges/
  51171. * Size by width
  51172. *
  51173. * @type {Highcharts.BubbleSizeByValue}
  51174. */
  51175. sizeBy: 'area',
  51176. /**
  51177. * When this is true, the absolute value of z determines the
  51178. * size of the bubble. This means that with the default
  51179. * zThreshold of 0, a bubble of value -1 will have the same size
  51180. * as a bubble of value 1, while a bubble of value 0 will have a
  51181. * smaller size according to minSize.
  51182. */
  51183. sizeByAbsoluteValue: false,
  51184. /**
  51185. * Define the visual z index of the bubble legend.
  51186. */
  51187. zIndex: 1,
  51188. /**
  51189. * Ranges with with lower value than zThreshold, are skipped.
  51190. */
  51191. zThreshold: 0
  51192. }
  51193. }
  51194. });
  51195. /* eslint-disable no-invalid-this, valid-jsdoc */
  51196. /**
  51197. * BubbleLegend class.
  51198. *
  51199. * @private
  51200. * @class
  51201. * @name Highcharts.BubbleLegend
  51202. * @param {Highcharts.LegendBubbleLegendOptions} options
  51203. * Bubble legend options
  51204. * @param {Highcharts.Legend} legend
  51205. * Legend
  51206. */
  51207. var BubbleLegend = /** @class */ (function () {
  51208. function BubbleLegend(options, legend) {
  51209. this.chart = void 0;
  51210. this.fontMetrics = void 0;
  51211. this.legend = void 0;
  51212. this.legendGroup = void 0;
  51213. this.legendItem = void 0;
  51214. this.legendItemHeight = void 0;
  51215. this.legendItemWidth = void 0;
  51216. this.legendSymbol = void 0;
  51217. this.maxLabel = void 0;
  51218. this.movementX = void 0;
  51219. this.ranges = void 0;
  51220. this.visible = void 0;
  51221. this.symbols = void 0;
  51222. this.options = void 0;
  51223. this.setState = noop;
  51224. this.init(options, legend);
  51225. }
  51226. /**
  51227. * Create basic bubbleLegend properties similar to item in legend.
  51228. *
  51229. * @private
  51230. * @function Highcharts.BubbleLegend#init
  51231. * @param {Highcharts.LegendBubbleLegendOptions} options
  51232. * Bubble legend options
  51233. * @param {Highcharts.Legend} legend
  51234. * Legend
  51235. * @return {void}
  51236. */
  51237. BubbleLegend.prototype.init = function (options, legend) {
  51238. this.options = options;
  51239. this.visible = true;
  51240. this.chart = legend.chart;
  51241. this.legend = legend;
  51242. };
  51243. /**
  51244. * Depending on the position option, add bubbleLegend to legend items.
  51245. *
  51246. * @private
  51247. * @function Highcharts.BubbleLegend#addToLegend
  51248. * @param {Array<(Highcharts.Point|Highcharts.Series)>}
  51249. * All legend items
  51250. * @return {void}
  51251. */
  51252. BubbleLegend.prototype.addToLegend = function (items) {
  51253. // Insert bubbleLegend into legend items
  51254. items.splice(this.options.legendIndex, 0, this);
  51255. };
  51256. /**
  51257. * Calculate ranges, sizes and call the next steps of bubbleLegend
  51258. * creation.
  51259. *
  51260. * @private
  51261. * @function Highcharts.BubbleLegend#drawLegendSymbol
  51262. * @param {Highcharts.Legend} legend
  51263. * Legend instance
  51264. * @return {void}
  51265. */
  51266. BubbleLegend.prototype.drawLegendSymbol = function (legend) {
  51267. var chart = this.chart,
  51268. options = this.options,
  51269. size,
  51270. itemDistance = pick(legend.options.itemDistance, 20),
  51271. connectorSpace,
  51272. ranges = options.ranges,
  51273. radius,
  51274. maxLabel,
  51275. connectorDistance = options.connectorDistance;
  51276. // Predict label dimensions
  51277. this.fontMetrics = chart.renderer.fontMetrics(options.labels.style.fontSize);
  51278. // Do not create bubbleLegend now if ranges or ranges valeus are not
  51279. // specified or if are empty array.
  51280. if (!ranges || !ranges.length || !isNumber(ranges[0].value)) {
  51281. legend.options.bubbleLegend.autoRanges = true;
  51282. return;
  51283. }
  51284. // Sort ranges to right render order
  51285. stableSort(ranges, function (a, b) {
  51286. return b.value - a.value;
  51287. });
  51288. this.ranges = ranges;
  51289. this.setOptions();
  51290. this.render();
  51291. // Get max label size
  51292. maxLabel = this.getMaxLabelSize();
  51293. radius = this.ranges[0].radius;
  51294. size = radius * 2;
  51295. // Space for connectors and labels.
  51296. connectorSpace =
  51297. connectorDistance - radius + maxLabel.width;
  51298. connectorSpace = connectorSpace > 0 ? connectorSpace : 0;
  51299. this.maxLabel = maxLabel;
  51300. this.movementX = options.labels.align === 'left' ?
  51301. connectorSpace : 0;
  51302. this.legendItemWidth = size + connectorSpace + itemDistance;
  51303. this.legendItemHeight = size + this.fontMetrics.h / 2;
  51304. };
  51305. /**
  51306. * Set style options for each bubbleLegend range.
  51307. *
  51308. * @private
  51309. * @function Highcharts.BubbleLegend#setOptions
  51310. * @return {void}
  51311. */
  51312. BubbleLegend.prototype.setOptions = function () {
  51313. var ranges = this.ranges,
  51314. options = this.options,
  51315. series = this.chart.series[options.seriesIndex],
  51316. baseline = this.legend.baseline,
  51317. bubbleAttribs = {
  51318. zIndex: options.zIndex,
  51319. 'stroke-width': options.borderWidth
  51320. },
  51321. connectorAttribs = {
  51322. zIndex: options.zIndex,
  51323. 'stroke-width': options.connectorWidth
  51324. },
  51325. labelAttribs = {
  51326. align: (this.legend.options.rtl ||
  51327. options.labels.align === 'left') ? 'right' : 'left',
  51328. zIndex: options.zIndex
  51329. },
  51330. fillOpacity = series.options.marker.fillOpacity,
  51331. styledMode = this.chart.styledMode;
  51332. // Allow to parts of styles be used individually for range
  51333. ranges.forEach(function (range, i) {
  51334. if (!styledMode) {
  51335. bubbleAttribs.stroke = pick(range.borderColor, options.borderColor, series.color);
  51336. bubbleAttribs.fill = pick(range.color, options.color, fillOpacity !== 1 ?
  51337. color(series.color).setOpacity(fillOpacity)
  51338. .get('rgba') :
  51339. series.color);
  51340. connectorAttribs.stroke = pick(range.connectorColor, options.connectorColor, series.color);
  51341. }
  51342. // Set options needed for rendering each range
  51343. ranges[i].radius = this.getRangeRadius(range.value);
  51344. ranges[i] = merge(ranges[i], {
  51345. center: (ranges[0].radius - ranges[i].radius +
  51346. baseline)
  51347. });
  51348. if (!styledMode) {
  51349. merge(true, ranges[i], {
  51350. bubbleAttribs: merge(bubbleAttribs),
  51351. connectorAttribs: merge(connectorAttribs),
  51352. labelAttribs: labelAttribs
  51353. });
  51354. }
  51355. }, this);
  51356. };
  51357. /**
  51358. * Calculate radius for each bubble range,
  51359. * used code from BubbleSeries.js 'getRadius' method.
  51360. *
  51361. * @private
  51362. * @function Highcharts.BubbleLegend#getRangeRadius
  51363. * @param {number} value
  51364. * Range value
  51365. * @return {number|null}
  51366. * Radius for one range
  51367. */
  51368. BubbleLegend.prototype.getRangeRadius = function (value) {
  51369. var options = this.options,
  51370. seriesIndex = this.options.seriesIndex,
  51371. bubbleSeries = this.chart.series[seriesIndex],
  51372. zMax = options.ranges[0].value,
  51373. zMin = options.ranges[options.ranges.length - 1].value,
  51374. minSize = options.minSize,
  51375. maxSize = options.maxSize;
  51376. return bubbleSeries.getRadius.call(this, zMin, zMax, minSize, maxSize, value);
  51377. };
  51378. /**
  51379. * Render the legendSymbol group.
  51380. *
  51381. * @private
  51382. * @function Highcharts.BubbleLegend#render
  51383. * @return {void}
  51384. */
  51385. BubbleLegend.prototype.render = function () {
  51386. var renderer = this.chart.renderer,
  51387. zThreshold = this.options.zThreshold;
  51388. if (!this.symbols) {
  51389. this.symbols = {
  51390. connectors: [],
  51391. bubbleItems: [],
  51392. labels: []
  51393. };
  51394. }
  51395. // Nesting SVG groups to enable handleOverflow
  51396. this.legendSymbol = renderer.g('bubble-legend');
  51397. this.legendItem = renderer.g('bubble-legend-item');
  51398. // To enable default 'hideOverlappingLabels' method
  51399. this.legendSymbol.translateX = 0;
  51400. this.legendSymbol.translateY = 0;
  51401. this.ranges.forEach(function (range) {
  51402. if (range.value >= zThreshold) {
  51403. this.renderRange(range);
  51404. }
  51405. }, this);
  51406. // To use handleOverflow method
  51407. this.legendSymbol.add(this.legendItem);
  51408. this.legendItem.add(this.legendGroup);
  51409. this.hideOverlappingLabels();
  51410. };
  51411. /**
  51412. * Render one range, consisting of bubble symbol, connector and label.
  51413. *
  51414. * @private
  51415. * @function Highcharts.BubbleLegend#renderRange
  51416. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  51417. * Range options
  51418. * @return {void}
  51419. */
  51420. BubbleLegend.prototype.renderRange = function (range) {
  51421. var mainRange = this.ranges[0],
  51422. legend = this.legend,
  51423. options = this.options,
  51424. labelsOptions = options.labels,
  51425. chart = this.chart,
  51426. bubbleSeries = chart.series[options.seriesIndex],
  51427. renderer = chart.renderer,
  51428. symbols = this.symbols,
  51429. labels = symbols.labels,
  51430. label,
  51431. elementCenter = range.center,
  51432. absoluteRadius = Math.abs(range.radius),
  51433. connectorDistance = options.connectorDistance || 0,
  51434. labelsAlign = labelsOptions.align,
  51435. rtl = legend.options.rtl,
  51436. connectorLength = rtl || labelsAlign === 'left' ?
  51437. -connectorDistance : connectorDistance,
  51438. borderWidth = options.borderWidth,
  51439. connectorWidth = options.connectorWidth,
  51440. posX = mainRange.radius || 0,
  51441. posY = elementCenter - absoluteRadius -
  51442. borderWidth / 2 + connectorWidth / 2,
  51443. labelY,
  51444. labelX,
  51445. fontMetrics = this.fontMetrics,
  51446. labelMovement = fontMetrics.f / 2 -
  51447. (fontMetrics.h - fontMetrics.f) / 2,
  51448. crispMovement = (posY % 1 ? 1 : 0.5) -
  51449. (connectorWidth % 2 ? 0 : 0.5),
  51450. styledMode = renderer.styledMode;
  51451. // Set options for centered labels
  51452. if (labelsAlign === 'center') {
  51453. connectorLength = 0; // do not use connector
  51454. options.connectorDistance = 0;
  51455. range.labelAttribs.align = 'center';
  51456. }
  51457. labelY = posY + options.labels.y;
  51458. labelX = posX + connectorLength + options.labels.x;
  51459. // Render bubble symbol
  51460. symbols.bubbleItems.push(renderer
  51461. .circle(posX, elementCenter + crispMovement, absoluteRadius)
  51462. .attr(styledMode ? {} : range.bubbleAttribs)
  51463. .addClass((styledMode ?
  51464. 'highcharts-color-' +
  51465. bubbleSeries.colorIndex + ' ' :
  51466. '') +
  51467. 'highcharts-bubble-legend-symbol ' +
  51468. (options.className || '')).add(this.legendSymbol));
  51469. // Render connector
  51470. symbols.connectors.push(renderer
  51471. .path(renderer.crispLine([
  51472. ['M', posX, posY],
  51473. ['L', posX + connectorLength, posY]
  51474. ], options.connectorWidth))
  51475. .attr((styledMode ? {} : range.connectorAttribs))
  51476. .addClass((styledMode ?
  51477. 'highcharts-color-' +
  51478. this.options.seriesIndex + ' ' : '') +
  51479. 'highcharts-bubble-legend-connectors ' +
  51480. (options.connectorClassName || '')).add(this.legendSymbol));
  51481. // Render label
  51482. label = renderer
  51483. .text(this.formatLabel(range), labelX, labelY + labelMovement)
  51484. .attr((styledMode ? {} : range.labelAttribs))
  51485. .css(styledMode ? {} : labelsOptions.style)
  51486. .addClass('highcharts-bubble-legend-labels ' +
  51487. (options.labels.className || '')).add(this.legendSymbol);
  51488. labels.push(label);
  51489. // To enable default 'hideOverlappingLabels' method
  51490. label.placed = true;
  51491. label.alignAttr = {
  51492. x: labelX,
  51493. y: labelY + labelMovement
  51494. };
  51495. };
  51496. /**
  51497. * Get the label which takes up the most space.
  51498. *
  51499. * @private
  51500. * @function Highcharts.BubbleLegend#getMaxLabelSize
  51501. * @return {Highcharts.BBoxObject}
  51502. */
  51503. BubbleLegend.prototype.getMaxLabelSize = function () {
  51504. var labels = this.symbols.labels,
  51505. maxLabel,
  51506. labelSize;
  51507. labels.forEach(function (label) {
  51508. labelSize = label.getBBox(true);
  51509. if (maxLabel) {
  51510. maxLabel = labelSize.width > maxLabel.width ?
  51511. labelSize : maxLabel;
  51512. }
  51513. else {
  51514. maxLabel = labelSize;
  51515. }
  51516. });
  51517. return maxLabel || {};
  51518. };
  51519. /**
  51520. * Get formatted label for range.
  51521. *
  51522. * @private
  51523. * @function Highcharts.BubbleLegend#formatLabel
  51524. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  51525. * Range options
  51526. * @return {string}
  51527. * Range label text
  51528. */
  51529. BubbleLegend.prototype.formatLabel = function (range) {
  51530. var options = this.options,
  51531. formatter = options.labels.formatter,
  51532. format = options.labels.format;
  51533. var numberFormatter = this.chart.numberFormatter;
  51534. return format ? F.format(format, range) :
  51535. formatter ? formatter.call(range) :
  51536. numberFormatter(range.value, 1);
  51537. };
  51538. /**
  51539. * By using default chart 'hideOverlappingLabels' method, hide or show
  51540. * labels and connectors.
  51541. *
  51542. * @private
  51543. * @function Highcharts.BubbleLegend#hideOverlappingLabels
  51544. * @return {void}
  51545. */
  51546. BubbleLegend.prototype.hideOverlappingLabels = function () {
  51547. var chart = this.chart,
  51548. allowOverlap = this.options.labels.allowOverlap,
  51549. symbols = this.symbols;
  51550. if (!allowOverlap && symbols) {
  51551. chart.hideOverlappingLabels(symbols.labels);
  51552. // Hide or show connectors
  51553. symbols.labels.forEach(function (label, index) {
  51554. if (!label.newOpacity) {
  51555. symbols.connectors[index].hide();
  51556. }
  51557. else if (label.newOpacity !== label.oldOpacity) {
  51558. symbols.connectors[index].show();
  51559. }
  51560. });
  51561. }
  51562. };
  51563. /**
  51564. * Calculate ranges from created series.
  51565. *
  51566. * @private
  51567. * @function Highcharts.BubbleLegend#getRanges
  51568. * @return {Array<Highcharts.LegendBubbleLegendRangesOptions>}
  51569. * Array of range objects
  51570. */
  51571. BubbleLegend.prototype.getRanges = function () {
  51572. var bubbleLegend = this.legend.bubbleLegend,
  51573. series = bubbleLegend.chart.series,
  51574. ranges,
  51575. rangesOptions = bubbleLegend.options.ranges,
  51576. zData,
  51577. minZ = Number.MAX_VALUE,
  51578. maxZ = -Number.MAX_VALUE;
  51579. series.forEach(function (s) {
  51580. // Find the min and max Z, like in bubble series
  51581. if (s.isBubble && !s.ignoreSeries) {
  51582. zData = s.zData.filter(isNumber);
  51583. if (zData.length) {
  51584. minZ = pick(s.options.zMin, Math.min(minZ, Math.max(arrayMin(zData), s.options.displayNegative === false ?
  51585. s.options.zThreshold :
  51586. -Number.MAX_VALUE)));
  51587. maxZ = pick(s.options.zMax, Math.max(maxZ, arrayMax(zData)));
  51588. }
  51589. }
  51590. });
  51591. // Set values for ranges
  51592. if (minZ === maxZ) {
  51593. // Only one range if min and max values are the same.
  51594. ranges = [{ value: maxZ }];
  51595. }
  51596. else {
  51597. ranges = [
  51598. { value: minZ },
  51599. { value: (minZ + maxZ) / 2 },
  51600. { value: maxZ, autoRanges: true }
  51601. ];
  51602. }
  51603. // Prevent reverse order of ranges after redraw
  51604. if (rangesOptions.length && rangesOptions[0].radius) {
  51605. ranges.reverse();
  51606. }
  51607. // Merge ranges values with user options
  51608. ranges.forEach(function (range, i) {
  51609. if (rangesOptions && rangesOptions[i]) {
  51610. ranges[i] = merge(rangesOptions[i], range);
  51611. }
  51612. });
  51613. return ranges;
  51614. };
  51615. /**
  51616. * Calculate bubble legend sizes from rendered series.
  51617. *
  51618. * @private
  51619. * @function Highcharts.BubbleLegend#predictBubbleSizes
  51620. * @return {Array<number,number>}
  51621. * Calculated min and max bubble sizes
  51622. */
  51623. BubbleLegend.prototype.predictBubbleSizes = function () {
  51624. var chart = this.chart,
  51625. fontMetrics = this.fontMetrics,
  51626. legendOptions = chart.legend.options,
  51627. floating = legendOptions.floating,
  51628. horizontal = legendOptions.layout === 'horizontal',
  51629. lastLineHeight = horizontal ? chart.legend.lastLineHeight : 0,
  51630. plotSizeX = chart.plotSizeX,
  51631. plotSizeY = chart.plotSizeY,
  51632. bubbleSeries = chart.series[this.options.seriesIndex],
  51633. minSize = Math.ceil(bubbleSeries.minPxSize),
  51634. maxPxSize = Math.ceil(bubbleSeries.maxPxSize),
  51635. maxSize = bubbleSeries.options.maxSize,
  51636. plotSize = Math.min(plotSizeY,
  51637. plotSizeX),
  51638. calculatedSize;
  51639. // Calculate prediceted max size of bubble
  51640. if (floating || !(/%$/.test(maxSize))) {
  51641. calculatedSize = maxPxSize;
  51642. }
  51643. else {
  51644. maxSize = parseFloat(maxSize);
  51645. calculatedSize = ((plotSize + lastLineHeight -
  51646. fontMetrics.h / 2) * maxSize / 100) / (maxSize / 100 + 1);
  51647. // Get maxPxSize from bubble series if calculated bubble legend
  51648. // size will not affect to bubbles series.
  51649. if ((horizontal && plotSizeY - calculatedSize >=
  51650. plotSizeX) || (!horizontal && plotSizeX -
  51651. calculatedSize >= plotSizeY)) {
  51652. calculatedSize = maxPxSize;
  51653. }
  51654. }
  51655. return [minSize, Math.ceil(calculatedSize)];
  51656. };
  51657. /**
  51658. * Correct ranges with calculated sizes.
  51659. *
  51660. * @private
  51661. * @function Highcharts.BubbleLegend#updateRanges
  51662. * @param {number} min
  51663. * @param {number} max
  51664. * @return {void}
  51665. */
  51666. BubbleLegend.prototype.updateRanges = function (min, max) {
  51667. var bubbleLegendOptions = this.legend.options.bubbleLegend;
  51668. bubbleLegendOptions.minSize = min;
  51669. bubbleLegendOptions.maxSize = max;
  51670. bubbleLegendOptions.ranges = this.getRanges();
  51671. };
  51672. /**
  51673. * Because of the possibility of creating another legend line, predicted
  51674. * bubble legend sizes may differ by a few pixels, so it is necessary to
  51675. * correct them.
  51676. *
  51677. * @private
  51678. * @function Highcharts.BubbleLegend#correctSizes
  51679. * @return {void}
  51680. */
  51681. BubbleLegend.prototype.correctSizes = function () {
  51682. var legend = this.legend,
  51683. chart = this.chart,
  51684. bubbleSeries = chart.series[this.options.seriesIndex],
  51685. bubbleSeriesSize = bubbleSeries.maxPxSize,
  51686. bubbleLegendSize = this.options.maxSize;
  51687. if (Math.abs(Math.ceil(bubbleSeriesSize) - bubbleLegendSize) >
  51688. 1) {
  51689. this.updateRanges(this.options.minSize, bubbleSeries.maxPxSize);
  51690. legend.render();
  51691. }
  51692. };
  51693. return BubbleLegend;
  51694. }());
  51695. // Start the bubble legend creation process.
  51696. addEvent(Legend, 'afterGetAllItems', function (e) {
  51697. var legend = this,
  51698. bubbleLegend = legend.bubbleLegend,
  51699. legendOptions = legend.options,
  51700. options = legendOptions.bubbleLegend,
  51701. bubbleSeriesIndex = legend.chart.getVisibleBubbleSeriesIndex();
  51702. // Remove unnecessary element
  51703. if (bubbleLegend && bubbleLegend.ranges && bubbleLegend.ranges.length) {
  51704. // Allow change the way of calculating ranges in update
  51705. if (options.ranges.length) {
  51706. options.autoRanges =
  51707. !!options.ranges[0].autoRanges;
  51708. }
  51709. // Update bubbleLegend dimensions in each redraw
  51710. legend.destroyItem(bubbleLegend);
  51711. }
  51712. // Create bubble legend
  51713. if (bubbleSeriesIndex >= 0 &&
  51714. legendOptions.enabled &&
  51715. options.enabled) {
  51716. options.seriesIndex = bubbleSeriesIndex;
  51717. legend.bubbleLegend = new H.BubbleLegend(options, legend);
  51718. legend.bubbleLegend.addToLegend(e.allItems);
  51719. }
  51720. });
  51721. /**
  51722. * Check if there is at least one visible bubble series.
  51723. *
  51724. * @private
  51725. * @function Highcharts.Chart#getVisibleBubbleSeriesIndex
  51726. * @return {number}
  51727. * First visible bubble series index
  51728. */
  51729. Chart.prototype.getVisibleBubbleSeriesIndex = function () {
  51730. var series = this.series,
  51731. i = 0;
  51732. while (i < series.length) {
  51733. if (series[i] &&
  51734. series[i].isBubble &&
  51735. series[i].visible &&
  51736. series[i].zData.length) {
  51737. return i;
  51738. }
  51739. i++;
  51740. }
  51741. return -1;
  51742. };
  51743. /**
  51744. * Calculate height for each row in legend.
  51745. *
  51746. * @private
  51747. * @function Highcharts.Legend#getLinesHeights
  51748. * @return {Array<Highcharts.Dictionary<number>>}
  51749. * Informations about line height and items amount
  51750. */
  51751. Legend.prototype.getLinesHeights = function () {
  51752. var items = this.allItems,
  51753. lines = [],
  51754. lastLine,
  51755. length = items.length,
  51756. i = 0,
  51757. j = 0;
  51758. for (i = 0; i < length; i++) {
  51759. if (items[i].legendItemHeight) {
  51760. // for bubbleLegend
  51761. items[i].itemHeight = items[i].legendItemHeight;
  51762. }
  51763. if ( // Line break
  51764. items[i] === items[length - 1] ||
  51765. items[i + 1] &&
  51766. items[i]._legendItemPos[1] !==
  51767. items[i + 1]._legendItemPos[1]) {
  51768. lines.push({ height: 0 });
  51769. lastLine = lines[lines.length - 1];
  51770. // Find the highest item in line
  51771. for (j; j <= i; j++) {
  51772. if (items[j].itemHeight > lastLine.height) {
  51773. lastLine.height = items[j].itemHeight;
  51774. }
  51775. }
  51776. lastLine.step = i;
  51777. }
  51778. }
  51779. return lines;
  51780. };
  51781. /**
  51782. * Correct legend items translation in case of different elements heights.
  51783. *
  51784. * @private
  51785. * @function Highcharts.Legend#retranslateItems
  51786. * @param {Array<Highcharts.Dictionary<number>>} lines
  51787. * Informations about line height and items amount
  51788. * @return {void}
  51789. */
  51790. Legend.prototype.retranslateItems = function (lines) {
  51791. var items = this.allItems,
  51792. orgTranslateX,
  51793. orgTranslateY,
  51794. movementX,
  51795. rtl = this.options.rtl,
  51796. actualLine = 0;
  51797. items.forEach(function (item, index) {
  51798. orgTranslateX = item.legendGroup.translateX;
  51799. orgTranslateY = item._legendItemPos[1];
  51800. movementX = item.movementX;
  51801. if (movementX || (rtl && item.ranges)) {
  51802. movementX = rtl ?
  51803. orgTranslateX - item.options.maxSize / 2 :
  51804. orgTranslateX + movementX;
  51805. item.legendGroup.attr({ translateX: movementX });
  51806. }
  51807. if (index > lines[actualLine].step) {
  51808. actualLine++;
  51809. }
  51810. item.legendGroup.attr({
  51811. translateY: Math.round(orgTranslateY + lines[actualLine].height / 2)
  51812. });
  51813. item._legendItemPos[1] = orgTranslateY +
  51814. lines[actualLine].height / 2;
  51815. });
  51816. };
  51817. // Toggle bubble legend depending on the visible status of bubble series.
  51818. addEvent(Series, 'legendItemClick', function () {
  51819. var series = this,
  51820. chart = series.chart,
  51821. visible = series.visible,
  51822. legend = series.chart.legend,
  51823. status;
  51824. if (legend && legend.bubbleLegend) {
  51825. // Temporary correct 'visible' property
  51826. series.visible = !visible;
  51827. // Save future status for getRanges method
  51828. series.ignoreSeries = visible;
  51829. // Check if at lest one bubble series is visible
  51830. status = chart.getVisibleBubbleSeriesIndex() >= 0;
  51831. // Hide bubble legend if all bubble series are disabled
  51832. if (legend.bubbleLegend.visible !== status) {
  51833. // Show or hide bubble legend
  51834. legend.update({
  51835. bubbleLegend: { enabled: status }
  51836. });
  51837. legend.bubbleLegend.visible = status; // Restore default status
  51838. }
  51839. series.visible = visible;
  51840. }
  51841. });
  51842. // If ranges are not specified, determine ranges from rendered bubble series
  51843. // and render legend again.
  51844. wrap(Chart.prototype, 'drawChartBox', function (proceed, options, callback) {
  51845. var chart = this,
  51846. legend = chart.legend,
  51847. bubbleSeries = chart.getVisibleBubbleSeriesIndex() >= 0,
  51848. bubbleLegendOptions,
  51849. bubbleSizes;
  51850. if (legend && legend.options.enabled && legend.bubbleLegend &&
  51851. legend.options.bubbleLegend.autoRanges && bubbleSeries) {
  51852. bubbleLegendOptions = legend.bubbleLegend.options;
  51853. bubbleSizes = legend.bubbleLegend.predictBubbleSizes();
  51854. legend.bubbleLegend.updateRanges(bubbleSizes[0], bubbleSizes[1]);
  51855. // Disable animation on init
  51856. if (!bubbleLegendOptions.placed) {
  51857. legend.group.placed = false;
  51858. legend.allItems.forEach(function (item) {
  51859. item.legendGroup.translateY = null;
  51860. });
  51861. }
  51862. // Create legend with bubbleLegend
  51863. legend.render();
  51864. chart.getMargins();
  51865. chart.axes.forEach(function (axis) {
  51866. if (axis.visible) { // #11448
  51867. axis.render();
  51868. }
  51869. if (!bubbleLegendOptions.placed) {
  51870. axis.setScale();
  51871. axis.updateNames();
  51872. // Disable axis animation on init
  51873. objectEach(axis.ticks, function (tick) {
  51874. tick.isNew = true;
  51875. tick.isNewLabel = true;
  51876. });
  51877. }
  51878. });
  51879. bubbleLegendOptions.placed = true;
  51880. // After recalculate axes, calculate margins again.
  51881. chart.getMargins();
  51882. // Call default 'drawChartBox' method.
  51883. proceed.call(chart, options, callback);
  51884. // Check bubble legend sizes and correct them if necessary.
  51885. legend.bubbleLegend.correctSizes();
  51886. // Correct items positions with different dimensions in legend.
  51887. legend.retranslateItems(legend.getLinesHeights());
  51888. }
  51889. else {
  51890. proceed.call(chart, options, callback);
  51891. // Allow color change on static bubble legend after click on legend
  51892. if (legend && legend.options.enabled && legend.bubbleLegend) {
  51893. legend.render();
  51894. legend.retranslateItems(legend.getLinesHeights());
  51895. }
  51896. }
  51897. });
  51898. H.BubbleLegend = BubbleLegend;
  51899. return H.BubbleLegend;
  51900. });
  51901. _registerModule(_modules, 'Series/Bubble/BubbleSeries.js', [_modules['Core/Axis/Axis.js'], _modules['Series/Bubble/BubblePoint.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Axis, BubblePoint, Color, H, Series, SeriesRegistry, U) {
  51902. /* *
  51903. *
  51904. * (c) 2010-2021 Torstein Honsi
  51905. *
  51906. * License: www.highcharts.com/license
  51907. *
  51908. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  51909. *
  51910. * */
  51911. var __extends = (this && this.__extends) || (function () {
  51912. var extendStatics = function (d,
  51913. b) {
  51914. extendStatics = Object.setPrototypeOf ||
  51915. ({ __proto__: [] } instanceof Array && function (d,
  51916. b) { d.__proto__ = b; }) ||
  51917. function (d,
  51918. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  51919. return extendStatics(d, b);
  51920. };
  51921. return function (d, b) {
  51922. extendStatics(d, b);
  51923. function __() { this.constructor = d; }
  51924. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  51925. };
  51926. })();
  51927. var color = Color.parse;
  51928. var noop = H.noop;
  51929. var _a = SeriesRegistry.seriesTypes,
  51930. ColumnSeries = _a.column,
  51931. ScatterSeries = _a.scatter;
  51932. var arrayMax = U.arrayMax,
  51933. arrayMin = U.arrayMin,
  51934. clamp = U.clamp,
  51935. extend = U.extend,
  51936. isNumber = U.isNumber,
  51937. merge = U.merge,
  51938. pick = U.pick,
  51939. pInt = U.pInt;
  51940. /* *
  51941. *
  51942. * Class
  51943. *
  51944. * */
  51945. var BubbleSeries = /** @class */ (function (_super) {
  51946. __extends(BubbleSeries, _super);
  51947. function BubbleSeries() {
  51948. /* *
  51949. *
  51950. * Static Properties
  51951. *
  51952. * */
  51953. var _this = _super !== null && _super.apply(this,
  51954. arguments) || this;
  51955. /* *
  51956. *
  51957. * Properties
  51958. *
  51959. * */
  51960. _this.data = void 0;
  51961. _this.maxPxSize = void 0;
  51962. _this.minPxSize = void 0;
  51963. _this.options = void 0;
  51964. _this.points = void 0;
  51965. _this.radii = void 0;
  51966. _this.yData = void 0;
  51967. _this.zData = void 0;
  51968. return _this;
  51969. /* eslint-enable valid-jsdoc */
  51970. }
  51971. /* *
  51972. *
  51973. * Functions
  51974. *
  51975. * */
  51976. /* eslint-disable valid-jsdoc */
  51977. /**
  51978. * Perform animation on the bubbles
  51979. * @private
  51980. */
  51981. BubbleSeries.prototype.animate = function (init) {
  51982. if (!init &&
  51983. this.points.length < this.options.animationLimit // #8099
  51984. ) {
  51985. this.points.forEach(function (point) {
  51986. var graphic = point.graphic;
  51987. if (graphic && graphic.width) { // URL symbols don't have width
  51988. // Start values
  51989. if (!this.hasRendered) {
  51990. graphic.attr({
  51991. x: point.plotX,
  51992. y: point.plotY,
  51993. width: 1,
  51994. height: 1
  51995. });
  51996. }
  51997. // Run animation
  51998. graphic.animate(this.markerAttribs(point), this.options.animation);
  51999. }
  52000. }, this);
  52001. }
  52002. };
  52003. /**
  52004. * Get the radius for each point based on the minSize, maxSize and each
  52005. * point's Z value. This must be done prior to Series.translate because
  52006. * the axis needs to add padding in accordance with the point sizes.
  52007. * @private
  52008. */
  52009. BubbleSeries.prototype.getRadii = function (zMin, zMax, series) {
  52010. var len,
  52011. i,
  52012. zData = this.zData,
  52013. yData = this.yData,
  52014. minSize = series.minPxSize,
  52015. maxSize = series.maxPxSize,
  52016. radii = [],
  52017. value;
  52018. // Set the shape type and arguments to be picked up in drawPoints
  52019. for (i = 0, len = zData.length; i < len; i++) {
  52020. value = zData[i];
  52021. // Separate method to get individual radius for bubbleLegend
  52022. radii.push(this.getRadius(zMin, zMax, minSize, maxSize, value, yData[i]));
  52023. }
  52024. this.radii = radii;
  52025. };
  52026. /**
  52027. * Get the individual radius for one point.
  52028. * @private
  52029. */
  52030. BubbleSeries.prototype.getRadius = function (zMin, zMax, minSize, maxSize, value, yValue) {
  52031. var options = this.options,
  52032. sizeByArea = options.sizeBy !== 'width',
  52033. zThreshold = options.zThreshold,
  52034. zRange = zMax - zMin,
  52035. pos = 0.5;
  52036. // #8608 - bubble should be visible when z is undefined
  52037. if (yValue === null || value === null) {
  52038. return null;
  52039. }
  52040. if (isNumber(value)) {
  52041. // When sizing by threshold, the absolute value of z determines
  52042. // the size of the bubble.
  52043. if (options.sizeByAbsoluteValue) {
  52044. value = Math.abs(value - zThreshold);
  52045. zMax = zRange = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
  52046. zMin = 0;
  52047. }
  52048. // Issue #4419 - if value is less than zMin, push a radius that's
  52049. // always smaller than the minimum size
  52050. if (value < zMin) {
  52051. return minSize / 2 - 1;
  52052. }
  52053. // Relative size, a number between 0 and 1
  52054. if (zRange > 0) {
  52055. pos = (value - zMin) / zRange;
  52056. }
  52057. }
  52058. if (sizeByArea && pos >= 0) {
  52059. pos = Math.sqrt(pos);
  52060. }
  52061. return Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
  52062. };
  52063. /**
  52064. * Define hasData function for non-cartesian series.
  52065. * Returns true if the series has points at all.
  52066. * @private
  52067. */
  52068. BubbleSeries.prototype.hasData = function () {
  52069. return !!this.processedXData.length; // != 0
  52070. };
  52071. /**
  52072. * @private
  52073. */
  52074. BubbleSeries.prototype.pointAttribs = function (point, state) {
  52075. var markerOptions = this.options.marker,
  52076. fillOpacity = markerOptions.fillOpacity,
  52077. attr = Series.prototype.pointAttribs.call(this,
  52078. point,
  52079. state);
  52080. if (fillOpacity !== 1) {
  52081. attr.fill = color(attr.fill)
  52082. .setOpacity(fillOpacity)
  52083. .get('rgba');
  52084. }
  52085. return attr;
  52086. };
  52087. /**
  52088. * Extend the base translate method to handle bubble size
  52089. * @private
  52090. */
  52091. BubbleSeries.prototype.translate = function () {
  52092. var i,
  52093. data = this.data,
  52094. point,
  52095. radius,
  52096. radii = this.radii;
  52097. // Run the parent method
  52098. _super.prototype.translate.call(this);
  52099. // Set the shape type and arguments to be picked up in drawPoints
  52100. i = data.length;
  52101. while (i--) {
  52102. point = data[i];
  52103. radius = radii ? radii[i] : 0; // #1737
  52104. if (isNumber(radius) && radius >= this.minPxSize / 2) {
  52105. // Shape arguments
  52106. point.marker = extend(point.marker, {
  52107. radius: radius,
  52108. width: 2 * radius,
  52109. height: 2 * radius
  52110. });
  52111. // Alignment box for the data label
  52112. point.dlBox = {
  52113. x: point.plotX - radius,
  52114. y: point.plotY - radius,
  52115. width: 2 * radius,
  52116. height: 2 * radius
  52117. };
  52118. }
  52119. else { // below zThreshold
  52120. // #1691
  52121. point.shapeArgs = point.plotY = point.dlBox = void 0;
  52122. }
  52123. }
  52124. };
  52125. /**
  52126. * A bubble series is a three dimensional series type where each point
  52127. * renders an X, Y and Z value. Each points is drawn as a bubble where the
  52128. * position along the X and Y axes mark the X and Y values, and the size of
  52129. * the bubble relates to the Z value.
  52130. *
  52131. * @sample {highcharts} highcharts/demo/bubble/
  52132. * Bubble chart
  52133. *
  52134. * @extends plotOptions.scatter
  52135. * @excluding cluster
  52136. * @product highcharts highstock
  52137. * @requires highcharts-more
  52138. * @optionparent plotOptions.bubble
  52139. */
  52140. BubbleSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  52141. dataLabels: {
  52142. formatter: function () {
  52143. return this.point.z;
  52144. },
  52145. inside: true,
  52146. verticalAlign: 'middle'
  52147. },
  52148. /**
  52149. * If there are more points in the series than the `animationLimit`, the
  52150. * animation won't run. Animation affects overall performance and
  52151. * doesn't work well with heavy data series.
  52152. *
  52153. * @since 6.1.0
  52154. */
  52155. animationLimit: 250,
  52156. /**
  52157. * Whether to display negative sized bubbles. The threshold is given
  52158. * by the [zThreshold](#plotOptions.bubble.zThreshold) option, and negative
  52159. * bubbles can be visualized by setting
  52160. * [negativeColor](#plotOptions.bubble.negativeColor).
  52161. *
  52162. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  52163. * Negative bubbles
  52164. *
  52165. * @type {boolean}
  52166. * @default true
  52167. * @since 3.0
  52168. * @apioption plotOptions.bubble.displayNegative
  52169. */
  52170. /**
  52171. * @extends plotOptions.series.marker
  52172. * @excluding enabled, enabledThreshold, height, radius, width
  52173. */
  52174. marker: {
  52175. lineColor: null,
  52176. lineWidth: 1,
  52177. /**
  52178. * The fill opacity of the bubble markers.
  52179. */
  52180. fillOpacity: 0.5,
  52181. /**
  52182. * In bubble charts, the radius is overridden and determined based
  52183. * on the point's data value.
  52184. *
  52185. * @ignore-option
  52186. */
  52187. radius: null,
  52188. states: {
  52189. hover: {
  52190. radiusPlus: 0
  52191. }
  52192. },
  52193. /**
  52194. * A predefined shape or symbol for the marker. Possible values are
  52195. * "circle", "square", "diamond", "triangle" and "triangle-down".
  52196. *
  52197. * Additionally, the URL to a graphic can be given on the form
  52198. * `url(graphic.png)`. Note that for the image to be applied to
  52199. * exported charts, its URL needs to be accessible by the export
  52200. * server.
  52201. *
  52202. * Custom callbacks for symbol path generation can also be added to
  52203. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  52204. * used by its method name, as shown in the demo.
  52205. *
  52206. * @sample {highcharts} highcharts/plotoptions/bubble-symbol/
  52207. * Bubble chart with various symbols
  52208. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  52209. * General chart with predefined, graphic and custom markers
  52210. *
  52211. * @type {Highcharts.SymbolKeyValue|string}
  52212. * @since 5.0.11
  52213. */
  52214. symbol: 'circle'
  52215. },
  52216. /**
  52217. * Minimum bubble size. Bubbles will automatically size between the
  52218. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  52219. * Can be either pixels (when no unit is given), or a percentage of
  52220. * the smallest one of the plot width and height.
  52221. *
  52222. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  52223. * Bubble size
  52224. *
  52225. * @type {number|string}
  52226. * @since 3.0
  52227. * @product highcharts highstock
  52228. */
  52229. minSize: 8,
  52230. /**
  52231. * Maximum bubble size. Bubbles will automatically size between the
  52232. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  52233. * Can be either pixels (when no unit is given), or a percentage of
  52234. * the smallest one of the plot width and height.
  52235. *
  52236. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  52237. * Bubble size
  52238. *
  52239. * @type {number|string}
  52240. * @since 3.0
  52241. * @product highcharts highstock
  52242. */
  52243. maxSize: '20%',
  52244. /**
  52245. * When a point's Z value is below the
  52246. * [zThreshold](#plotOptions.bubble.zThreshold)
  52247. * setting, this color is used.
  52248. *
  52249. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  52250. * Negative bubbles
  52251. *
  52252. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  52253. * @since 3.0
  52254. * @product highcharts
  52255. * @apioption plotOptions.bubble.negativeColor
  52256. */
  52257. /**
  52258. * Whether the bubble's value should be represented by the area or the
  52259. * width of the bubble. The default, `area`, corresponds best to the
  52260. * human perception of the size of each bubble.
  52261. *
  52262. * @sample {highcharts} highcharts/plotoptions/bubble-sizeby/
  52263. * Comparison of area and size
  52264. *
  52265. * @type {Highcharts.BubbleSizeByValue}
  52266. * @default area
  52267. * @since 3.0.7
  52268. * @apioption plotOptions.bubble.sizeBy
  52269. */
  52270. /**
  52271. * When this is true, the absolute value of z determines the size of
  52272. * the bubble. This means that with the default `zThreshold` of 0, a
  52273. * bubble of value -1 will have the same size as a bubble of value 1,
  52274. * while a bubble of value 0 will have a smaller size according to
  52275. * `minSize`.
  52276. *
  52277. * @sample {highcharts} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  52278. * Size by absolute value, various thresholds
  52279. *
  52280. * @type {boolean}
  52281. * @default false
  52282. * @since 4.1.9
  52283. * @product highcharts
  52284. * @apioption plotOptions.bubble.sizeByAbsoluteValue
  52285. */
  52286. /**
  52287. * When this is true, the series will not cause the Y axis to cross
  52288. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  52289. * unless the data actually crosses the plane.
  52290. *
  52291. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  52292. * 3 will make the Y axis show negative values according to the
  52293. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  52294. * at 0.
  52295. *
  52296. * @since 4.1.9
  52297. * @product highcharts
  52298. */
  52299. softThreshold: false,
  52300. states: {
  52301. hover: {
  52302. halo: {
  52303. size: 5
  52304. }
  52305. }
  52306. },
  52307. tooltip: {
  52308. pointFormat: '({point.x}, {point.y}), Size: {point.z}'
  52309. },
  52310. turboThreshold: 0,
  52311. /**
  52312. * The minimum for the Z value range. Defaults to the highest Z value
  52313. * in the data.
  52314. *
  52315. * @see [zMin](#plotOptions.bubble.zMin)
  52316. *
  52317. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  52318. * Z has a possible range of 0-100
  52319. *
  52320. * @type {number}
  52321. * @since 4.0.3
  52322. * @product highcharts
  52323. * @apioption plotOptions.bubble.zMax
  52324. */
  52325. /**
  52326. * @default z
  52327. * @apioption plotOptions.bubble.colorKey
  52328. */
  52329. /**
  52330. * The minimum for the Z value range. Defaults to the lowest Z value
  52331. * in the data.
  52332. *
  52333. * @see [zMax](#plotOptions.bubble.zMax)
  52334. *
  52335. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  52336. * Z has a possible range of 0-100
  52337. *
  52338. * @type {number}
  52339. * @since 4.0.3
  52340. * @product highcharts
  52341. * @apioption plotOptions.bubble.zMin
  52342. */
  52343. /**
  52344. * When [displayNegative](#plotOptions.bubble.displayNegative) is `false`,
  52345. * bubbles with lower Z values are skipped. When `displayNegative`
  52346. * is `true` and a [negativeColor](#plotOptions.bubble.negativeColor)
  52347. * is given, points with lower Z is colored.
  52348. *
  52349. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  52350. * Negative bubbles
  52351. *
  52352. * @since 3.0
  52353. * @product highcharts
  52354. */
  52355. zThreshold: 0,
  52356. zoneAxis: 'z'
  52357. });
  52358. return BubbleSeries;
  52359. }(ScatterSeries));
  52360. extend(BubbleSeries.prototype, {
  52361. alignDataLabel: ColumnSeries.prototype.alignDataLabel,
  52362. applyZones: noop,
  52363. bubblePadding: true,
  52364. buildKDTree: noop,
  52365. directTouch: true,
  52366. isBubble: true,
  52367. pointArrayMap: ['y', 'z'],
  52368. pointClass: BubblePoint,
  52369. parallelArrays: ['x', 'y', 'z'],
  52370. trackerGroups: ['group', 'dataLabelsGroup'],
  52371. specialGroup: 'group',
  52372. zoneAxis: 'z'
  52373. });
  52374. /* *
  52375. *
  52376. * Axis ?
  52377. *
  52378. * */
  52379. // Add logic to pad each axis with the amount of pixels necessary to avoid the
  52380. // bubbles to overflow.
  52381. Axis.prototype.beforePadding = function () {
  52382. var axis = this,
  52383. axisLength = this.len,
  52384. chart = this.chart,
  52385. pxMin = 0,
  52386. pxMax = axisLength,
  52387. isXAxis = this.isXAxis,
  52388. dataKey = isXAxis ? 'xData' : 'yData',
  52389. min = this.min,
  52390. extremes = {},
  52391. smallestSize = Math.min(chart.plotWidth,
  52392. chart.plotHeight),
  52393. zMin = Number.MAX_VALUE,
  52394. zMax = -Number.MAX_VALUE,
  52395. range = this.max - min,
  52396. transA = axisLength / range,
  52397. activeSeries = [];
  52398. // Handle padding on the second pass, or on redraw
  52399. this.series.forEach(function (series) {
  52400. var seriesOptions = series.options,
  52401. zData;
  52402. if (series.bubblePadding &&
  52403. (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
  52404. // Correction for #1673
  52405. axis.allowZoomOutside = true;
  52406. // Cache it
  52407. activeSeries.push(series);
  52408. if (isXAxis) { // because X axis is evaluated first
  52409. // For each series, translate the size extremes to pixel values
  52410. ['minSize', 'maxSize'].forEach(function (prop) {
  52411. var length = seriesOptions[prop],
  52412. isPercent = /%$/.test(length);
  52413. length = pInt(length);
  52414. extremes[prop] = isPercent ?
  52415. smallestSize * length / 100 :
  52416. length;
  52417. });
  52418. series.minPxSize = extremes.minSize;
  52419. // Prioritize min size if conflict to make sure bubbles are
  52420. // always visible. #5873
  52421. series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
  52422. // Find the min and max Z
  52423. zData = series.zData.filter(isNumber);
  52424. if (zData.length) { // #1735
  52425. zMin = pick(seriesOptions.zMin, clamp(arrayMin(zData), seriesOptions.displayNegative === false ?
  52426. seriesOptions.zThreshold :
  52427. -Number.MAX_VALUE, zMin));
  52428. zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
  52429. }
  52430. }
  52431. }
  52432. });
  52433. activeSeries.forEach(function (series) {
  52434. var data = series[dataKey],
  52435. i = data.length,
  52436. radius;
  52437. if (isXAxis) {
  52438. series.getRadii(zMin, zMax, series);
  52439. }
  52440. if (range > 0) {
  52441. while (i--) {
  52442. if (isNumber(data[i]) &&
  52443. axis.dataMin <= data[i] &&
  52444. data[i] <= axis.max) {
  52445. radius = series.radii ? series.radii[i] : 0;
  52446. pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
  52447. pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
  52448. }
  52449. }
  52450. }
  52451. });
  52452. // Apply the padding to the min and max properties
  52453. if (activeSeries.length && range > 0 && !this.logarithmic) {
  52454. pxMax -= axisLength;
  52455. transA *= (axisLength +
  52456. Math.max(0, pxMin) - // #8901
  52457. Math.min(pxMax, axisLength)) / axisLength;
  52458. [
  52459. ['min', 'userMin', pxMin],
  52460. ['max', 'userMax', pxMax]
  52461. ].forEach(function (keys) {
  52462. if (typeof pick(axis.options[keys[0]], axis[keys[1]]) === 'undefined') {
  52463. axis[keys[0]] += keys[2] / transA;
  52464. }
  52465. });
  52466. }
  52467. /* eslint-enable valid-jsdoc */
  52468. };
  52469. SeriesRegistry.registerSeriesType('bubble', BubbleSeries);
  52470. /* *
  52471. *
  52472. * Default Export
  52473. *
  52474. * */
  52475. /* *
  52476. *
  52477. * API Declarations
  52478. *
  52479. * */
  52480. /**
  52481. * @typedef {"area"|"width"} Highcharts.BubbleSizeByValue
  52482. */
  52483. ''; // detach doclets above
  52484. /* *
  52485. *
  52486. * API Options
  52487. *
  52488. * */
  52489. /**
  52490. * A `bubble` series. If the [type](#series.bubble.type) option is
  52491. * not specified, it is inherited from [chart.type](#chart.type).
  52492. *
  52493. * @extends series,plotOptions.bubble
  52494. * @excluding dataParser, dataURL, stack
  52495. * @product highcharts highstock
  52496. * @requires highcharts-more
  52497. * @apioption series.bubble
  52498. */
  52499. /**
  52500. * An array of data points for the series. For the `bubble` series type,
  52501. * points can be given in the following ways:
  52502. *
  52503. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  52504. * to `x,y,z`. If the first value is a string, it is applied as the name of
  52505. * the point, and the `x` value is inferred. The `x` value can also be
  52506. * omitted, in which case the inner arrays should be of length 2\. Then the
  52507. * `x` value is automatically calculated, either starting at 0 and
  52508. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  52509. * series options.
  52510. * ```js
  52511. * data: [
  52512. * [0, 1, 2],
  52513. * [1, 5, 5],
  52514. * [2, 0, 2]
  52515. * ]
  52516. * ```
  52517. *
  52518. * 2. An array of objects with named values. The following snippet shows only a
  52519. * few settings, see the complete options set below. If the total number of
  52520. * data points exceeds the series'
  52521. * [turboThreshold](#series.bubble.turboThreshold), this option is not
  52522. * available.
  52523. * ```js
  52524. * data: [{
  52525. * x: 1,
  52526. * y: 1,
  52527. * z: 1,
  52528. * name: "Point2",
  52529. * color: "#00FF00"
  52530. * }, {
  52531. * x: 1,
  52532. * y: 5,
  52533. * z: 4,
  52534. * name: "Point1",
  52535. * color: "#FF00FF"
  52536. * }]
  52537. * ```
  52538. *
  52539. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  52540. * Arrays of numeric x and y
  52541. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  52542. * Arrays of datetime x and y
  52543. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  52544. * Arrays of point.name and y
  52545. * @sample {highcharts} highcharts/series/data-array-of-objects/
  52546. * Config objects
  52547. *
  52548. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  52549. * @extends series.line.data
  52550. * @product highcharts
  52551. * @apioption series.bubble.data
  52552. */
  52553. /**
  52554. * @extends series.line.data.marker
  52555. * @excluding enabledThreshold, height, radius, width
  52556. * @product highcharts
  52557. * @apioption series.bubble.data.marker
  52558. */
  52559. /**
  52560. * The size value for each bubble. The bubbles' diameters are computed
  52561. * based on the `z`, and controlled by series options like `minSize`,
  52562. * `maxSize`, `sizeBy`, `zMin` and `zMax`.
  52563. *
  52564. * @type {number|null}
  52565. * @product highcharts
  52566. * @apioption series.bubble.data.z
  52567. */
  52568. /**
  52569. * @excluding enabled, enabledThreshold, height, radius, width
  52570. * @apioption series.bubble.marker
  52571. */
  52572. ''; // adds doclets above to transpiled file
  52573. return BubbleSeries;
  52574. });
  52575. _registerModule(_modules, 'Series/MapBubble/MapBubblePoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  52576. /* *
  52577. *
  52578. * (c) 2010-2021 Torstein Honsi
  52579. *
  52580. * License: www.highcharts.com/license
  52581. *
  52582. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  52583. *
  52584. * */
  52585. var __extends = (this && this.__extends) || (function () {
  52586. var extendStatics = function (d,
  52587. b) {
  52588. extendStatics = Object.setPrototypeOf ||
  52589. ({ __proto__: [] } instanceof Array && function (d,
  52590. b) { d.__proto__ = b; }) ||
  52591. function (d,
  52592. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  52593. return extendStatics(d, b);
  52594. };
  52595. return function (d, b) {
  52596. extendStatics(d, b);
  52597. function __() { this.constructor = d; }
  52598. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  52599. };
  52600. })();
  52601. var _a = SeriesRegistry.seriesTypes,
  52602. BubbleSeries = _a.bubble,
  52603. MapSeries = _a.map;
  52604. var extend = U.extend,
  52605. merge = U.merge;
  52606. /* *
  52607. *
  52608. * Class
  52609. *
  52610. * */
  52611. var MapBubblePoint = /** @class */ (function (_super) {
  52612. __extends(MapBubblePoint, _super);
  52613. function MapBubblePoint() {
  52614. return _super !== null && _super.apply(this, arguments) || this;
  52615. }
  52616. /* *
  52617. *
  52618. * Functions
  52619. *
  52620. * */
  52621. /* eslint-disable valid-jsdoc */
  52622. /**
  52623. * @private
  52624. */
  52625. MapBubblePoint.prototype.applyOptions = function (options, x) {
  52626. var point;
  52627. if (options &&
  52628. typeof options.lat !== 'undefined' &&
  52629. typeof options.lon !== 'undefined') {
  52630. point = _super.prototype.applyOptions.call(this, merge(options, this.series.chart.fromLatLonToPoint(options)), x);
  52631. }
  52632. else {
  52633. point = MapSeries.prototype.pointClass.prototype
  52634. .applyOptions.call(this, options, x);
  52635. }
  52636. return point;
  52637. };
  52638. /**
  52639. * @private
  52640. */
  52641. MapBubblePoint.prototype.isValid = function () {
  52642. return typeof this.z === 'number';
  52643. };
  52644. return MapBubblePoint;
  52645. }(BubbleSeries.prototype.pointClass));
  52646. extend(MapBubblePoint.prototype, {
  52647. ttBelow: false
  52648. });
  52649. /* *
  52650. *
  52651. * Default Export
  52652. *
  52653. * */
  52654. return MapBubblePoint;
  52655. });
  52656. _registerModule(_modules, 'Series/MapBubble/MapBubbleSeries.js', [_modules['Series/Bubble/BubbleSeries.js'], _modules['Series/MapBubble/MapBubblePoint.js'], _modules['Series/Map/MapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (BubbleSeries, MapBubblePoint, MapSeries, SeriesRegistry, U) {
  52657. /* *
  52658. *
  52659. * (c) 2010-2021 Torstein Honsi
  52660. *
  52661. * License: www.highcharts.com/license
  52662. *
  52663. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  52664. *
  52665. * */
  52666. var __extends = (this && this.__extends) || (function () {
  52667. var extendStatics = function (d,
  52668. b) {
  52669. extendStatics = Object.setPrototypeOf ||
  52670. ({ __proto__: [] } instanceof Array && function (d,
  52671. b) { d.__proto__ = b; }) ||
  52672. function (d,
  52673. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  52674. return extendStatics(d, b);
  52675. };
  52676. return function (d, b) {
  52677. extendStatics(d, b);
  52678. function __() { this.constructor = d; }
  52679. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  52680. };
  52681. })();
  52682. var extend = U.extend,
  52683. merge = U.merge;
  52684. /* *
  52685. *
  52686. * Class
  52687. *
  52688. * */
  52689. /**
  52690. * @private
  52691. * @class
  52692. * @name Highcharts.seriesTypes.mapbubble
  52693. *
  52694. * @augments Highcharts.Series
  52695. */
  52696. var MapBubbleSeries = /** @class */ (function (_super) {
  52697. __extends(MapBubbleSeries, _super);
  52698. function MapBubbleSeries() {
  52699. /* *
  52700. *
  52701. * Static Properties
  52702. *
  52703. * */
  52704. var _this = _super !== null && _super.apply(this,
  52705. arguments) || this;
  52706. /* *
  52707. *
  52708. * Properties
  52709. *
  52710. * */
  52711. _this.data = void 0;
  52712. _this.options = void 0;
  52713. _this.points = void 0;
  52714. return _this;
  52715. }
  52716. /**
  52717. * A map bubble series is a bubble series laid out on top of a map
  52718. * series, where each bubble is tied to a specific map area.
  52719. *
  52720. * @sample maps/demo/map-bubble/
  52721. * Map bubble chart
  52722. *
  52723. * @extends plotOptions.bubble
  52724. * @product highmaps
  52725. * @optionparent plotOptions.mapbubble
  52726. */
  52727. MapBubbleSeries.defaultOptions = merge(BubbleSeries.defaultOptions, {
  52728. /**
  52729. * The main color of the series. This color affects both the fill
  52730. * and the stroke of the bubble. For enhanced control, use `marker`
  52731. * options.
  52732. *
  52733. * @sample {highmaps} maps/plotoptions/mapbubble-color/
  52734. * Pink bubbles
  52735. *
  52736. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  52737. * @apioption plotOptions.mapbubble.color
  52738. */
  52739. /**
  52740. * Whether to display negative sized bubbles. The threshold is
  52741. * given by the [zThreshold](#plotOptions.mapbubble.zThreshold)
  52742. * option, and negative bubbles can be visualized by setting
  52743. * [negativeColor](#plotOptions.bubble.negativeColor).
  52744. *
  52745. * @type {boolean}
  52746. * @default true
  52747. * @apioption plotOptions.mapbubble.displayNegative
  52748. */
  52749. /**
  52750. * @sample {highmaps} maps/demo/map-bubble/
  52751. * Bubble size
  52752. *
  52753. * @apioption plotOptions.mapbubble.maxSize
  52754. */
  52755. /**
  52756. * @sample {highmaps} maps/demo/map-bubble/
  52757. * Bubble size
  52758. *
  52759. * @apioption plotOptions.mapbubble.minSize
  52760. */
  52761. /**
  52762. * When a point's Z value is below the
  52763. * [zThreshold](#plotOptions.mapbubble.zThreshold) setting, this
  52764. * color is used.
  52765. *
  52766. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  52767. * Negative color below a threshold
  52768. *
  52769. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  52770. * @apioption plotOptions.mapbubble.negativeColor
  52771. */
  52772. /**
  52773. * Whether the bubble's value should be represented by the area or
  52774. * the width of the bubble. The default, `area`, corresponds best to
  52775. * the human perception of the size of each bubble.
  52776. *
  52777. * @type {Highcharts.BubbleSizeByValue}
  52778. * @default area
  52779. * @apioption plotOptions.mapbubble.sizeBy
  52780. */
  52781. /**
  52782. * When this is true, the absolute value of z determines the size
  52783. * of the bubble. This means that with the default `zThreshold` of
  52784. * 0, a bubble of value -1 will have the same size as a bubble of
  52785. * value 1, while a bubble of value 0 will have a smaller size
  52786. * according to `minSize`.
  52787. *
  52788. * @sample {highmaps} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  52789. * Size by absolute value, various thresholds
  52790. *
  52791. * @type {boolean}
  52792. * @default false
  52793. * @since 1.1.9
  52794. * @apioption plotOptions.mapbubble.sizeByAbsoluteValue
  52795. */
  52796. /**
  52797. * The minimum for the Z value range. Defaults to the highest Z
  52798. * value in the data.
  52799. *
  52800. * @see [zMax](#plotOptions.mapbubble.zMin)
  52801. *
  52802. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  52803. * Z has a possible range of 0-100
  52804. *
  52805. * @type {number}
  52806. * @since 1.0.3
  52807. * @apioption plotOptions.mapbubble.zMax
  52808. */
  52809. /**
  52810. * The minimum for the Z value range. Defaults to the lowest Z value
  52811. * in the data.
  52812. *
  52813. * @see [zMax](#plotOptions.mapbubble.zMax)
  52814. *
  52815. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  52816. * Z has a possible range of 0-100
  52817. *
  52818. * @type {number}
  52819. * @since 1.0.3
  52820. * @apioption plotOptions.mapbubble.zMin
  52821. */
  52822. /**
  52823. * When [displayNegative](#plotOptions.mapbubble.displayNegative)
  52824. * is `false`, bubbles with lower Z values are skipped. When
  52825. * `displayNegative` is `true` and a
  52826. * [negativeColor](#plotOptions.mapbubble.negativeColor) is given,
  52827. * points with lower Z is colored.
  52828. *
  52829. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  52830. * Negative color below a threshold
  52831. *
  52832. * @type {number}
  52833. * @default 0
  52834. * @apioption plotOptions.mapbubble.zThreshold
  52835. */
  52836. animationLimit: 500,
  52837. tooltip: {
  52838. pointFormat: '{point.name}: {point.z}'
  52839. }
  52840. });
  52841. return MapBubbleSeries;
  52842. }(BubbleSeries));
  52843. extend(MapBubbleSeries.prototype, {
  52844. type: 'mapbubble',
  52845. getBox: MapSeries.prototype.getBox,
  52846. // If one single value is passed, it is interpreted as z
  52847. pointArrayMap: ['z'],
  52848. pointClass: MapBubblePoint,
  52849. setData: MapSeries.prototype.setData,
  52850. setOptions: MapSeries.prototype.setOptions,
  52851. xyFromShape: true
  52852. });
  52853. SeriesRegistry.registerSeriesType('mapbubble', MapBubbleSeries);
  52854. /* *
  52855. *
  52856. * Default Export
  52857. *
  52858. * */
  52859. /* *
  52860. *
  52861. * API Options
  52862. *
  52863. * */
  52864. /**
  52865. * A `mapbubble` series. If the [type](#series.mapbubble.type) option
  52866. * is not specified, it is inherited from [chart.type](#chart.type).
  52867. *
  52868. * @extends series,plotOptions.mapbubble
  52869. * @excluding dataParser, dataURL
  52870. * @product highmaps
  52871. * @apioption series.mapbubble
  52872. */
  52873. /**
  52874. * An array of data points for the series. For the `mapbubble` series
  52875. * type, points can be given in the following ways:
  52876. *
  52877. * 1. An array of numerical values. In this case, the numerical values
  52878. * will be interpreted as `z` options. Example:
  52879. *
  52880. * ```js
  52881. * data: [0, 5, 3, 5]
  52882. * ```
  52883. *
  52884. * 2. An array of objects with named values. The following snippet shows only a
  52885. * few settings, see the complete options set below. If the total number of
  52886. * data points exceeds the series'
  52887. * [turboThreshold](#series.mapbubble.turboThreshold),
  52888. * this option is not available.
  52889. *
  52890. * ```js
  52891. * data: [{
  52892. * z: 9,
  52893. * name: "Point2",
  52894. * color: "#00FF00"
  52895. * }, {
  52896. * z: 10,
  52897. * name: "Point1",
  52898. * color: "#FF00FF"
  52899. * }]
  52900. * ```
  52901. *
  52902. * @type {Array<number|null|*>}
  52903. * @extends series.mappoint.data
  52904. * @excluding labelrank, middleX, middleY, path, value, x, y, lat, lon
  52905. * @product highmaps
  52906. * @apioption series.mapbubble.data
  52907. */
  52908. /**
  52909. * While the `x` and `y` values of the bubble are determined by the
  52910. * underlying map, the `z` indicates the actual value that gives the
  52911. * size of the bubble.
  52912. *
  52913. * @sample {highmaps} maps/demo/map-bubble/
  52914. * Bubble
  52915. *
  52916. * @type {number|null}
  52917. * @product highmaps
  52918. * @apioption series.mapbubble.data.z
  52919. */
  52920. /**
  52921. * @excluding enabled, enabledThreshold, height, radius, width
  52922. * @apioption series.mapbubble.marker
  52923. */
  52924. ''; // adds doclets above to transpiled file
  52925. return MapBubbleSeries;
  52926. });
  52927. _registerModule(_modules, 'Series/Heatmap/HeatmapPoint.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, SeriesRegistry, U) {
  52928. /* *
  52929. *
  52930. * (c) 2010-2021 Torstein Honsi
  52931. *
  52932. * License: www.highcharts.com/license
  52933. *
  52934. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  52935. *
  52936. * */
  52937. var __extends = (this && this.__extends) || (function () {
  52938. var extendStatics = function (d,
  52939. b) {
  52940. extendStatics = Object.setPrototypeOf ||
  52941. ({ __proto__: [] } instanceof Array && function (d,
  52942. b) { d.__proto__ = b; }) ||
  52943. function (d,
  52944. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  52945. return extendStatics(d, b);
  52946. };
  52947. return function (d, b) {
  52948. extendStatics(d, b);
  52949. function __() { this.constructor = d; }
  52950. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  52951. };
  52952. })();
  52953. var colorMapPointMixin = ColorMapMixin.colorMapPointMixin;
  52954. var ScatterPoint = SeriesRegistry.seriesTypes.scatter.prototype.pointClass;
  52955. var clamp = U.clamp,
  52956. extend = U.extend,
  52957. pick = U.pick;
  52958. /* *
  52959. *
  52960. * Class
  52961. *
  52962. * */
  52963. var HeatmapPoint = /** @class */ (function (_super) {
  52964. __extends(HeatmapPoint, _super);
  52965. function HeatmapPoint() {
  52966. /* *
  52967. *
  52968. * Properties
  52969. *
  52970. * */
  52971. var _this = _super !== null && _super.apply(this,
  52972. arguments) || this;
  52973. _this.options = void 0;
  52974. _this.series = void 0;
  52975. _this.value = void 0;
  52976. _this.x = void 0;
  52977. _this.y = void 0;
  52978. return _this;
  52979. /* eslint-enable valid-jsdoc */
  52980. }
  52981. /* *
  52982. *
  52983. * Functions
  52984. *
  52985. * */
  52986. /* eslint-disable valid-jsdoc */
  52987. /**
  52988. * @private
  52989. */
  52990. HeatmapPoint.prototype.applyOptions = function (options, x) {
  52991. var point = _super.prototype.applyOptions.call(this,
  52992. options,
  52993. x);
  52994. point.formatPrefix = point.isNull || point.value === null ? 'null' : 'point';
  52995. return point;
  52996. };
  52997. HeatmapPoint.prototype.getCellAttributes = function () {
  52998. var point = this,
  52999. series = point.series,
  53000. seriesOptions = series.options,
  53001. xPad = (seriesOptions.colsize || 1) / 2,
  53002. yPad = (seriesOptions.rowsize || 1) / 2,
  53003. xAxis = series.xAxis,
  53004. yAxis = series.yAxis,
  53005. markerOptions = point.options.marker || series.options.marker,
  53006. pointPlacement = series.pointPlacementToXValue(), // #7860
  53007. pointPadding = pick(point.pointPadding,
  53008. seriesOptions.pointPadding, 0),
  53009. cellAttr = {
  53010. x1: clamp(Math.round(xAxis.len -
  53011. (xAxis.translate(point.x - xPad,
  53012. false,
  53013. true,
  53014. false,
  53015. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  53016. x2: clamp(Math.round(xAxis.len -
  53017. (xAxis.translate(point.x + xPad,
  53018. false,
  53019. true,
  53020. false,
  53021. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  53022. y1: clamp(Math.round((yAxis.translate(point.y - yPad,
  53023. false,
  53024. true,
  53025. false,
  53026. true) || 0)), -yAxis.len, 2 * yAxis.len),
  53027. y2: clamp(Math.round((yAxis.translate(point.y + yPad,
  53028. false,
  53029. true,
  53030. false,
  53031. true) || 0)), -yAxis.len, 2 * yAxis.len)
  53032. };
  53033. // Handle marker's fixed width, and height values including border
  53034. // and pointPadding while calculating cell attributes.
  53035. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  53036. var prop = dimension[0],
  53037. direction = dimension[1];
  53038. var start = direction + '1', end = direction + '2';
  53039. var side = Math.abs(cellAttr[start] - cellAttr[end]),
  53040. borderWidth = markerOptions &&
  53041. markerOptions.lineWidth || 0,
  53042. plotPos = Math.abs(cellAttr[start] + cellAttr[end]) / 2;
  53043. if (markerOptions[prop] &&
  53044. markerOptions[prop] < side) {
  53045. cellAttr[start] = plotPos - (markerOptions[prop] / 2) -
  53046. (borderWidth / 2);
  53047. cellAttr[end] = plotPos + (markerOptions[prop] / 2) +
  53048. (borderWidth / 2);
  53049. }
  53050. // Handle pointPadding
  53051. if (pointPadding) {
  53052. if (direction === 'y') {
  53053. start = end;
  53054. end = direction + '1';
  53055. }
  53056. cellAttr[start] += pointPadding;
  53057. cellAttr[end] -= pointPadding;
  53058. }
  53059. });
  53060. return cellAttr;
  53061. };
  53062. /**
  53063. * @private
  53064. */
  53065. HeatmapPoint.prototype.haloPath = function (size) {
  53066. if (!size) {
  53067. return [];
  53068. }
  53069. var rect = this.shapeArgs;
  53070. return [
  53071. 'M',
  53072. rect.x - size,
  53073. rect.y - size,
  53074. 'L',
  53075. rect.x - size,
  53076. rect.y + rect.height + size,
  53077. rect.x + rect.width + size,
  53078. rect.y + rect.height + size,
  53079. rect.x + rect.width + size,
  53080. rect.y - size,
  53081. 'Z'
  53082. ];
  53083. };
  53084. /**
  53085. * Color points have a value option that determines whether or not it is
  53086. * a null point
  53087. * @private
  53088. */
  53089. HeatmapPoint.prototype.isValid = function () {
  53090. // undefined is allowed
  53091. return (this.value !== Infinity &&
  53092. this.value !== -Infinity);
  53093. };
  53094. return HeatmapPoint;
  53095. }(ScatterPoint));
  53096. extend(HeatmapPoint.prototype, {
  53097. dataLabelOnNull: colorMapPointMixin.dataLabelOnNull,
  53098. moveToTopOnHover: colorMapPointMixin.moveToTopOnHover
  53099. });
  53100. /* *
  53101. *
  53102. * Default Export
  53103. *
  53104. * */
  53105. return HeatmapPoint;
  53106. });
  53107. _registerModule(_modules, 'Series/Heatmap/HeatmapSeries.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Globals.js'], _modules['Series/Heatmap/HeatmapPoint.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, H, HeatmapPoint, LegendSymbolMixin, palette, SeriesRegistry, SVGRenderer, U) {
  53108. /* *
  53109. *
  53110. * (c) 2010-2021 Torstein Honsi
  53111. *
  53112. * License: www.highcharts.com/license
  53113. *
  53114. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53115. *
  53116. * */
  53117. var __extends = (this && this.__extends) || (function () {
  53118. var extendStatics = function (d,
  53119. b) {
  53120. extendStatics = Object.setPrototypeOf ||
  53121. ({ __proto__: [] } instanceof Array && function (d,
  53122. b) { d.__proto__ = b; }) ||
  53123. function (d,
  53124. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53125. return extendStatics(d, b);
  53126. };
  53127. return function (d, b) {
  53128. extendStatics(d, b);
  53129. function __() { this.constructor = d; }
  53130. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53131. };
  53132. })();
  53133. var colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  53134. var noop = H.noop;
  53135. var Series = SeriesRegistry.series,
  53136. _a = SeriesRegistry.seriesTypes,
  53137. ColumnSeries = _a.column,
  53138. ScatterSeries = _a.scatter;
  53139. var symbols = SVGRenderer.prototype.symbols;
  53140. var extend = U.extend,
  53141. fireEvent = U.fireEvent,
  53142. isNumber = U.isNumber,
  53143. merge = U.merge,
  53144. pick = U.pick;
  53145. /* *
  53146. *
  53147. * Class
  53148. *
  53149. * */
  53150. /**
  53151. * @private
  53152. * @class
  53153. * @name Highcharts.seriesTypes.heatmap
  53154. *
  53155. * @augments Highcharts.Series
  53156. */
  53157. var HeatmapSeries = /** @class */ (function (_super) {
  53158. __extends(HeatmapSeries, _super);
  53159. function HeatmapSeries() {
  53160. /* *
  53161. *
  53162. * Static Properties
  53163. *
  53164. * */
  53165. var _this = _super !== null && _super.apply(this,
  53166. arguments) || this;
  53167. /* *
  53168. *
  53169. * Properties
  53170. *
  53171. * */
  53172. _this.colorAxis = void 0;
  53173. _this.data = void 0;
  53174. _this.options = void 0;
  53175. _this.points = void 0;
  53176. _this.valueMax = NaN;
  53177. _this.valueMin = NaN;
  53178. return _this;
  53179. /* eslint-enable valid-jsdoc */
  53180. }
  53181. /* *
  53182. *
  53183. * Functions
  53184. *
  53185. * */
  53186. /* eslint-disable valid-jsdoc */
  53187. /**
  53188. * @private
  53189. */
  53190. HeatmapSeries.prototype.drawPoints = function () {
  53191. var _this = this;
  53192. // In styled mode, use CSS, otherwise the fill used in the style
  53193. // sheet will take precedence over the fill attribute.
  53194. var seriesMarkerOptions = this.options.marker || {};
  53195. if (seriesMarkerOptions.enabled || this._hasPointMarkers) {
  53196. Series.prototype.drawPoints.call(this);
  53197. this.points.forEach(function (point) {
  53198. point.graphic &&
  53199. point.graphic[_this.chart.styledMode ? 'css' : 'animate'](_this.colorAttribs(point));
  53200. });
  53201. }
  53202. };
  53203. /**
  53204. * @private
  53205. */
  53206. HeatmapSeries.prototype.getExtremes = function () {
  53207. // Get the extremes from the value data
  53208. var _a = Series.prototype.getExtremes
  53209. .call(this,
  53210. this.valueData),
  53211. dataMin = _a.dataMin,
  53212. dataMax = _a.dataMax;
  53213. if (isNumber(dataMin)) {
  53214. this.valueMin = dataMin;
  53215. }
  53216. if (isNumber(dataMax)) {
  53217. this.valueMax = dataMax;
  53218. }
  53219. // Get the extremes from the y data
  53220. return Series.prototype.getExtremes.call(this);
  53221. };
  53222. /**
  53223. * Override to also allow null points, used when building the k-d-tree for
  53224. * tooltips in boost mode.
  53225. * @private
  53226. */
  53227. HeatmapSeries.prototype.getValidPoints = function (points, insideOnly) {
  53228. return Series.prototype.getValidPoints.call(this, points, insideOnly, true);
  53229. };
  53230. /**
  53231. * Define hasData function for non-cartesian series. Returns true if the
  53232. * series has points at all.
  53233. * @private
  53234. */
  53235. HeatmapSeries.prototype.hasData = function () {
  53236. return !!this.processedXData.length; // != 0
  53237. };
  53238. /**
  53239. * Override the init method to add point ranges on both axes.
  53240. * @private
  53241. */
  53242. HeatmapSeries.prototype.init = function () {
  53243. var options;
  53244. Series.prototype.init.apply(this, arguments);
  53245. options = this.options;
  53246. // #3758, prevent resetting in setData
  53247. options.pointRange = pick(options.pointRange, options.colsize || 1);
  53248. // general point range
  53249. this.yAxis.axisPointRange = options.rowsize || 1;
  53250. // Bind new symbol names
  53251. extend(symbols, {
  53252. ellipse: symbols.circle
  53253. });
  53254. };
  53255. /**
  53256. * @private
  53257. */
  53258. HeatmapSeries.prototype.markerAttribs = function (point, state) {
  53259. var pointMarkerOptions = point.marker || {},
  53260. seriesMarkerOptions = this.options.marker || {},
  53261. seriesStateOptions,
  53262. pointStateOptions,
  53263. shapeArgs = point.shapeArgs || {},
  53264. hasImage = point.hasImage,
  53265. attribs = {};
  53266. if (hasImage) {
  53267. return {
  53268. x: point.plotX,
  53269. y: point.plotY
  53270. };
  53271. }
  53272. // Setting width and height attributes on image does not affect
  53273. // on its dimensions.
  53274. if (state) {
  53275. seriesStateOptions = seriesMarkerOptions.states[state] || {};
  53276. pointStateOptions = pointMarkerOptions.states &&
  53277. pointMarkerOptions.states[state] || {};
  53278. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  53279. // Set new width and height basing on state options.
  53280. attribs[dimension[0]] = (pointStateOptions[dimension[0]] ||
  53281. seriesStateOptions[dimension[0]] ||
  53282. shapeArgs[dimension[0]]) + (pointStateOptions[dimension[0] + 'Plus'] ||
  53283. seriesStateOptions[dimension[0] + 'Plus'] || 0);
  53284. // Align marker by a new size.
  53285. attribs[dimension[1]] =
  53286. shapeArgs[dimension[1]] +
  53287. (shapeArgs[dimension[0]] -
  53288. attribs[dimension[0]]) / 2;
  53289. });
  53290. }
  53291. return state ? attribs : shapeArgs;
  53292. };
  53293. /**
  53294. * @private
  53295. */
  53296. HeatmapSeries.prototype.pointAttribs = function (point, state) {
  53297. var series = this,
  53298. attr = Series.prototype.pointAttribs.call(series,
  53299. point,
  53300. state),
  53301. seriesOptions = series.options || {},
  53302. plotOptions = series.chart.options.plotOptions || {},
  53303. seriesPlotOptions = plotOptions.series || {},
  53304. heatmapPlotOptions = plotOptions.heatmap || {},
  53305. stateOptions,
  53306. brightness,
  53307. // Get old properties in order to keep backward compatibility
  53308. borderColor = seriesOptions.borderColor ||
  53309. heatmapPlotOptions.borderColor ||
  53310. seriesPlotOptions.borderColor,
  53311. borderWidth = seriesOptions.borderWidth ||
  53312. heatmapPlotOptions.borderWidth ||
  53313. seriesPlotOptions.borderWidth ||
  53314. attr['stroke-width'];
  53315. // Apply lineColor, or set it to default series color.
  53316. attr.stroke = ((point && point.marker && point.marker.lineColor) ||
  53317. (seriesOptions.marker && seriesOptions.marker.lineColor) ||
  53318. borderColor ||
  53319. this.color);
  53320. // Apply old borderWidth property if exists.
  53321. attr['stroke-width'] = borderWidth;
  53322. if (state) {
  53323. stateOptions =
  53324. merge(seriesOptions.states[state], seriesOptions.marker &&
  53325. seriesOptions.marker.states[state], point &&
  53326. point.options.states &&
  53327. point.options.states[state] || {});
  53328. brightness = stateOptions.brightness;
  53329. attr.fill =
  53330. stateOptions.color ||
  53331. H.color(attr.fill).brighten(brightness || 0).get();
  53332. attr.stroke = stateOptions.lineColor;
  53333. }
  53334. return attr;
  53335. };
  53336. /**
  53337. * @private
  53338. */
  53339. HeatmapSeries.prototype.setClip = function (animation) {
  53340. var series = this,
  53341. chart = series.chart;
  53342. Series.prototype.setClip.apply(series, arguments);
  53343. if (series.options.clip !== false || animation) {
  53344. series.markerGroup
  53345. .clip((animation || series.clipBox) && series.sharedClipKey ?
  53346. chart.sharedClips[series.sharedClipKey] :
  53347. chart.clipRect);
  53348. }
  53349. };
  53350. /**
  53351. * @private
  53352. */
  53353. HeatmapSeries.prototype.translate = function () {
  53354. var series = this, options = series.options, symbol = options.marker && options.marker.symbol || '', shape = symbols[symbol] ? symbol : 'rect', hasRegularShape = ['circle', 'square'].indexOf(shape) !== -1;
  53355. series.generatePoints();
  53356. series.points.forEach(function (point) {
  53357. var pointAttr,
  53358. sizeDiff,
  53359. hasImage,
  53360. cellAttr = point.getCellAttributes(),
  53361. shapeArgs = {};
  53362. shapeArgs.x = Math.min(cellAttr.x1, cellAttr.x2);
  53363. shapeArgs.y = Math.min(cellAttr.y1, cellAttr.y2);
  53364. shapeArgs.width = Math.max(Math.abs(cellAttr.x2 - cellAttr.x1), 0);
  53365. shapeArgs.height = Math.max(Math.abs(cellAttr.y2 - cellAttr.y1), 0);
  53366. hasImage = point.hasImage =
  53367. (point.marker && point.marker.symbol || symbol || '')
  53368. .indexOf('url') === 0;
  53369. // If marker shape is regular (symetric), find shorter
  53370. // cell's side.
  53371. if (hasRegularShape) {
  53372. sizeDiff = Math.abs(shapeArgs.width - shapeArgs.height);
  53373. shapeArgs.x = Math.min(cellAttr.x1, cellAttr.x2) +
  53374. (shapeArgs.width < shapeArgs.height ? 0 : sizeDiff / 2);
  53375. shapeArgs.y = Math.min(cellAttr.y1, cellAttr.y2) +
  53376. (shapeArgs.width < shapeArgs.height ? sizeDiff / 2 : 0);
  53377. shapeArgs.width = shapeArgs.height =
  53378. Math.min(shapeArgs.width, shapeArgs.height);
  53379. }
  53380. pointAttr = {
  53381. plotX: (cellAttr.x1 + cellAttr.x2) / 2,
  53382. plotY: (cellAttr.y1 + cellAttr.y2) / 2,
  53383. clientX: (cellAttr.x1 + cellAttr.x2) / 2,
  53384. shapeType: 'path',
  53385. shapeArgs: merge(true, shapeArgs, {
  53386. d: symbols[shape](shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height)
  53387. })
  53388. };
  53389. if (hasImage) {
  53390. point.marker = {
  53391. width: shapeArgs.width,
  53392. height: shapeArgs.height
  53393. };
  53394. }
  53395. extend(point, pointAttr);
  53396. });
  53397. fireEvent(series, 'afterTranslate');
  53398. };
  53399. /**
  53400. * A heatmap is a graphical representation of data where the individual
  53401. * values contained in a matrix are represented as colors.
  53402. *
  53403. * @productdesc {highcharts}
  53404. * Requires `modules/heatmap`.
  53405. *
  53406. * @sample highcharts/demo/heatmap/
  53407. * Simple heatmap
  53408. * @sample highcharts/demo/heatmap-canvas/
  53409. * Heavy heatmap
  53410. *
  53411. * @extends plotOptions.scatter
  53412. * @excluding animationLimit, connectEnds, connectNulls, cropThreshold,
  53413. * dashStyle, findNearestPointBy, getExtremesFromAll, jitter,
  53414. * linecap, lineWidth, pointInterval, pointIntervalUnit,
  53415. * pointRange, pointStart, shadow, softThreshold, stacking,
  53416. * step, threshold, cluster
  53417. * @product highcharts highmaps
  53418. * @optionparent plotOptions.heatmap
  53419. */
  53420. HeatmapSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  53421. /**
  53422. * Animation is disabled by default on the heatmap series.
  53423. */
  53424. animation: false,
  53425. /**
  53426. * The border width for each heat map item.
  53427. */
  53428. borderWidth: 0,
  53429. /**
  53430. * Padding between the points in the heatmap.
  53431. *
  53432. * @type {number}
  53433. * @default 0
  53434. * @since 6.0
  53435. * @apioption plotOptions.heatmap.pointPadding
  53436. */
  53437. /**
  53438. * @default value
  53439. * @apioption plotOptions.heatmap.colorKey
  53440. */
  53441. /**
  53442. * The main color of the series. In heat maps this color is rarely used,
  53443. * as we mostly use the color to denote the value of each point. Unless
  53444. * options are set in the [colorAxis](#colorAxis), the default value
  53445. * is pulled from the [options.colors](#colors) array.
  53446. *
  53447. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53448. * @since 4.0
  53449. * @product highcharts
  53450. * @apioption plotOptions.heatmap.color
  53451. */
  53452. /**
  53453. * The column size - how many X axis units each column in the heatmap
  53454. * should span.
  53455. *
  53456. * @sample {highcharts} maps/demo/heatmap/
  53457. * One day
  53458. * @sample {highmaps} maps/demo/heatmap/
  53459. * One day
  53460. *
  53461. * @type {number}
  53462. * @default 1
  53463. * @since 4.0
  53464. * @product highcharts highmaps
  53465. * @apioption plotOptions.heatmap.colsize
  53466. */
  53467. /**
  53468. * The row size - how many Y axis units each heatmap row should span.
  53469. *
  53470. * @sample {highcharts} maps/demo/heatmap/
  53471. * 1 by default
  53472. * @sample {highmaps} maps/demo/heatmap/
  53473. * 1 by default
  53474. *
  53475. * @type {number}
  53476. * @default 1
  53477. * @since 4.0
  53478. * @product highcharts highmaps
  53479. * @apioption plotOptions.heatmap.rowsize
  53480. */
  53481. /**
  53482. * The color applied to null points. In styled mode, a general CSS class
  53483. * is applied instead.
  53484. *
  53485. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53486. */
  53487. nullColor: palette.neutralColor3,
  53488. dataLabels: {
  53489. formatter: function () {
  53490. return this.point.value;
  53491. },
  53492. inside: true,
  53493. verticalAlign: 'middle',
  53494. crop: false,
  53495. overflow: false,
  53496. padding: 0 // #3837
  53497. },
  53498. /**
  53499. * @excluding radius, enabledThreshold
  53500. * @since 8.1
  53501. */
  53502. marker: {
  53503. /**
  53504. * A predefined shape or symbol for the marker. When undefined, the
  53505. * symbol is pulled from options.symbols. Other possible values are
  53506. * `'circle'`, `'square'`,`'diamond'`, `'triangle'`,
  53507. * `'triangle-down'`, `'rect'`, and `'ellipse'`.
  53508. *
  53509. * Additionally, the URL to a graphic can be given on this form:
  53510. * `'url(graphic.png)'`. Note that for the image to be applied to
  53511. * exported charts, its URL needs to be accessible by the export
  53512. * server.
  53513. *
  53514. * Custom callbacks for symbol path generation can also be added to
  53515. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  53516. * used by its method name, as shown in the demo.
  53517. *
  53518. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  53519. * Predefined, graphic and custom markers
  53520. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  53521. * Predefined, graphic and custom markers
  53522. */
  53523. symbol: 'rect',
  53524. /** @ignore-option */
  53525. radius: 0,
  53526. lineColor: void 0,
  53527. states: {
  53528. /**
  53529. * @excluding radius, radiusPlus
  53530. */
  53531. hover: {
  53532. /**
  53533. * Set the marker's fixed width on hover state.
  53534. *
  53535. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53536. * 70px fixed marker's width and height on hover
  53537. *
  53538. * @type {number|undefined}
  53539. * @default undefined
  53540. * @product highcharts highmaps
  53541. * @apioption plotOptions.heatmap.marker.states.hover.width
  53542. */
  53543. /**
  53544. * Set the marker's fixed height on hover state.
  53545. *
  53546. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53547. * 70px fixed marker's width and height on hover
  53548. *
  53549. * @type {number|undefined}
  53550. * @default undefined
  53551. * @product highcharts highmaps
  53552. * @apioption plotOptions.heatmap.marker.states.hover.height
  53553. */
  53554. /**
  53555. * The number of pixels to increase the width of the
  53556. * selected point.
  53557. *
  53558. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53559. * 20px greater width and height on hover
  53560. *
  53561. * @type {number|undefined}
  53562. * @default undefined
  53563. * @product highcharts highmaps
  53564. * @apioption plotOptions.heatmap.marker.states.hover.widthPlus
  53565. */
  53566. /**
  53567. * The number of pixels to increase the height of the
  53568. * selected point.
  53569. *
  53570. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53571. * 20px greater width and height on hover
  53572. *
  53573. * @type {number|undefined}
  53574. * @default undefined
  53575. * @product highcharts highmaps
  53576. * @apioption plotOptions.heatmap.marker.states.hover.heightPlus
  53577. */
  53578. /**
  53579. * The additional line width for a hovered point.
  53580. *
  53581. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  53582. * 5 pixels wider lineWidth on hover
  53583. * @sample {highmaps} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  53584. * 5 pixels wider lineWidth on hover
  53585. */
  53586. lineWidthPlus: 0
  53587. },
  53588. /**
  53589. * @excluding radius
  53590. */
  53591. select: {
  53592. /**
  53593. * Set the marker's fixed width on select state.
  53594. *
  53595. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53596. * 70px fixed marker's width and height on hover
  53597. *
  53598. * @type {number|undefined}
  53599. * @default undefined
  53600. * @product highcharts highmaps
  53601. * @apioption plotOptions.heatmap.marker.states.select.width
  53602. */
  53603. /**
  53604. * Set the marker's fixed height on select state.
  53605. *
  53606. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53607. * 70px fixed marker's width and height on hover
  53608. *
  53609. * @type {number|undefined}
  53610. * @default undefined
  53611. * @product highcharts highmaps
  53612. * @apioption plotOptions.heatmap.marker.states.select.height
  53613. */
  53614. /**
  53615. * The number of pixels to increase the width of the
  53616. * selected point.
  53617. *
  53618. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53619. * 20px greater width and height on hover
  53620. *
  53621. * @type {number|undefined}
  53622. * @default undefined
  53623. * @product highcharts highmaps
  53624. * @apioption plotOptions.heatmap.marker.states.select.widthPlus
  53625. */
  53626. /**
  53627. * The number of pixels to increase the height of the
  53628. * selected point.
  53629. *
  53630. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53631. * 20px greater width and height on hover
  53632. *
  53633. * @type {number|undefined}
  53634. * @default undefined
  53635. * @product highcharts highmaps
  53636. * @apioption plotOptions.heatmap.marker.states.select.heightPlus
  53637. */
  53638. }
  53639. }
  53640. },
  53641. clip: true,
  53642. /** @ignore-option */
  53643. pointRange: null,
  53644. tooltip: {
  53645. pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
  53646. },
  53647. states: {
  53648. hover: {
  53649. /** @ignore-option */
  53650. halo: false,
  53651. /**
  53652. * How much to brighten the point on interaction. Requires the
  53653. * main color to be defined in hex or rgb(a) format.
  53654. *
  53655. * In styled mode, the hover brightening is by default replaced
  53656. * with a fill-opacity set in the `.highcharts-point:hover`
  53657. * rule.
  53658. */
  53659. brightness: 0.2
  53660. }
  53661. }
  53662. });
  53663. return HeatmapSeries;
  53664. }(ScatterSeries));
  53665. extend(HeatmapSeries.prototype, {
  53666. /**
  53667. * @private
  53668. */
  53669. alignDataLabel: ColumnSeries.prototype.alignDataLabel,
  53670. axisTypes: colorMapSeriesMixin.axisTypes,
  53671. colorAttribs: colorMapSeriesMixin.colorAttribs,
  53672. colorKey: colorMapSeriesMixin.colorKey,
  53673. directTouch: true,
  53674. /**
  53675. * @private
  53676. */
  53677. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  53678. getExtremesFromAll: true,
  53679. getSymbol: Series.prototype.getSymbol,
  53680. parallelArrays: colorMapSeriesMixin.parallelArrays,
  53681. pointArrayMap: ['y', 'value'],
  53682. pointClass: HeatmapPoint,
  53683. trackerGroups: colorMapSeriesMixin.trackerGroups
  53684. });
  53685. SeriesRegistry.registerSeriesType('heatmap', HeatmapSeries);
  53686. /* *
  53687. *
  53688. * Default Export
  53689. *
  53690. * */
  53691. /* *
  53692. *
  53693. * API Declarations
  53694. *
  53695. * */
  53696. /**
  53697. * Heatmap series only. Padding between the points in the heatmap.
  53698. * @name Highcharts.Point#pointPadding
  53699. * @type {number|undefined}
  53700. */
  53701. /**
  53702. * Heatmap series only. The value of the point, resulting in a color
  53703. * controled by options as set in the colorAxis configuration.
  53704. * @name Highcharts.Point#value
  53705. * @type {number|null|undefined}
  53706. */
  53707. /* *
  53708. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  53709. */ /**
  53710. * Heatmap series only. Point padding for a single point.
  53711. * @name Highcharts.PointOptionsObject#pointPadding
  53712. * @type {number|undefined}
  53713. */ /**
  53714. * Heatmap series only. The value of the point, resulting in a color controled
  53715. * by options as set in the colorAxis configuration.
  53716. * @name Highcharts.PointOptionsObject#value
  53717. * @type {number|null|undefined}
  53718. */
  53719. ''; // detach doclets above
  53720. /* *
  53721. *
  53722. * API Options
  53723. *
  53724. * */
  53725. /**
  53726. * A `heatmap` series. If the [type](#series.heatmap.type) option is
  53727. * not specified, it is inherited from [chart.type](#chart.type).
  53728. *
  53729. * @productdesc {highcharts}
  53730. * Requires `modules/heatmap`.
  53731. *
  53732. * @extends series,plotOptions.heatmap
  53733. * @excluding cropThreshold, dataParser, dataURL, pointRange, stack,
  53734. * @product highcharts highmaps
  53735. * @apioption series.heatmap
  53736. */
  53737. /**
  53738. * An array of data points for the series. For the `heatmap` series
  53739. * type, points can be given in the following ways:
  53740. *
  53741. * 1. An array of arrays with 3 or 2 values. In this case, the values
  53742. * correspond to `x,y,value`. If the first value is a string, it is
  53743. * applied as the name of the point, and the `x` value is inferred.
  53744. * The `x` value can also be omitted, in which case the inner arrays
  53745. * should be of length 2\. Then the `x` value is automatically calculated,
  53746. * either starting at 0 and incremented by 1, or from `pointStart`
  53747. * and `pointInterval` given in the series options.
  53748. *
  53749. * ```js
  53750. * data: [
  53751. * [0, 9, 7],
  53752. * [1, 10, 4],
  53753. * [2, 6, 3]
  53754. * ]
  53755. * ```
  53756. *
  53757. * 2. An array of objects with named values. The following snippet shows only a
  53758. * few settings, see the complete options set below. If the total number of data
  53759. * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
  53760. * this option is not available.
  53761. *
  53762. * ```js
  53763. * data: [{
  53764. * x: 1,
  53765. * y: 3,
  53766. * value: 10,
  53767. * name: "Point2",
  53768. * color: "#00FF00"
  53769. * }, {
  53770. * x: 1,
  53771. * y: 7,
  53772. * value: 10,
  53773. * name: "Point1",
  53774. * color: "#FF00FF"
  53775. * }]
  53776. * ```
  53777. *
  53778. * @sample {highcharts} highcharts/chart/reflow-true/
  53779. * Numerical values
  53780. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  53781. * Arrays of numeric x and y
  53782. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  53783. * Arrays of datetime x and y
  53784. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  53785. * Arrays of point.name and y
  53786. * @sample {highcharts} highcharts/series/data-array-of-objects/
  53787. * Config objects
  53788. *
  53789. * @type {Array<Array<number>|*>}
  53790. * @extends series.line.data
  53791. * @product highcharts highmaps
  53792. * @apioption series.heatmap.data
  53793. */
  53794. /**
  53795. * The color of the point. In heat maps the point color is rarely set
  53796. * explicitly, as we use the color to denote the `value`. Options for
  53797. * this are set in the [colorAxis](#colorAxis) configuration.
  53798. *
  53799. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53800. * @product highcharts highmaps
  53801. * @apioption series.heatmap.data.color
  53802. */
  53803. /**
  53804. * The value of the point, resulting in a color controled by options
  53805. * as set in the [colorAxis](#colorAxis) configuration.
  53806. *
  53807. * @type {number}
  53808. * @product highcharts highmaps
  53809. * @apioption series.heatmap.data.value
  53810. */
  53811. /**
  53812. * The x value of the point. For datetime axes,
  53813. * the X value is the timestamp in milliseconds since 1970.
  53814. *
  53815. * @type {number}
  53816. * @product highcharts highmaps
  53817. * @apioption series.heatmap.data.x
  53818. */
  53819. /**
  53820. * The y value of the point.
  53821. *
  53822. * @type {number}
  53823. * @product highcharts highmaps
  53824. * @apioption series.heatmap.data.y
  53825. */
  53826. /**
  53827. * Point padding for a single point.
  53828. *
  53829. * @sample maps/plotoptions/tilemap-pointpadding
  53830. * Point padding on tiles
  53831. *
  53832. * @type {number}
  53833. * @product highcharts highmaps
  53834. * @apioption series.heatmap.data.pointPadding
  53835. */
  53836. /**
  53837. * @excluding radius, enabledThreshold
  53838. * @product highcharts highmaps
  53839. * @since 8.1
  53840. * @apioption series.heatmap.data.marker
  53841. */
  53842. /**
  53843. * @excluding radius, enabledThreshold
  53844. * @product highcharts highmaps
  53845. * @since 8.1
  53846. * @apioption series.heatmap.marker
  53847. */
  53848. /**
  53849. * @excluding radius, radiusPlus
  53850. * @product highcharts highmaps
  53851. * @apioption series.heatmap.marker.states.hover
  53852. */
  53853. /**
  53854. * @excluding radius
  53855. * @product highcharts highmaps
  53856. * @apioption series.heatmap.marker.states.select
  53857. */
  53858. /**
  53859. * @excluding radius, radiusPlus
  53860. * @product highcharts highmaps
  53861. * @apioption series.heatmap.data.marker.states.hover
  53862. */
  53863. /**
  53864. * @excluding radius
  53865. * @product highcharts highmaps
  53866. * @apioption series.heatmap.data.marker.states.select
  53867. */
  53868. /**
  53869. * Set the marker's fixed width on hover state.
  53870. *
  53871. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  53872. * 5 pixels wider lineWidth on hover
  53873. *
  53874. * @type {number|undefined}
  53875. * @default 0
  53876. * @product highcharts highmaps
  53877. * @apioption series.heatmap.marker.states.hover.lineWidthPlus
  53878. */
  53879. /**
  53880. * Set the marker's fixed width on hover state.
  53881. *
  53882. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53883. * 70px fixed marker's width and height on hover
  53884. *
  53885. * @type {number|undefined}
  53886. * @default undefined
  53887. * @product highcharts highmaps
  53888. * @apioption series.heatmap.marker.states.hover.width
  53889. */
  53890. /**
  53891. * Set the marker's fixed height on hover state.
  53892. *
  53893. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53894. * 70px fixed marker's width and height on hover
  53895. *
  53896. * @type {number|undefined}
  53897. * @default undefined
  53898. * @product highcharts highmaps
  53899. * @apioption series.heatmap.marker.states.hover.height
  53900. */
  53901. /**
  53902. * The number of pixels to increase the width of the
  53903. * hovered point.
  53904. *
  53905. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53906. * One day
  53907. *
  53908. * @type {number|undefined}
  53909. * @default undefined
  53910. * @product highcharts highmaps
  53911. * @apioption series.heatmap.marker.states.hover.widthPlus
  53912. */
  53913. /**
  53914. * The number of pixels to increase the height of the
  53915. * hovered point.
  53916. *
  53917. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53918. * One day
  53919. *
  53920. * @type {number|undefined}
  53921. * @default undefined
  53922. * @product highcharts highmaps
  53923. * @apioption series.heatmap.marker.states.hover.heightPlus
  53924. */
  53925. /**
  53926. * The number of pixels to increase the width of the
  53927. * hovered point.
  53928. *
  53929. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53930. * One day
  53931. *
  53932. * @type {number|undefined}
  53933. * @default undefined
  53934. * @product highcharts highmaps
  53935. * @apioption series.heatmap.marker.states.select.widthPlus
  53936. */
  53937. /**
  53938. * The number of pixels to increase the height of the
  53939. * hovered point.
  53940. *
  53941. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53942. * One day
  53943. *
  53944. * @type {number|undefined}
  53945. * @default undefined
  53946. * @product highcharts highmaps
  53947. * @apioption series.heatmap.marker.states.select.heightPlus
  53948. */
  53949. /**
  53950. * Set the marker's fixed width on hover state.
  53951. *
  53952. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  53953. * 5 pixels wider lineWidth on hover
  53954. *
  53955. * @type {number|undefined}
  53956. * @default 0
  53957. * @product highcharts highmaps
  53958. * @apioption series.heatmap.data.marker.states.hover.lineWidthPlus
  53959. */
  53960. /**
  53961. * Set the marker's fixed width on hover state.
  53962. *
  53963. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53964. * 70px fixed marker's width and height on hover
  53965. *
  53966. * @type {number|undefined}
  53967. * @default undefined
  53968. * @product highcharts highmaps
  53969. * @apioption series.heatmap.data.marker.states.hover.width
  53970. */
  53971. /**
  53972. * Set the marker's fixed height on hover state.
  53973. *
  53974. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  53975. * 70px fixed marker's width and height on hover
  53976. *
  53977. * @type {number|undefined}
  53978. * @default undefined
  53979. * @product highcharts highmaps
  53980. * @apioption series.heatmap.data.marker.states.hover.height
  53981. */
  53982. /**
  53983. * The number of pixels to increase the width of the
  53984. * hovered point.
  53985. *
  53986. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53987. * One day
  53988. *
  53989. * @type {number|undefined}
  53990. * @default undefined
  53991. * @product highcharts highstock
  53992. * @apioption series.heatmap.data.marker.states.hover.widthPlus
  53993. */
  53994. /**
  53995. * The number of pixels to increase the height of the
  53996. * hovered point.
  53997. *
  53998. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  53999. * One day
  54000. *
  54001. * @type {number|undefined}
  54002. * @default undefined
  54003. * @product highcharts highstock
  54004. * @apioption series.heatmap.data.marker.states.hover.heightPlus
  54005. */
  54006. /**
  54007. * Set the marker's fixed width on select state.
  54008. *
  54009. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  54010. * 70px fixed marker's width and height on hover
  54011. *
  54012. * @type {number|undefined}
  54013. * @default undefined
  54014. * @product highcharts highmaps
  54015. * @apioption series.heatmap.data.marker.states.select.width
  54016. */
  54017. /**
  54018. * Set the marker's fixed height on select state.
  54019. *
  54020. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  54021. * 70px fixed marker's width and height on hover
  54022. *
  54023. * @type {number|undefined}
  54024. * @default undefined
  54025. * @product highcharts highmaps
  54026. * @apioption series.heatmap.data.marker.states.select.height
  54027. */
  54028. /**
  54029. * The number of pixels to increase the width of the
  54030. * hovered point.
  54031. *
  54032. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  54033. * One day
  54034. *
  54035. * @type {number|undefined}
  54036. * @default undefined
  54037. * @product highcharts highstock
  54038. * @apioption series.heatmap.data.marker.states.select.widthPlus
  54039. */
  54040. /**
  54041. * The number of pixels to increase the height of the
  54042. * hovered point.
  54043. *
  54044. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  54045. * One day
  54046. *
  54047. * @type {number|undefined}
  54048. * @default undefined
  54049. * @product highcharts highstock
  54050. * @apioption series.heatmap.data.marker.states.select.heightPlus
  54051. */
  54052. ''; // adds doclets above to transpiled file
  54053. return HeatmapSeries;
  54054. });
  54055. _registerModule(_modules, 'Extensions/GeoJSON.js', [_modules['Core/Chart/Chart.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, F, H, U) {
  54056. /* *
  54057. *
  54058. * (c) 2010-2021 Torstein Honsi
  54059. *
  54060. * License: www.highcharts.com/license
  54061. *
  54062. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  54063. *
  54064. * */
  54065. var format = F.format;
  54066. var win = H.win;
  54067. var error = U.error,
  54068. extend = U.extend,
  54069. merge = U.merge,
  54070. wrap = U.wrap;
  54071. /**
  54072. * Represents the loose structure of a geographic JSON file.
  54073. *
  54074. * @interface Highcharts.GeoJSON
  54075. */ /**
  54076. * Full copyright note of the geographic data.
  54077. * @name Highcharts.GeoJSON#copyright
  54078. * @type {string|undefined}
  54079. */ /**
  54080. * Short copyright note of the geographic data suitable for watermarks.
  54081. * @name Highcharts.GeoJSON#copyrightShort
  54082. * @type {string|undefined}
  54083. */ /**
  54084. * Additional meta information based on the coordinate reference system.
  54085. * @name Highcharts.GeoJSON#crs
  54086. * @type {Highcharts.Dictionary<any>|undefined}
  54087. */ /**
  54088. * Data sets of geographic features.
  54089. * @name Highcharts.GeoJSON#features
  54090. * @type {Array<Highcharts.GeoJSONFeature>}
  54091. */ /**
  54092. * Map projections and transformations to be used when calculating between
  54093. * lat/lon and chart values. Required for lat/lon support on maps. Allows
  54094. * resizing, rotating, and moving portions of a map within its projected
  54095. * coordinate system while still retaining lat/lon support. If using lat/lon
  54096. * on a portion of the map that does not match a `hitZone`, the definition with
  54097. * the key `default` is used.
  54098. * @name Highcharts.GeoJSON#hc-transform
  54099. * @type {Highcharts.Dictionary<Highcharts.GeoJSONTranslation>|undefined}
  54100. */ /**
  54101. * Title of the geographic data.
  54102. * @name Highcharts.GeoJSON#title
  54103. * @type {string|undefined}
  54104. */ /**
  54105. * Type of the geographic data. Type of an optimized map collection is
  54106. * `FeatureCollection`.
  54107. * @name Highcharts.GeoJSON#type
  54108. * @type {string|undefined}
  54109. */ /**
  54110. * Version of the geographic data.
  54111. * @name Highcharts.GeoJSON#version
  54112. * @type {string|undefined}
  54113. */
  54114. /**
  54115. * Data set of a geographic feature.
  54116. * @interface Highcharts.GeoJSONFeature
  54117. * @extends Highcharts.Dictionary<*>
  54118. */ /**
  54119. * Data type of the geographic feature.
  54120. * @name Highcharts.GeoJSONFeature#type
  54121. * @type {string}
  54122. */
  54123. /**
  54124. * Describes the map projection and transformations applied to a portion of
  54125. * a map.
  54126. * @interface Highcharts.GeoJSONTranslation
  54127. */ /**
  54128. * The coordinate reference system used to generate this portion of the map.
  54129. * @name Highcharts.GeoJSONTranslation#crs
  54130. * @type {string}
  54131. */ /**
  54132. * Define the portion of the map that this defintion applies to. Defined as a
  54133. * GeoJSON polygon feature object, with `type` and `coordinates` properties.
  54134. * @name Highcharts.GeoJSONTranslation#hitZone
  54135. * @type {Highcharts.Dictionary<*>|undefined}
  54136. */ /**
  54137. * Property for internal use for maps generated by Highsoft.
  54138. * @name Highcharts.GeoJSONTranslation#jsonmarginX
  54139. * @type {number|undefined}
  54140. */ /**
  54141. * Property for internal use for maps generated by Highsoft.
  54142. * @name Highcharts.GeoJSONTranslation#jsonmarginY
  54143. * @type {number|undefined}
  54144. */ /**
  54145. * Property for internal use for maps generated by Highsoft.
  54146. * @name Highcharts.GeoJSONTranslation#jsonres
  54147. * @type {number|undefined}
  54148. */ /**
  54149. * Specifies clockwise rotation of the coordinates after the projection, but
  54150. * before scaling and panning. Defined in radians, relative to the coordinate
  54151. * system origin.
  54152. * @name Highcharts.GeoJSONTranslation#rotation
  54153. * @type {number|undefined}
  54154. */ /**
  54155. * The scaling factor applied to the projected coordinates.
  54156. * @name Highcharts.GeoJSONTranslation#scale
  54157. * @type {number|undefined}
  54158. */ /**
  54159. * Property for internal use for maps generated by Highsoft.
  54160. * @name Highcharts.GeoJSONTranslation#xoffset
  54161. * @type {number|undefined}
  54162. */ /**
  54163. * X offset of projected coordinates after scaling.
  54164. * @name Highcharts.GeoJSONTranslation#xpan
  54165. * @type {number|undefined}
  54166. */ /**
  54167. * Property for internal use for maps generated by Highsoft.
  54168. * @name Highcharts.GeoJSONTranslation#yoffset
  54169. * @type {number|undefined}
  54170. */ /**
  54171. * Y offset of projected coordinates after scaling.
  54172. * @name Highcharts.GeoJSONTranslation#ypan
  54173. * @type {number|undefined}
  54174. */
  54175. /**
  54176. * Result object of a map transformation.
  54177. *
  54178. * @interface Highcharts.MapCoordinateObject
  54179. */ /**
  54180. * X coordinate on the map.
  54181. * @name Highcharts.MapCoordinateObject#x
  54182. * @type {number}
  54183. */ /**
  54184. * Y coordinate on the map.
  54185. * @name Highcharts.MapCoordinateObject#y
  54186. * @type {number|null}
  54187. */
  54188. /**
  54189. * A latitude/longitude object.
  54190. *
  54191. * @interface Highcharts.MapLatLonObject
  54192. */ /**
  54193. * The latitude.
  54194. * @name Highcharts.MapLatLonObject#lat
  54195. * @type {number}
  54196. */ /**
  54197. * The longitude.
  54198. * @name Highcharts.MapLatLonObject#lon
  54199. * @type {number}
  54200. */
  54201. ''; // detach doclets above
  54202. /* eslint-disable no-invalid-this, valid-jsdoc */
  54203. /**
  54204. * Test for point in polygon. Polygon defined as array of [x,y] points.
  54205. * @private
  54206. */
  54207. function pointInPolygon(point, polygon) {
  54208. var i,
  54209. j,
  54210. rel1,
  54211. rel2,
  54212. c = false,
  54213. x = point.x,
  54214. y = point.y;
  54215. for (i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
  54216. rel1 = polygon[i][1] > y;
  54217. rel2 = polygon[j][1] > y;
  54218. if (rel1 !== rel2 &&
  54219. (x < (polygon[j][0] -
  54220. polygon[i][0]) * (y - polygon[i][1]) /
  54221. (polygon[j][1] - polygon[i][1]) +
  54222. polygon[i][0])) {
  54223. c = !c;
  54224. }
  54225. }
  54226. return c;
  54227. }
  54228. /**
  54229. * Highmaps only. Get point from latitude and longitude using specified
  54230. * transform definition.
  54231. *
  54232. * @requires modules/map
  54233. *
  54234. * @sample maps/series/latlon-transform/
  54235. * Use specific transformation for lat/lon
  54236. *
  54237. * @function Highcharts.Chart#transformFromLatLon
  54238. *
  54239. * @param {Highcharts.MapLatLonObject} latLon
  54240. * A latitude/longitude object.
  54241. *
  54242. * @param {*} transform
  54243. * The transform definition to use as explained in the
  54244. * {@link https://www.highcharts.com/docs/maps/latlon|documentation}.
  54245. *
  54246. * @return {Highcharts.MapCoordinateObject}
  54247. * An object with `x` and `y` properties.
  54248. */
  54249. Chart.prototype.transformFromLatLon = function (latLon, transform) {
  54250. /**
  54251. * Allows to manually load the proj4 library from Highcharts options
  54252. * instead of the `window`.
  54253. * In case of loading the library from a `script` tag,
  54254. * this option is not needed, it will be loaded from there by default.
  54255. *
  54256. * @type {function}
  54257. * @product highmaps
  54258. * @apioption chart.proj4
  54259. */
  54260. var proj4 = (this.userOptions.chart &&
  54261. this.userOptions.chart.proj4 ||
  54262. win.proj4);
  54263. if (!proj4) {
  54264. error(21, false, this);
  54265. return {
  54266. x: 0,
  54267. y: null
  54268. };
  54269. }
  54270. var projected = proj4(transform.crs,
  54271. [latLon.lon,
  54272. latLon.lat]),
  54273. cosAngle = transform.cosAngle ||
  54274. (transform.rotation && Math.cos(transform.rotation)),
  54275. sinAngle = transform.sinAngle ||
  54276. (transform.rotation && Math.sin(transform.rotation)),
  54277. rotated = transform.rotation ? [
  54278. projected[0] * cosAngle + projected[1] * sinAngle,
  54279. -projected[0] * sinAngle + projected[1] * cosAngle
  54280. ] : projected;
  54281. return {
  54282. x: ((rotated[0] - (transform.xoffset || 0)) * (transform.scale || 1) +
  54283. (transform.xpan || 0)) * (transform.jsonres || 1) +
  54284. (transform.jsonmarginX || 0),
  54285. y: (((transform.yoffset || 0) - rotated[1]) * (transform.scale || 1) +
  54286. (transform.ypan || 0)) * (transform.jsonres || 1) -
  54287. (transform.jsonmarginY || 0)
  54288. };
  54289. };
  54290. /**
  54291. * Highmaps only. Get latLon from point using specified transform definition.
  54292. * The method returns an object with the numeric properties `lat` and `lon`.
  54293. *
  54294. * @requires modules/map
  54295. *
  54296. * @sample maps/series/latlon-transform/
  54297. * Use specific transformation for lat/lon
  54298. *
  54299. * @function Highcharts.Chart#transformToLatLon
  54300. *
  54301. * @param {Highcharts.Point|Highcharts.MapCoordinateObject} point
  54302. * A `Point` instance, or any object containing the properties `x` and
  54303. * `y` with numeric values.
  54304. *
  54305. * @param {*} transform
  54306. * The transform definition to use as explained in the
  54307. * {@link https://www.highcharts.com/docs/maps/latlon|documentation}.
  54308. *
  54309. * @return {Highcharts.MapLatLonObject|undefined}
  54310. * An object with `lat` and `lon` properties.
  54311. */
  54312. Chart.prototype.transformToLatLon = function (point, transform) {
  54313. if (typeof win.proj4 === 'undefined') {
  54314. error(21, false, this);
  54315. return;
  54316. }
  54317. var normalized = {
  54318. x: ((point.x -
  54319. (transform.jsonmarginX || 0)) / (transform.jsonres || 1) -
  54320. (transform.xpan || 0)) / (transform.scale || 1) +
  54321. (transform.xoffset || 0),
  54322. y: ((-point.y - (transform.jsonmarginY || 0)) / (transform.jsonres || 1) +
  54323. (transform.ypan || 0)) / (transform.scale || 1) +
  54324. (transform.yoffset || 0)
  54325. },
  54326. cosAngle = transform.cosAngle ||
  54327. (transform.rotation && Math.cos(transform.rotation)),
  54328. sinAngle = transform.sinAngle ||
  54329. (transform.rotation && Math.sin(transform.rotation)),
  54330. // Note: Inverted sinAngle to reverse rotation direction
  54331. projected = win.proj4(transform.crs, 'WGS84',
  54332. transform.rotation ? {
  54333. x: normalized.x * cosAngle + normalized.y * -sinAngle,
  54334. y: normalized.x * sinAngle + normalized.y * cosAngle
  54335. } : normalized);
  54336. return { lat: projected.y, lon: projected.x };
  54337. };
  54338. /**
  54339. * Highmaps only. Calculate latitude/longitude values for a point. Returns an
  54340. * object with the numeric properties `lat` and `lon`.
  54341. *
  54342. * @requires modules/map
  54343. *
  54344. * @sample maps/demo/latlon-advanced/
  54345. * Advanced lat/lon demo
  54346. *
  54347. * @function Highcharts.Chart#fromPointToLatLon
  54348. *
  54349. * @param {Highcharts.Point|Highcharts.MapCoordinateObject} point
  54350. * A `Point` instance or anything containing `x` and `y` properties with
  54351. * numeric values.
  54352. *
  54353. * @return {Highcharts.MapLatLonObject|undefined}
  54354. * An object with `lat` and `lon` properties.
  54355. */
  54356. Chart.prototype.fromPointToLatLon = function (point) {
  54357. var transforms = this.mapTransforms,
  54358. transform;
  54359. if (!transforms) {
  54360. error(22, false, this);
  54361. return;
  54362. }
  54363. for (transform in transforms) {
  54364. if (Object.hasOwnProperty.call(transforms, transform) &&
  54365. transforms[transform].hitZone &&
  54366. pointInPolygon({ x: point.x, y: -point.y }, transforms[transform].hitZone.coordinates[0])) {
  54367. return this.transformToLatLon(point, transforms[transform]);
  54368. }
  54369. }
  54370. return this.transformToLatLon(point, transforms['default'] // eslint-disable-line dot-notation
  54371. );
  54372. };
  54373. /**
  54374. * Highmaps only. Get chart coordinates from latitude/longitude. Returns an
  54375. * object with x and y values corresponding to the `xAxis` and `yAxis`.
  54376. *
  54377. * @requires modules/map
  54378. *
  54379. * @sample maps/series/latlon-to-point/
  54380. * Find a point from lat/lon
  54381. *
  54382. * @function Highcharts.Chart#fromLatLonToPoint
  54383. *
  54384. * @param {Highcharts.MapLatLonObject} latLon
  54385. * Coordinates.
  54386. *
  54387. * @return {Highcharts.MapCoordinateObject}
  54388. * X and Y coordinates in terms of chart axis values.
  54389. */
  54390. Chart.prototype.fromLatLonToPoint = function (latLon) {
  54391. var transforms = this.mapTransforms,
  54392. transform,
  54393. coords;
  54394. if (!transforms) {
  54395. error(22, false, this);
  54396. return {
  54397. x: 0,
  54398. y: null
  54399. };
  54400. }
  54401. for (transform in transforms) {
  54402. if (Object.hasOwnProperty.call(transforms, transform) &&
  54403. transforms[transform].hitZone) {
  54404. coords = this.transformFromLatLon(latLon, transforms[transform]);
  54405. if (pointInPolygon({ x: coords.x, y: -coords.y }, transforms[transform].hitZone.coordinates[0])) {
  54406. return coords;
  54407. }
  54408. }
  54409. }
  54410. return this.transformFromLatLon(latLon, transforms['default'] // eslint-disable-line dot-notation
  54411. );
  54412. };
  54413. /**
  54414. * Highmaps only. Restructure a GeoJSON object in preparation to be read
  54415. * directly by the
  54416. * {@link https://api.highcharts.com/highmaps/plotOptions.series.mapData|series.mapData}
  54417. * option. The GeoJSON will be broken down to fit a specific Highcharts type,
  54418. * either `map`, `mapline` or `mappoint`. Meta data in GeoJSON's properties
  54419. * object will be copied directly over to {@link Point.properties} in Highmaps.
  54420. *
  54421. * @requires modules/map
  54422. *
  54423. * @sample maps/demo/geojson/
  54424. * Simple areas
  54425. * @sample maps/demo/geojson-multiple-types/
  54426. * Multiple types
  54427. *
  54428. * @function Highcharts.geojson
  54429. *
  54430. * @param {Highcharts.GeoJSON} geojson
  54431. * The GeoJSON structure to parse, represented as a JavaScript object
  54432. * rather than a JSON string.
  54433. *
  54434. * @param {string} [hType=map]
  54435. * The Highmaps series type to prepare for. Setting "map" will return
  54436. * GeoJSON polygons and multipolygons. Setting "mapline" will return
  54437. * GeoJSON linestrings and multilinestrings. Setting "mappoint" will
  54438. * return GeoJSON points and multipoints.
  54439. *
  54440. * @return {Array<*>}
  54441. * An object ready for the `mapData` option.
  54442. */
  54443. H.geojson = function (geojson, hType, series) {
  54444. var mapData = [],
  54445. path = [],
  54446. polygonToPath = function (polygon) {
  54447. polygon.forEach(function (point,
  54448. i) {
  54449. if (i === 0) {
  54450. path.push(['M',
  54451. point[0], -point[1]]);
  54452. }
  54453. else {
  54454. path.push(['L', point[0], -point[1]]);
  54455. }
  54456. });
  54457. };
  54458. hType = hType || 'map';
  54459. geojson.features.forEach(function (feature) {
  54460. var geometry = feature.geometry,
  54461. type = geometry.type,
  54462. coordinates = geometry.coordinates,
  54463. properties = feature.properties,
  54464. point;
  54465. path = [];
  54466. if (hType === 'map' || hType === 'mapbubble') {
  54467. if (type === 'Polygon') {
  54468. coordinates.forEach(polygonToPath);
  54469. path.push(['Z']);
  54470. }
  54471. else if (type === 'MultiPolygon') {
  54472. coordinates.forEach(function (items) {
  54473. items.forEach(polygonToPath);
  54474. });
  54475. path.push(['Z']);
  54476. }
  54477. if (path.length) {
  54478. point = { path: path };
  54479. }
  54480. }
  54481. else if (hType === 'mapline') {
  54482. if (type === 'LineString') {
  54483. polygonToPath(coordinates);
  54484. }
  54485. else if (type === 'MultiLineString') {
  54486. coordinates.forEach(polygonToPath);
  54487. }
  54488. if (path.length) {
  54489. point = { path: path };
  54490. }
  54491. }
  54492. else if (hType === 'mappoint') {
  54493. if (type === 'Point') {
  54494. point = {
  54495. x: coordinates[0],
  54496. y: -coordinates[1]
  54497. };
  54498. }
  54499. }
  54500. if (point) {
  54501. mapData.push(extend(point, {
  54502. name: properties.name || properties.NAME,
  54503. /**
  54504. * In Highmaps, when data is loaded from GeoJSON, the GeoJSON
  54505. * item's properies are copied over here.
  54506. *
  54507. * @requires modules/map
  54508. * @name Highcharts.Point#properties
  54509. * @type {*}
  54510. */
  54511. properties: properties
  54512. }));
  54513. }
  54514. });
  54515. // Create a credits text that includes map source, to be picked up in
  54516. // Chart.addCredits
  54517. if (series && geojson.copyrightShort) {
  54518. series.chart.mapCredits = format(series.chart.options.credits.mapText, { geojson: geojson });
  54519. series.chart.mapCreditsFull = format(series.chart.options.credits.mapTextFull, { geojson: geojson });
  54520. }
  54521. return mapData;
  54522. };
  54523. // Override addCredits to include map source by default
  54524. wrap(Chart.prototype, 'addCredits', function (proceed, credits) {
  54525. credits = merge(true, this.options.credits, credits);
  54526. // Disable credits link if map credits enabled. This to allow for in-text
  54527. // anchors.
  54528. if (this.mapCredits) {
  54529. credits.href = null;
  54530. }
  54531. proceed.call(this, credits);
  54532. // Add full map credits to hover
  54533. if (this.credits && this.mapCreditsFull) {
  54534. this.credits.attr({
  54535. title: this.mapCreditsFull
  54536. });
  54537. }
  54538. });
  54539. });
  54540. _registerModule(_modules, 'masters/modules/map.src.js', [_modules['Core/Globals.js'], _modules['Core/Chart/MapChart.js']], function (Highcharts, MapChart) {
  54541. Highcharts.MapChart = MapChart;
  54542. Highcharts.mapChart = Highcharts.Map = MapChart.mapChart;
  54543. Highcharts.maps = MapChart.maps;
  54544. });
  54545. _registerModule(_modules, 'masters/highmaps.src.js', [_modules['masters/highcharts.src.js']], function (Highcharts) {
  54546. Highcharts.product = 'Highmaps';
  54547. return Highcharts;
  54548. });
  54549. _modules['masters/highmaps.src.js']._modules = _modules;
  54550. return _modules['masters/highmaps.src.js'];
  54551. }));