accessibility.src.js 334 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635
  1. /**
  2. * @license Highcharts JS v8.2.0 (2020-08-20)
  3. *
  4. * Accessibility module
  5. *
  6. * (c) 2010-2019 Highsoft AS
  7. * Author: Oystein Moseng
  8. *
  9. * License: www.highcharts.com/license
  10. */
  11. 'use strict';
  12. (function (factory) {
  13. if (typeof module === 'object' && module.exports) {
  14. factory['default'] = factory;
  15. module.exports = factory;
  16. } else if (typeof define === 'function' && define.amd) {
  17. define('highcharts/modules/accessibility', ['highcharts'], function (Highcharts) {
  18. factory(Highcharts);
  19. factory.Highcharts = Highcharts;
  20. return factory;
  21. });
  22. } else {
  23. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  24. }
  25. }(function (Highcharts) {
  26. var _modules = Highcharts ? Highcharts._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, 'Accessibility/Utils/HTMLUtilities.js', [_modules['Core/Utilities.js'], _modules['Core/Globals.js']], function (U, H) {
  33. /* *
  34. *
  35. * (c) 2009-2020 Øystein Moseng
  36. *
  37. * Utility functions for accessibility module.
  38. *
  39. * License: www.highcharts.com/license
  40. *
  41. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42. *
  43. * */
  44. var merge = U.merge;
  45. var win = H.win,
  46. doc = win.document;
  47. /* eslint-disable valid-jsdoc */
  48. /**
  49. * @private
  50. * @param {Highcharts.HTMLDOMElement} el
  51. * @param {string} className
  52. * @return {void}
  53. */
  54. function addClass(el, className) {
  55. if (el.classList) {
  56. el.classList.add(className);
  57. }
  58. else if (el.className.indexOf(className) < 0) {
  59. // Note: Dumb check for class name exists, should be fine for practical
  60. // use cases, but will return false positives if the element has a class
  61. // that contains the className.
  62. el.className += className;
  63. }
  64. }
  65. /**
  66. * @private
  67. * @param {string} str
  68. * @return {string}
  69. */
  70. function escapeStringForHTML(str) {
  71. return str
  72. .replace(/&/g, '&amp;')
  73. .replace(/</g, '&lt;')
  74. .replace(/>/g, '&gt;')
  75. .replace(/"/g, '&quot;')
  76. .replace(/'/g, '&#x27;')
  77. .replace(/\//g, '&#x2F;');
  78. }
  79. /**
  80. * Get an element by ID
  81. * @param {string} id
  82. * @private
  83. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|null}
  84. */
  85. function getElement(id) {
  86. return doc.getElementById(id);
  87. }
  88. /**
  89. * Get a fake mouse event of a given type
  90. * @param {string} type
  91. * @private
  92. * @return {global.MouseEvent}
  93. */
  94. function getFakeMouseEvent(type) {
  95. if (typeof win.MouseEvent === 'function') {
  96. return new win.MouseEvent(type);
  97. }
  98. // No MouseEvent support, try using initMouseEvent
  99. if (doc.createEvent) {
  100. var evt = doc.createEvent('MouseEvent');
  101. if (evt.initMouseEvent) {
  102. evt.initMouseEvent(type, true, // Bubble
  103. true, // Cancel
  104. win, // View
  105. type === 'click' ? 1 : 0, // Detail
  106. // Coords
  107. 0, 0, 0, 0,
  108. // Pressed keys
  109. false, false, false, false, 0, // button
  110. null // related target
  111. );
  112. return evt;
  113. }
  114. }
  115. return { type: type };
  116. }
  117. /**
  118. * Remove an element from the DOM.
  119. * @private
  120. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} [element]
  121. * @return {void}
  122. */
  123. function removeElement(element) {
  124. if (element && element.parentNode) {
  125. element.parentNode.removeChild(element);
  126. }
  127. }
  128. /**
  129. * Utility function. Reverses child nodes of a DOM element.
  130. * @private
  131. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} node
  132. * @return {void}
  133. */
  134. function reverseChildNodes(node) {
  135. var i = node.childNodes.length;
  136. while (i--) {
  137. node.appendChild(node.childNodes[i]);
  138. }
  139. }
  140. /**
  141. * Set attributes on element. Set to null to remove attribute.
  142. * @private
  143. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  144. * @param {Highcharts.HTMLAttributes|Highcharts.SVGAttributes} attrs
  145. * @return {void}
  146. */
  147. function setElAttrs(el, attrs) {
  148. Object.keys(attrs).forEach(function (attr) {
  149. var val = attrs[attr];
  150. if (val === null) {
  151. el.removeAttribute(attr);
  152. }
  153. else {
  154. var cleanedVal = escapeStringForHTML('' + val);
  155. el.setAttribute(attr, cleanedVal);
  156. }
  157. });
  158. }
  159. /**
  160. * Used for aria-label attributes, painting on a canvas will fail if the
  161. * text contains tags.
  162. * @private
  163. * @param {string} str
  164. * @return {string}
  165. */
  166. function stripHTMLTagsFromString(str) {
  167. return typeof str === 'string' ?
  168. str.replace(/<\/?[^>]+(>|$)/g, '') : str;
  169. }
  170. /**
  171. * Utility function for hiding an element visually, but still keeping it
  172. * available to screen reader users.
  173. * @private
  174. * @param {Highcharts.HTMLDOMElement} element
  175. * @return {void}
  176. */
  177. function visuallyHideElement(element) {
  178. var hiddenStyle = {
  179. position: 'absolute',
  180. width: '1px',
  181. height: '1px',
  182. overflow: 'hidden',
  183. whiteSpace: 'nowrap',
  184. clip: 'rect(1px, 1px, 1px, 1px)',
  185. marginTop: '-3px',
  186. '-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=1)',
  187. filter: 'alpha(opacity=1)',
  188. opacity: '0.01'
  189. };
  190. merge(true, element.style, hiddenStyle);
  191. }
  192. var HTMLUtilities = {
  193. addClass: addClass,
  194. escapeStringForHTML: escapeStringForHTML,
  195. getElement: getElement,
  196. getFakeMouseEvent: getFakeMouseEvent,
  197. removeElement: removeElement,
  198. reverseChildNodes: reverseChildNodes,
  199. setElAttrs: setElAttrs,
  200. stripHTMLTagsFromString: stripHTMLTagsFromString,
  201. visuallyHideElement: visuallyHideElement
  202. };
  203. return HTMLUtilities;
  204. });
  205. _registerModule(_modules, 'Accessibility/Utils/ChartUtilities.js', [_modules['Accessibility/Utils/HTMLUtilities.js'], _modules['Core/Utilities.js']], function (HTMLUtilities, U) {
  206. /* *
  207. *
  208. * (c) 2009-2020 Øystein Moseng
  209. *
  210. * Utils for dealing with charts.
  211. *
  212. * License: www.highcharts.com/license
  213. *
  214. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  215. *
  216. * */
  217. var stripHTMLTags = HTMLUtilities.stripHTMLTagsFromString;
  218. var defined = U.defined,
  219. find = U.find,
  220. fireEvent = U.fireEvent;
  221. /* eslint-disable valid-jsdoc */
  222. /**
  223. * @return {string}
  224. */
  225. function getChartTitle(chart) {
  226. return stripHTMLTags(chart.options.title.text ||
  227. chart.langFormat('accessibility.defaultChartTitle', { chart: chart }));
  228. }
  229. /**
  230. * @param {Highcharts.Axis} axis
  231. * @return {string}
  232. */
  233. function getAxisDescription(axis) {
  234. return stripHTMLTags(axis && (axis.userOptions && axis.userOptions.accessibility &&
  235. axis.userOptions.accessibility.description ||
  236. axis.axisTitle && axis.axisTitle.textStr ||
  237. axis.options.id ||
  238. axis.categories && 'categories' ||
  239. axis.dateTime && 'Time' ||
  240. 'values'));
  241. }
  242. /**
  243. * Get the DOM element for the first point in the series.
  244. * @private
  245. * @param {Highcharts.Series} series
  246. * The series to get element for.
  247. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|undefined}
  248. * The DOM element for the point.
  249. */
  250. function getSeriesFirstPointElement(series) {
  251. if (series.points &&
  252. series.points.length &&
  253. series.points[0].graphic) {
  254. return series.points[0].graphic.element;
  255. }
  256. }
  257. /**
  258. * Get the DOM element for the series that we put accessibility info on.
  259. * @private
  260. * @param {Highcharts.Series} series
  261. * The series to get element for.
  262. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|undefined}
  263. * The DOM element for the series
  264. */
  265. function getSeriesA11yElement(series) {
  266. var firstPointEl = getSeriesFirstPointElement(series);
  267. return (firstPointEl &&
  268. firstPointEl.parentNode || series.graph &&
  269. series.graph.element || series.group &&
  270. series.group.element); // Could be tracker series depending on series type
  271. }
  272. /**
  273. * Remove aria-hidden from element. Also unhides parents of the element, and
  274. * hides siblings that are not explicitly unhidden.
  275. * @private
  276. * @param {Highcharts.Chart} chart
  277. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} element
  278. */
  279. function unhideChartElementFromAT(chart, element) {
  280. element.setAttribute('aria-hidden', false);
  281. if (element === chart.renderTo || !element.parentNode) {
  282. return;
  283. }
  284. // Hide siblings unless their hidden state is already explicitly set
  285. Array.prototype.forEach.call(element.parentNode.childNodes, function (node) {
  286. if (!node.hasAttribute('aria-hidden')) {
  287. node.setAttribute('aria-hidden', true);
  288. }
  289. });
  290. // Repeat for parent
  291. unhideChartElementFromAT(chart, element.parentNode);
  292. }
  293. /**
  294. * Hide series from screen readers.
  295. * @private
  296. * @param {Highcharts.Series} series
  297. * The series to hide
  298. * @return {void}
  299. */
  300. function hideSeriesFromAT(series) {
  301. var seriesEl = getSeriesA11yElement(series);
  302. if (seriesEl) {
  303. seriesEl.setAttribute('aria-hidden', true);
  304. }
  305. }
  306. /**
  307. * Get series objects by series name.
  308. * @private
  309. * @param {Highcharts.Chart} chart
  310. * @param {string} name
  311. * @return {Array<Highcharts.Series>}
  312. */
  313. function getSeriesFromName(chart, name) {
  314. if (!name) {
  315. return chart.series;
  316. }
  317. return (chart.series || []).filter(function (s) {
  318. return s.name === name;
  319. });
  320. }
  321. /**
  322. * Get point in a series from x/y values.
  323. * @private
  324. * @param {Array<Highcharts.Series>} series
  325. * @param {number} x
  326. * @param {number} y
  327. * @return {Highcharts.Point|undefined}
  328. */
  329. function getPointFromXY(series, x, y) {
  330. var i = series.length,
  331. res;
  332. while (i--) {
  333. res = find(series[i].points || [], function (p) {
  334. return p.x === x && p.y === y;
  335. });
  336. if (res) {
  337. return res;
  338. }
  339. }
  340. }
  341. /**
  342. * Get relative position of point on an x/y axis from 0 to 1.
  343. * @private
  344. * @param {Highcharts.Axis} axis
  345. * @param {Highcharts.Point} point
  346. * @return {number}
  347. */
  348. function getRelativePointAxisPosition(axis, point) {
  349. if (!defined(axis.dataMin) || !defined(axis.dataMax)) {
  350. return 0;
  351. }
  352. var axisStart = axis.toPixels(axis.dataMin);
  353. var axisEnd = axis.toPixels(axis.dataMax);
  354. // We have to use pixel position because of axis breaks, log axis etc.
  355. var positionProp = axis.coll === 'xAxis' ? 'x' : 'y';
  356. var pointPos = axis.toPixels(point[positionProp] || 0);
  357. return (pointPos - axisStart) / (axisEnd - axisStart);
  358. }
  359. /**
  360. * Get relative position of point on an x/y axis from 0 to 1.
  361. * @private
  362. * @param {Highcharts.Point} point
  363. */
  364. function scrollToPoint(point) {
  365. var xAxis = point.series.xAxis;
  366. var yAxis = point.series.yAxis;
  367. var axis = (xAxis === null || xAxis === void 0 ? void 0 : xAxis.scrollbar) ? xAxis : yAxis;
  368. var scrollbar = axis === null || axis === void 0 ? void 0 : axis.scrollbar;
  369. if (scrollbar && defined(scrollbar.to) && defined(scrollbar.from)) {
  370. var range = scrollbar.to - scrollbar.from;
  371. var pos = getRelativePointAxisPosition(axis,
  372. point);
  373. scrollbar.updatePosition(pos - range / 2, pos + range / 2);
  374. fireEvent(scrollbar, 'changed', {
  375. from: scrollbar.from,
  376. to: scrollbar.to,
  377. trigger: 'scrollbar',
  378. DOMEvent: null
  379. });
  380. }
  381. }
  382. var ChartUtilities = {
  383. getChartTitle: getChartTitle,
  384. getAxisDescription: getAxisDescription,
  385. getPointFromXY: getPointFromXY,
  386. getSeriesFirstPointElement: getSeriesFirstPointElement,
  387. getSeriesFromName: getSeriesFromName,
  388. getSeriesA11yElement: getSeriesA11yElement,
  389. unhideChartElementFromAT: unhideChartElementFromAT,
  390. hideSeriesFromAT: hideSeriesFromAT,
  391. scrollToPoint: scrollToPoint
  392. };
  393. return ChartUtilities;
  394. });
  395. _registerModule(_modules, 'Accessibility/KeyboardNavigationHandler.js', [_modules['Core/Utilities.js']], function (U) {
  396. /* *
  397. *
  398. * (c) 2009-2020 Øystein Moseng
  399. *
  400. * Keyboard navigation handler base class definition
  401. *
  402. * License: www.highcharts.com/license
  403. *
  404. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  405. *
  406. * */
  407. var find = U.find;
  408. /**
  409. * Options for the keyboard navigation handler.
  410. *
  411. * @interface Highcharts.KeyboardNavigationHandlerOptionsObject
  412. */ /**
  413. * An array containing pairs of an array of keycodes, mapped to a handler
  414. * function. When the keycode is received, the handler is called with the
  415. * keycode as parameter.
  416. * @name Highcharts.KeyboardNavigationHandlerOptionsObject#keyCodeMap
  417. * @type {Array<Array<Array<number>, Function>>}
  418. */ /**
  419. * Function to run on initialization of module.
  420. * @name Highcharts.KeyboardNavigationHandlerOptionsObject#init
  421. * @type {Function}
  422. */ /**
  423. * Function to run before moving to next/prev module. Receives moving direction
  424. * as parameter: +1 for next, -1 for previous.
  425. * @name Highcharts.KeyboardNavigationHandlerOptionsObject#terminate
  426. * @type {Function|undefined}
  427. */ /**
  428. * Function to run to validate module. Should return false if module should not
  429. * run, true otherwise. Receives chart as parameter.
  430. * @name Highcharts.KeyboardNavigationHandlerOptionsObject#validate
  431. * @type {Function|undefined}
  432. */
  433. /* eslint-disable no-invalid-this, valid-jsdoc */
  434. /**
  435. * Define a keyboard navigation handler for use with a
  436. * Highcharts.AccessibilityComponent instance. This functions as an abstraction
  437. * layer for keyboard navigation, and defines a map of keyCodes to handler
  438. * functions.
  439. *
  440. * @requires module:modules/accessibility
  441. *
  442. * @sample highcharts/accessibility/custom-component
  443. * Custom accessibility component
  444. *
  445. * @class
  446. * @name Highcharts.KeyboardNavigationHandler
  447. *
  448. * @param {Highcharts.Chart} chart
  449. * The chart this module should act on.
  450. *
  451. * @param {Highcharts.KeyboardNavigationHandlerOptionsObject} options
  452. * Options for the keyboard navigation handler.
  453. */
  454. function KeyboardNavigationHandler(chart, options) {
  455. this.chart = chart;
  456. this.keyCodeMap = options.keyCodeMap || [];
  457. this.validate = options.validate;
  458. this.init = options.init;
  459. this.terminate = options.terminate;
  460. // Response enum
  461. this.response = {
  462. success: 1,
  463. prev: 2,
  464. next: 3,
  465. noHandler: 4,
  466. fail: 5 // Handler failed
  467. };
  468. }
  469. KeyboardNavigationHandler.prototype = {
  470. /**
  471. * Find handler function(s) for key code in the keyCodeMap and run it.
  472. *
  473. * @function KeyboardNavigationHandler#run
  474. * @param {global.KeyboardEvent} e
  475. * @return {number} Returns a response code indicating whether the run was
  476. * a success/fail/unhandled, or if we should move to next/prev module.
  477. */
  478. run: function (e) {
  479. var keyCode = e.which || e.keyCode,
  480. response = this.response.noHandler,
  481. handlerCodeSet = find(this.keyCodeMap,
  482. function (codeSet) {
  483. return codeSet[0].indexOf(keyCode) > -1;
  484. });
  485. if (handlerCodeSet) {
  486. response = handlerCodeSet[1].call(this, keyCode, e);
  487. }
  488. else if (keyCode === 9) {
  489. // Default tab handler, move to next/prev module
  490. response = this.response[e.shiftKey ? 'prev' : 'next'];
  491. }
  492. return response;
  493. }
  494. };
  495. return KeyboardNavigationHandler;
  496. });
  497. _registerModule(_modules, 'Accessibility/Utils/EventProvider.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  498. /* *
  499. *
  500. * (c) 2009-2020 Øystein Moseng
  501. *
  502. * Class that can keep track of events added, and clean them up on destroy.
  503. *
  504. * License: www.highcharts.com/license
  505. *
  506. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  507. *
  508. * */
  509. var addEvent = U.addEvent,
  510. extend = U.extend;
  511. /* eslint-disable no-invalid-this, valid-jsdoc */
  512. /**
  513. * @private
  514. * @class
  515. */
  516. var EventProvider = function () {
  517. this.eventRemovers = [];
  518. };
  519. extend(EventProvider.prototype, {
  520. /**
  521. * Add an event to an element and keep track of it for later removal.
  522. * Same args as Highcharts.addEvent.
  523. * @private
  524. * @return {Function}
  525. */
  526. addEvent: function () {
  527. var remover = addEvent.apply(H,
  528. arguments);
  529. this.eventRemovers.push(remover);
  530. return remover;
  531. },
  532. /**
  533. * Remove all added events.
  534. * @private
  535. * @return {void}
  536. */
  537. removeAddedEvents: function () {
  538. this.eventRemovers.forEach(function (remover) {
  539. remover();
  540. });
  541. this.eventRemovers = [];
  542. }
  543. });
  544. return EventProvider;
  545. });
  546. _registerModule(_modules, 'Accessibility/Utils/DOMElementProvider.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, U, HTMLUtilities) {
  547. /* *
  548. *
  549. * (c) 2009-2020 Øystein Moseng
  550. *
  551. * Class that can keep track of elements added to DOM and clean them up on
  552. * destroy.
  553. *
  554. * License: www.highcharts.com/license
  555. *
  556. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  557. *
  558. * */
  559. var doc = H.win.document;
  560. var extend = U.extend;
  561. var removeElement = HTMLUtilities.removeElement;
  562. /* eslint-disable no-invalid-this, valid-jsdoc */
  563. /**
  564. * @private
  565. * @class
  566. */
  567. var DOMElementProvider = function () {
  568. this.elements = [];
  569. };
  570. extend(DOMElementProvider.prototype, {
  571. /**
  572. * Create an element and keep track of it for later removal.
  573. * Same args as document.createElement
  574. * @private
  575. */
  576. createElement: function () {
  577. var el = doc.createElement.apply(doc,
  578. arguments);
  579. this.elements.push(el);
  580. return el;
  581. },
  582. /**
  583. * Destroy all created elements, removing them from the DOM.
  584. * @private
  585. */
  586. destroyCreatedElements: function () {
  587. this.elements.forEach(function (element) {
  588. removeElement(element);
  589. });
  590. this.elements = [];
  591. }
  592. });
  593. return DOMElementProvider;
  594. });
  595. _registerModule(_modules, 'Accessibility/AccessibilityComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Utils/EventProvider.js'], _modules['Accessibility/Utils/DOMElementProvider.js']], function (H, U, HTMLUtilities, ChartUtilities, EventProvider, DOMElementProvider) {
  596. /* *
  597. *
  598. * (c) 2009-2020 Øystein Moseng
  599. *
  600. * Accessibility component class definition
  601. *
  602. * License: www.highcharts.com/license
  603. *
  604. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  605. *
  606. * */
  607. var win = H.win,
  608. doc = win.document;
  609. var extend = U.extend,
  610. fireEvent = U.fireEvent,
  611. merge = U.merge;
  612. var removeElement = HTMLUtilities.removeElement,
  613. getFakeMouseEvent = HTMLUtilities.getFakeMouseEvent;
  614. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT;
  615. /* eslint-disable valid-jsdoc */
  616. /** @lends Highcharts.AccessibilityComponent */
  617. var functionsToOverrideByDerivedClasses = {
  618. /**
  619. * Called on component initialization.
  620. */
  621. init: function () { },
  622. /**
  623. * Get keyboard navigation handler for this component.
  624. * @return {Highcharts.KeyboardNavigationHandler}
  625. */
  626. getKeyboardNavigation: function () { },
  627. /**
  628. * Called on updates to the chart,
  629. including options changes.
  630. * Note that this is also called on first render of chart.
  631. */
  632. onChartUpdate: function () { },
  633. /**
  634. * Called on every chart render.
  635. */
  636. onChartRender: function () { },
  637. /**
  638. * Called when accessibility is disabled or chart is destroyed.
  639. */
  640. destroy: function () { }
  641. };
  642. /**
  643. * The AccessibilityComponent base class, representing a part of the chart that
  644. * has accessibility logic connected to it. This class can be inherited from to
  645. * create a custom accessibility component for a chart.
  646. *
  647. * Components should take care to destroy added elements and unregister event
  648. * handlers on destroy. This is handled automatically if using this.addEvent and
  649. * this.createElement.
  650. *
  651. * @sample highcharts/accessibility/custom-component
  652. * Custom accessibility component
  653. *
  654. * @requires module:modules/accessibility
  655. * @class
  656. * @name Highcharts.AccessibilityComponent
  657. */
  658. function AccessibilityComponent() { }
  659. /**
  660. * @lends Highcharts.AccessibilityComponent
  661. */
  662. AccessibilityComponent.prototype = {
  663. /**
  664. * Initialize the class
  665. * @private
  666. * @param {Highcharts.Chart} chart
  667. * Chart object
  668. */
  669. initBase: function (chart) {
  670. this.chart = chart;
  671. this.eventProvider = new EventProvider();
  672. this.domElementProvider = new DOMElementProvider();
  673. // Key code enum for common keys
  674. this.keyCodes = {
  675. left: 37,
  676. right: 39,
  677. up: 38,
  678. down: 40,
  679. enter: 13,
  680. space: 32,
  681. esc: 27,
  682. tab: 9
  683. };
  684. },
  685. /**
  686. * Add an event to an element and keep track of it for later removal.
  687. * See EventProvider for details.
  688. * @private
  689. */
  690. addEvent: function () {
  691. return this.eventProvider.addEvent
  692. .apply(this.eventProvider, arguments);
  693. },
  694. /**
  695. * Create an element and keep track of it for later removal.
  696. * See DOMElementProvider for details.
  697. * @private
  698. */
  699. createElement: function () {
  700. return this.domElementProvider.createElement.apply(this.domElementProvider, arguments);
  701. },
  702. /**
  703. * Fire an event on an element that is either wrapped by Highcharts,
  704. * or a DOM element
  705. * @private
  706. * @param {Highcharts.HTMLElement|Highcharts.HTMLDOMElement|
  707. * Highcharts.SVGDOMElement|Highcharts.SVGElement} el
  708. * @param {Event} eventObject
  709. */
  710. fireEventOnWrappedOrUnwrappedElement: function (el, eventObject) {
  711. var type = eventObject.type;
  712. if (doc.createEvent && (el.dispatchEvent || el.fireEvent)) {
  713. if (el.dispatchEvent) {
  714. el.dispatchEvent(eventObject);
  715. }
  716. else {
  717. el.fireEvent(type, eventObject);
  718. }
  719. }
  720. else {
  721. fireEvent(el, type, eventObject);
  722. }
  723. },
  724. /**
  725. * Utility function to attempt to fake a click event on an element.
  726. * @private
  727. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} element
  728. */
  729. fakeClickEvent: function (element) {
  730. if (element) {
  731. var fakeEventObject = getFakeMouseEvent('click');
  732. this.fireEventOnWrappedOrUnwrappedElement(element, fakeEventObject);
  733. }
  734. },
  735. /**
  736. * Add a new proxy group to the proxy container. Creates the proxy container
  737. * if it does not exist.
  738. * @private
  739. * @param {Highcharts.HTMLAttributes} [attrs]
  740. * The attributes to set on the new group div.
  741. * @return {Highcharts.HTMLDOMElement}
  742. * The new proxy group element.
  743. */
  744. addProxyGroup: function (attrs) {
  745. this.createOrUpdateProxyContainer();
  746. var groupDiv = this.createElement('div');
  747. Object.keys(attrs || {}).forEach(function (prop) {
  748. if (attrs[prop] !== null) {
  749. groupDiv.setAttribute(prop, attrs[prop]);
  750. }
  751. });
  752. this.chart.a11yProxyContainer.appendChild(groupDiv);
  753. return groupDiv;
  754. },
  755. /**
  756. * Creates and updates DOM position of proxy container
  757. * @private
  758. */
  759. createOrUpdateProxyContainer: function () {
  760. var chart = this.chart,
  761. rendererSVGEl = chart.renderer.box;
  762. chart.a11yProxyContainer = chart.a11yProxyContainer ||
  763. this.createProxyContainerElement();
  764. if (rendererSVGEl.nextSibling !== chart.a11yProxyContainer) {
  765. chart.container.insertBefore(chart.a11yProxyContainer, rendererSVGEl.nextSibling);
  766. }
  767. },
  768. /**
  769. * @private
  770. * @return {Highcharts.HTMLDOMElement} element
  771. */
  772. createProxyContainerElement: function () {
  773. var pc = doc.createElement('div');
  774. pc.className = 'highcharts-a11y-proxy-container';
  775. return pc;
  776. },
  777. /**
  778. * Create an invisible proxy HTML button in the same position as an SVG
  779. * element
  780. * @private
  781. * @param {Highcharts.SVGElement} svgElement
  782. * The wrapped svg el to proxy.
  783. * @param {Highcharts.HTMLDOMElement} parentGroup
  784. * The proxy group element in the proxy container to add this button to.
  785. * @param {Highcharts.SVGAttributes} [attributes]
  786. * Additional attributes to set.
  787. * @param {Highcharts.SVGElement} [posElement]
  788. * Element to use for positioning instead of svgElement.
  789. * @param {Function} [preClickEvent]
  790. * Function to call before click event fires.
  791. *
  792. * @return {Highcharts.HTMLDOMElement} The proxy button.
  793. */
  794. createProxyButton: function (svgElement, parentGroup, attributes, posElement, preClickEvent) {
  795. var svgEl = svgElement.element,
  796. proxy = this.createElement('button'),
  797. attrs = merge({
  798. 'aria-label': svgEl.getAttribute('aria-label')
  799. },
  800. attributes);
  801. Object.keys(attrs).forEach(function (prop) {
  802. if (attrs[prop] !== null) {
  803. proxy.setAttribute(prop, attrs[prop]);
  804. }
  805. });
  806. proxy.className = 'highcharts-a11y-proxy-button';
  807. if (preClickEvent) {
  808. this.addEvent(proxy, 'click', preClickEvent);
  809. }
  810. this.setProxyButtonStyle(proxy);
  811. this.updateProxyButtonPosition(proxy, posElement || svgElement);
  812. this.proxyMouseEventsForButton(svgEl, proxy);
  813. // Add to chart div and unhide from screen readers
  814. parentGroup.appendChild(proxy);
  815. if (!attrs['aria-hidden']) {
  816. unhideChartElementFromAT(this.chart, proxy);
  817. }
  818. return proxy;
  819. },
  820. /**
  821. * Get the position relative to chart container for a wrapped SVG element.
  822. * @private
  823. * @param {Highcharts.SVGElement} element
  824. * The element to calculate position for.
  825. * @return {Highcharts.BBoxObject}
  826. * Object with x and y props for the position.
  827. */
  828. getElementPosition: function (element) {
  829. var el = element.element,
  830. div = this.chart.renderTo;
  831. if (div && el && el.getBoundingClientRect) {
  832. var rectEl = el.getBoundingClientRect(),
  833. rectDiv = div.getBoundingClientRect();
  834. return {
  835. x: rectEl.left - rectDiv.left,
  836. y: rectEl.top - rectDiv.top,
  837. width: rectEl.right - rectEl.left,
  838. height: rectEl.bottom - rectEl.top
  839. };
  840. }
  841. return { x: 0, y: 0, width: 1, height: 1 };
  842. },
  843. /**
  844. * @private
  845. * @param {Highcharts.HTMLElement} button The proxy element.
  846. */
  847. setProxyButtonStyle: function (button) {
  848. merge(true, button.style, {
  849. 'border-width': 0,
  850. 'background-color': 'transparent',
  851. cursor: 'pointer',
  852. outline: 'none',
  853. opacity: 0.001,
  854. filter: 'alpha(opacity=1)',
  855. '-ms-filter': 'progid:DXImageTransform.Microsoft.Alpha(Opacity=1)',
  856. zIndex: 999,
  857. overflow: 'hidden',
  858. padding: 0,
  859. margin: 0,
  860. display: 'block',
  861. position: 'absolute'
  862. });
  863. },
  864. /**
  865. * @private
  866. * @param {Highcharts.HTMLElement} proxy The proxy to update position of.
  867. * @param {Highcharts.SVGElement} posElement The element to overlay and take position from.
  868. */
  869. updateProxyButtonPosition: function (proxy, posElement) {
  870. var bBox = this.getElementPosition(posElement);
  871. merge(true, proxy.style, {
  872. width: (bBox.width || 1) + 'px',
  873. height: (bBox.height || 1) + 'px',
  874. left: (bBox.x || 0) + 'px',
  875. top: (bBox.y || 0) + 'px'
  876. });
  877. },
  878. /**
  879. * @private
  880. * @param {Highcharts.HTMLElement|Highcharts.HTMLDOMElement|
  881. * Highcharts.SVGDOMElement|Highcharts.SVGElement} source
  882. * @param {Highcharts.HTMLElement} button
  883. */
  884. proxyMouseEventsForButton: function (source, button) {
  885. var component = this;
  886. [
  887. 'click', 'touchstart', 'touchend', 'touchcancel', 'touchmove',
  888. 'mouseover', 'mouseenter', 'mouseleave', 'mouseout'
  889. ].forEach(function (evtType) {
  890. var isTouchEvent = evtType.indexOf('touch') === 0;
  891. component.addEvent(button, evtType, function (e) {
  892. var clonedEvent = isTouchEvent ?
  893. component.cloneTouchEvent(e) :
  894. component.cloneMouseEvent(e);
  895. if (source) {
  896. component.fireEventOnWrappedOrUnwrappedElement(source, clonedEvent);
  897. }
  898. e.stopPropagation();
  899. e.preventDefault();
  900. });
  901. });
  902. },
  903. /**
  904. * Utility function to clone a mouse event for re-dispatching.
  905. * @private
  906. * @param {global.MouseEvent} e The event to clone.
  907. * @return {global.MouseEvent} The cloned event
  908. */
  909. cloneMouseEvent: function (e) {
  910. if (typeof win.MouseEvent === 'function') {
  911. return new win.MouseEvent(e.type, e);
  912. }
  913. // No MouseEvent support, try using initMouseEvent
  914. if (doc.createEvent) {
  915. var evt = doc.createEvent('MouseEvent');
  916. if (evt.initMouseEvent) {
  917. evt.initMouseEvent(e.type, e.bubbles, // #10561, #12161
  918. e.cancelable, e.view || win, e.detail, e.screenX, e.screenY, e.clientX, e.clientY, e.ctrlKey, e.altKey, e.shiftKey, e.metaKey, e.button, e.relatedTarget);
  919. return evt;
  920. }
  921. }
  922. return getFakeMouseEvent(e.type);
  923. },
  924. /**
  925. * Utility function to clone a touch event for re-dispatching.
  926. * @private
  927. * @param {global.TouchEvent} e The event to clone.
  928. * @return {global.TouchEvent} The cloned event
  929. */
  930. cloneTouchEvent: function (e) {
  931. var touchListToTouchArray = function (l) {
  932. var touchArray = [];
  933. for (var i = 0; i < l.length; ++i) {
  934. var item = l.item(i);
  935. if (item) {
  936. touchArray.push(item);
  937. }
  938. }
  939. return touchArray;
  940. };
  941. if (typeof win.TouchEvent === 'function') {
  942. var newEvent = new win.TouchEvent(e.type, {
  943. touches: touchListToTouchArray(e.touches),
  944. targetTouches: touchListToTouchArray(e.targetTouches),
  945. changedTouches: touchListToTouchArray(e.changedTouches),
  946. ctrlKey: e.ctrlKey,
  947. shiftKey: e.shiftKey,
  948. altKey: e.altKey,
  949. metaKey: e.metaKey,
  950. bubbles: e.bubbles,
  951. cancelable: e.cancelable,
  952. composed: e.composed,
  953. detail: e.detail,
  954. view: e.view
  955. });
  956. if (e.defaultPrevented) {
  957. newEvent.preventDefault();
  958. }
  959. return newEvent;
  960. }
  961. // Fallback to mouse event
  962. var fakeEvt = this.cloneMouseEvent(e);
  963. fakeEvt.touches = e.touches;
  964. fakeEvt.changedTouches = e.changedTouches;
  965. fakeEvt.targetTouches = e.targetTouches;
  966. return fakeEvt;
  967. },
  968. /**
  969. * Remove traces of the component.
  970. * @private
  971. */
  972. destroyBase: function () {
  973. removeElement(this.chart.a11yProxyContainer);
  974. this.domElementProvider.destroyCreatedElements();
  975. this.eventProvider.removeAddedEvents();
  976. }
  977. };
  978. extend(AccessibilityComponent.prototype, functionsToOverrideByDerivedClasses);
  979. return AccessibilityComponent;
  980. });
  981. _registerModule(_modules, 'Accessibility/KeyboardNavigation.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js'], _modules['Accessibility/Utils/EventProvider.js']], function (H, U, HTMLUtilities, EventProvider) {
  982. /* *
  983. *
  984. * (c) 2009-2020 Øystein Moseng
  985. *
  986. * Main keyboard navigation handling.
  987. *
  988. * License: www.highcharts.com/license
  989. *
  990. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  991. *
  992. * */
  993. var doc = H.doc,
  994. win = H.win;
  995. var addEvent = U.addEvent,
  996. fireEvent = U.fireEvent;
  997. var getElement = HTMLUtilities.getElement;
  998. /* eslint-disable valid-jsdoc */
  999. // Add event listener to document to detect ESC key press and dismiss
  1000. // hover/popup content.
  1001. addEvent(doc, 'keydown', function (e) {
  1002. var keycode = e.which || e.keyCode;
  1003. var esc = 27;
  1004. if (keycode === esc && H.charts) {
  1005. H.charts.forEach(function (chart) {
  1006. if (chart && chart.dismissPopupContent) {
  1007. chart.dismissPopupContent();
  1008. }
  1009. });
  1010. }
  1011. });
  1012. /**
  1013. * Dismiss popup content in chart, including export menu and tooltip.
  1014. */
  1015. H.Chart.prototype.dismissPopupContent = function () {
  1016. var chart = this;
  1017. fireEvent(this, 'dismissPopupContent', {}, function () {
  1018. if (chart.tooltip) {
  1019. chart.tooltip.hide(0);
  1020. }
  1021. chart.hideExportMenu();
  1022. });
  1023. };
  1024. /**
  1025. * The KeyboardNavigation class, containing the overall keyboard navigation
  1026. * logic for the chart.
  1027. *
  1028. * @requires module:modules/accessibility
  1029. *
  1030. * @private
  1031. * @class
  1032. * @param {Highcharts.Chart} chart
  1033. * Chart object
  1034. * @param {object} components
  1035. * Map of component names to AccessibilityComponent objects.
  1036. * @name Highcharts.KeyboardNavigation
  1037. */
  1038. function KeyboardNavigation(chart, components) {
  1039. this.init(chart, components);
  1040. }
  1041. KeyboardNavigation.prototype = {
  1042. /**
  1043. * Initialize the class
  1044. * @private
  1045. * @param {Highcharts.Chart} chart
  1046. * Chart object
  1047. * @param {object} components
  1048. * Map of component names to AccessibilityComponent objects.
  1049. */
  1050. init: function (chart, components) {
  1051. var _this = this;
  1052. var ep = this.eventProvider = new EventProvider();
  1053. this.chart = chart;
  1054. this.components = components;
  1055. this.modules = [];
  1056. this.currentModuleIx = 0;
  1057. // Run an update to get all modules
  1058. this.update();
  1059. ep.addEvent(this.tabindexContainer, 'keydown', function (e) { return _this.onKeydown(e); });
  1060. ep.addEvent(this.tabindexContainer, 'focus', function (e) { return _this.onFocus(e); });
  1061. ep.addEvent(doc, 'mouseup', function () { return _this.onMouseUp(); });
  1062. ep.addEvent(chart.renderTo, 'mousedown', function () {
  1063. _this.isClickingChart = true;
  1064. });
  1065. ep.addEvent(chart.renderTo, 'mouseover', function () {
  1066. _this.pointerIsOverChart = true;
  1067. });
  1068. ep.addEvent(chart.renderTo, 'mouseout', function () {
  1069. _this.pointerIsOverChart = false;
  1070. });
  1071. // Init first module
  1072. if (this.modules.length) {
  1073. this.modules[0].init(1);
  1074. }
  1075. },
  1076. /**
  1077. * Update the modules for the keyboard navigation.
  1078. * @param {Array<string>} [order]
  1079. * Array specifying the tab order of the components.
  1080. */
  1081. update: function (order) {
  1082. var a11yOptions = this.chart.options.accessibility,
  1083. keyboardOptions = a11yOptions && a11yOptions.keyboardNavigation,
  1084. components = this.components;
  1085. this.updateContainerTabindex();
  1086. if (keyboardOptions &&
  1087. keyboardOptions.enabled &&
  1088. order &&
  1089. order.length) {
  1090. // We (still) have keyboard navigation. Update module list
  1091. this.modules = order.reduce(function (modules, componentName) {
  1092. var navModules = components[componentName].getKeyboardNavigation();
  1093. return modules.concat(navModules);
  1094. }, []);
  1095. this.updateExitAnchor();
  1096. }
  1097. else {
  1098. this.modules = [];
  1099. this.currentModuleIx = 0;
  1100. this.removeExitAnchor();
  1101. }
  1102. },
  1103. /**
  1104. * Function to run on container focus
  1105. * @private
  1106. * @param {global.FocusEvent} e Browser focus event.
  1107. */
  1108. onFocus: function (e) {
  1109. var _a;
  1110. var chart = this.chart;
  1111. var focusComesFromChart = (e.relatedTarget &&
  1112. chart.container.contains(e.relatedTarget));
  1113. // Init keyboard nav if tabbing into chart
  1114. if (!this.isClickingChart && !focusComesFromChart) {
  1115. (_a = this.modules[0]) === null || _a === void 0 ? void 0 : _a.init(1);
  1116. }
  1117. },
  1118. /**
  1119. * Reset chart navigation state if we click outside the chart and it's
  1120. * not already reset.
  1121. * @private
  1122. */
  1123. onMouseUp: function () {
  1124. delete this.isClickingChart;
  1125. if (!this.keyboardReset && !this.pointerIsOverChart) {
  1126. var chart = this.chart,
  1127. curMod = this.modules &&
  1128. this.modules[this.currentModuleIx || 0];
  1129. if (curMod && curMod.terminate) {
  1130. curMod.terminate();
  1131. }
  1132. if (chart.focusElement) {
  1133. chart.focusElement.removeFocusBorder();
  1134. }
  1135. this.currentModuleIx = 0;
  1136. this.keyboardReset = true;
  1137. }
  1138. },
  1139. /**
  1140. * Function to run on keydown
  1141. * @private
  1142. * @param {global.KeyboardEvent} ev Browser keydown event.
  1143. */
  1144. onKeydown: function (ev) {
  1145. var e = ev || win.event,
  1146. preventDefault,
  1147. curNavModule = this.modules && this.modules.length &&
  1148. this.modules[this.currentModuleIx];
  1149. // Used for resetting nav state when clicking outside chart
  1150. this.keyboardReset = false;
  1151. // If there is a nav module for the current index, run it.
  1152. // Otherwise, we are outside of the chart in some direction.
  1153. if (curNavModule) {
  1154. var response = curNavModule.run(e);
  1155. if (response === curNavModule.response.success) {
  1156. preventDefault = true;
  1157. }
  1158. else if (response === curNavModule.response.prev) {
  1159. preventDefault = this.prev();
  1160. }
  1161. else if (response === curNavModule.response.next) {
  1162. preventDefault = this.next();
  1163. }
  1164. if (preventDefault) {
  1165. e.preventDefault();
  1166. e.stopPropagation();
  1167. }
  1168. }
  1169. },
  1170. /**
  1171. * Go to previous module.
  1172. * @private
  1173. */
  1174. prev: function () {
  1175. return this.move(-1);
  1176. },
  1177. /**
  1178. * Go to next module.
  1179. * @private
  1180. */
  1181. next: function () {
  1182. return this.move(1);
  1183. },
  1184. /**
  1185. * Move to prev/next module.
  1186. * @private
  1187. * @param {number} direction
  1188. * Direction to move. +1 for next, -1 for prev.
  1189. * @return {boolean}
  1190. * True if there was a valid module in direction.
  1191. */
  1192. move: function (direction) {
  1193. var curModule = this.modules && this.modules[this.currentModuleIx];
  1194. if (curModule && curModule.terminate) {
  1195. curModule.terminate(direction);
  1196. }
  1197. // Remove existing focus border if any
  1198. if (this.chart.focusElement) {
  1199. this.chart.focusElement.removeFocusBorder();
  1200. }
  1201. this.currentModuleIx += direction;
  1202. var newModule = this.modules && this.modules[this.currentModuleIx];
  1203. if (newModule) {
  1204. if (newModule.validate && !newModule.validate()) {
  1205. return this.move(direction); // Invalid module, recurse
  1206. }
  1207. if (newModule.init) {
  1208. newModule.init(direction); // Valid module, init it
  1209. return true;
  1210. }
  1211. }
  1212. // No module
  1213. this.currentModuleIx = 0; // Reset counter
  1214. // Set focus to chart or exit anchor depending on direction
  1215. if (direction > 0) {
  1216. this.exiting = true;
  1217. this.exitAnchor.focus();
  1218. }
  1219. else {
  1220. this.tabindexContainer.focus();
  1221. }
  1222. return false;
  1223. },
  1224. /**
  1225. * We use an exit anchor to move focus out of chart whenever we want, by
  1226. * setting focus to this div and not preventing the default tab action. We
  1227. * also use this when users come back into the chart by tabbing back, in
  1228. * order to navigate from the end of the chart.
  1229. * @private
  1230. */
  1231. updateExitAnchor: function () {
  1232. var endMarkerId = 'highcharts-end-of-chart-marker-' + this.chart.index,
  1233. endMarker = getElement(endMarkerId);
  1234. this.removeExitAnchor();
  1235. if (endMarker) {
  1236. this.makeElementAnExitAnchor(endMarker);
  1237. this.exitAnchor = endMarker;
  1238. }
  1239. else {
  1240. this.createExitAnchor();
  1241. }
  1242. },
  1243. /**
  1244. * Chart container should have tabindex if navigation is enabled.
  1245. * @private
  1246. */
  1247. updateContainerTabindex: function () {
  1248. var a11yOptions = this.chart.options.accessibility,
  1249. keyboardOptions = a11yOptions && a11yOptions.keyboardNavigation,
  1250. shouldHaveTabindex = !(keyboardOptions && keyboardOptions.enabled === false),
  1251. chart = this.chart,
  1252. container = chart.container;
  1253. var tabindexContainer;
  1254. if (chart.renderTo.hasAttribute('tabindex')) {
  1255. container.removeAttribute('tabindex');
  1256. tabindexContainer = chart.renderTo;
  1257. }
  1258. else {
  1259. tabindexContainer = container;
  1260. }
  1261. this.tabindexContainer = tabindexContainer;
  1262. var curTabindex = tabindexContainer.getAttribute('tabindex');
  1263. if (shouldHaveTabindex && !curTabindex) {
  1264. tabindexContainer.setAttribute('tabindex', '0');
  1265. }
  1266. else if (!shouldHaveTabindex) {
  1267. chart.container.removeAttribute('tabindex');
  1268. }
  1269. },
  1270. /**
  1271. * @private
  1272. */
  1273. makeElementAnExitAnchor: function (el) {
  1274. var chartTabindex = this.tabindexContainer.getAttribute('tabindex') || 0;
  1275. el.setAttribute('class', 'highcharts-exit-anchor');
  1276. el.setAttribute('tabindex', chartTabindex);
  1277. el.setAttribute('aria-hidden', false);
  1278. // Handle focus
  1279. this.addExitAnchorEventsToEl(el);
  1280. },
  1281. /**
  1282. * Add new exit anchor to the chart.
  1283. *
  1284. * @private
  1285. */
  1286. createExitAnchor: function () {
  1287. var chart = this.chart,
  1288. exitAnchor = this.exitAnchor = doc.createElement('div');
  1289. chart.renderTo.appendChild(exitAnchor);
  1290. this.makeElementAnExitAnchor(exitAnchor);
  1291. },
  1292. /**
  1293. * @private
  1294. */
  1295. removeExitAnchor: function () {
  1296. if (this.exitAnchor && this.exitAnchor.parentNode) {
  1297. this.exitAnchor.parentNode
  1298. .removeChild(this.exitAnchor);
  1299. delete this.exitAnchor;
  1300. }
  1301. },
  1302. /**
  1303. * @private
  1304. */
  1305. addExitAnchorEventsToEl: function (element) {
  1306. var chart = this.chart,
  1307. keyboardNavigation = this;
  1308. this.eventProvider.addEvent(element, 'focus', function (ev) {
  1309. var e = ev || win.event,
  1310. curModule,
  1311. focusComesFromChart = (e.relatedTarget &&
  1312. chart.container.contains(e.relatedTarget)),
  1313. comingInBackwards = !(focusComesFromChart || keyboardNavigation.exiting);
  1314. if (comingInBackwards) {
  1315. keyboardNavigation.tabindexContainer.focus();
  1316. e.preventDefault();
  1317. // Move to last valid keyboard nav module
  1318. // Note the we don't run it, just set the index
  1319. if (keyboardNavigation.modules &&
  1320. keyboardNavigation.modules.length) {
  1321. keyboardNavigation.currentModuleIx =
  1322. keyboardNavigation.modules.length - 1;
  1323. curModule = keyboardNavigation.modules[keyboardNavigation.currentModuleIx];
  1324. // Validate the module
  1325. if (curModule &&
  1326. curModule.validate && !curModule.validate()) {
  1327. // Invalid. Try moving backwards to find next valid.
  1328. keyboardNavigation.prev();
  1329. }
  1330. else if (curModule) {
  1331. // We have a valid module, init it
  1332. curModule.init(-1);
  1333. }
  1334. }
  1335. }
  1336. else {
  1337. // Don't skip the next focus, we only skip once.
  1338. keyboardNavigation.exiting = false;
  1339. }
  1340. });
  1341. },
  1342. /**
  1343. * Remove all traces of keyboard navigation.
  1344. * @private
  1345. */
  1346. destroy: function () {
  1347. this.removeExitAnchor();
  1348. this.eventProvider.removeAddedEvents();
  1349. this.chart.container.removeAttribute('tabindex');
  1350. }
  1351. };
  1352. return KeyboardNavigation;
  1353. });
  1354. _registerModule(_modules, 'Accessibility/Components/LegendComponent.js', [_modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, Legend, U, AccessibilityComponent, KeyboardNavigationHandler, HTMLUtilities) {
  1355. /* *
  1356. *
  1357. * (c) 2009-2020 Øystein Moseng
  1358. *
  1359. * Accessibility component for chart legend.
  1360. *
  1361. * License: www.highcharts.com/license
  1362. *
  1363. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1364. *
  1365. * */
  1366. var addEvent = U.addEvent,
  1367. extend = U.extend,
  1368. find = U.find,
  1369. fireEvent = U.fireEvent;
  1370. var stripHTMLTags = HTMLUtilities.stripHTMLTagsFromString,
  1371. removeElement = HTMLUtilities.removeElement;
  1372. /* eslint-disable no-invalid-this, valid-jsdoc */
  1373. /**
  1374. * @private
  1375. */
  1376. function scrollLegendToItem(legend, itemIx) {
  1377. var itemPage = legend.allItems[itemIx].pageIx,
  1378. curPage = legend.currentPage;
  1379. if (typeof itemPage !== 'undefined' && itemPage + 1 !== curPage) {
  1380. legend.scroll(1 + itemPage - curPage);
  1381. }
  1382. }
  1383. /**
  1384. * @private
  1385. */
  1386. function shouldDoLegendA11y(chart) {
  1387. var items = chart.legend && chart.legend.allItems,
  1388. legendA11yOptions = (chart.options.legend.accessibility || {});
  1389. return !!(items && items.length &&
  1390. !(chart.colorAxis && chart.colorAxis.length) &&
  1391. legendA11yOptions.enabled !== false);
  1392. }
  1393. /**
  1394. * Highlight legend item by index.
  1395. *
  1396. * @private
  1397. * @function Highcharts.Chart#highlightLegendItem
  1398. *
  1399. * @param {number} ix
  1400. *
  1401. * @return {boolean}
  1402. */
  1403. H.Chart.prototype.highlightLegendItem = function (ix) {
  1404. var items = this.legend.allItems,
  1405. oldIx = this.highlightedLegendItemIx;
  1406. if (items[ix]) {
  1407. if (items[oldIx]) {
  1408. fireEvent(items[oldIx].legendGroup.element, 'mouseout');
  1409. }
  1410. scrollLegendToItem(this.legend, ix);
  1411. this.setFocusToElement(items[ix].legendItem, items[ix].a11yProxyElement);
  1412. fireEvent(items[ix].legendGroup.element, 'mouseover');
  1413. return true;
  1414. }
  1415. return false;
  1416. };
  1417. // Keep track of pressed state for legend items
  1418. addEvent(Legend, 'afterColorizeItem', function (e) {
  1419. var chart = this.chart,
  1420. a11yOptions = chart.options.accessibility,
  1421. legendItem = e.item;
  1422. if (a11yOptions.enabled && legendItem && legendItem.a11yProxyElement) {
  1423. legendItem.a11yProxyElement.setAttribute('aria-pressed', e.visible ? 'false' : 'true');
  1424. }
  1425. });
  1426. /**
  1427. * The LegendComponent class
  1428. *
  1429. * @private
  1430. * @class
  1431. * @name Highcharts.LegendComponent
  1432. */
  1433. var LegendComponent = function () { };
  1434. LegendComponent.prototype = new AccessibilityComponent();
  1435. extend(LegendComponent.prototype, /** @lends Highcharts.LegendComponent */ {
  1436. /**
  1437. * Init the component
  1438. * @private
  1439. */
  1440. init: function () {
  1441. var component = this;
  1442. this.proxyElementsList = [];
  1443. this.recreateProxies();
  1444. // Note: Chart could create legend dynamically, so events can not be
  1445. // tied to the component's chart's current legend.
  1446. this.addEvent(Legend, 'afterScroll', function () {
  1447. if (this.chart === component.chart) {
  1448. component.updateProxiesPositions();
  1449. component.updateLegendItemProxyVisibility();
  1450. this.chart.highlightLegendItem(component.highlightedLegendItemIx);
  1451. }
  1452. });
  1453. this.addEvent(Legend, 'afterPositionItem', function (e) {
  1454. if (this.chart === component.chart && this.chart.renderer) {
  1455. component.updateProxyPositionForItem(e.item);
  1456. }
  1457. });
  1458. },
  1459. /**
  1460. * @private
  1461. */
  1462. updateLegendItemProxyVisibility: function () {
  1463. var legend = this.chart.legend,
  1464. items = legend.allItems || [],
  1465. curPage = legend.currentPage || 1,
  1466. clipHeight = legend.clipHeight || 0;
  1467. items.forEach(function (item) {
  1468. var itemPage = item.pageIx || 0,
  1469. y = item._legendItemPos ? item._legendItemPos[1] : 0,
  1470. h = item.legendItem ? Math.round(item.legendItem.getBBox().height) : 0,
  1471. hide = y + h - legend.pages[itemPage] > clipHeight || itemPage !== curPage - 1;
  1472. if (item.a11yProxyElement) {
  1473. item.a11yProxyElement.style.visibility = hide ?
  1474. 'hidden' : 'visible';
  1475. }
  1476. });
  1477. },
  1478. /**
  1479. * The legend needs updates on every render, in order to update positioning
  1480. * of the proxy overlays.
  1481. */
  1482. onChartRender: function () {
  1483. if (shouldDoLegendA11y(this.chart)) {
  1484. this.updateProxiesPositions();
  1485. }
  1486. else {
  1487. this.removeProxies();
  1488. }
  1489. },
  1490. /**
  1491. * @private
  1492. */
  1493. updateProxiesPositions: function () {
  1494. for (var _i = 0, _a = this.proxyElementsList; _i < _a.length; _i++) {
  1495. var _b = _a[_i],
  1496. element = _b.element,
  1497. posElement = _b.posElement;
  1498. this.updateProxyButtonPosition(element, posElement);
  1499. }
  1500. },
  1501. /**
  1502. * @private
  1503. */
  1504. updateProxyPositionForItem: function (item) {
  1505. var proxyRef = find(this.proxyElementsList,
  1506. function (ref) { return ref.item === item; });
  1507. if (proxyRef) {
  1508. this.updateProxyButtonPosition(proxyRef.element, proxyRef.posElement);
  1509. }
  1510. },
  1511. /**
  1512. * @private
  1513. */
  1514. recreateProxies: function () {
  1515. this.removeProxies();
  1516. if (shouldDoLegendA11y(this.chart)) {
  1517. this.addLegendProxyGroup();
  1518. this.proxyLegendItems();
  1519. this.updateLegendItemProxyVisibility();
  1520. }
  1521. },
  1522. /**
  1523. * @private
  1524. */
  1525. removeProxies: function () {
  1526. removeElement(this.legendProxyGroup);
  1527. this.proxyElementsList = [];
  1528. },
  1529. /**
  1530. * @private
  1531. */
  1532. addLegendProxyGroup: function () {
  1533. var a11yOptions = this.chart.options.accessibility, groupLabel = this.chart.langFormat('accessibility.legend.legendLabel', {}), groupRole = a11yOptions.landmarkVerbosity === 'all' ?
  1534. 'region' : null;
  1535. this.legendProxyGroup = this.addProxyGroup({
  1536. 'aria-label': groupLabel,
  1537. 'role': groupRole
  1538. });
  1539. },
  1540. /**
  1541. * @private
  1542. */
  1543. proxyLegendItems: function () {
  1544. var component = this,
  1545. items = (this.chart.legend &&
  1546. this.chart.legend.allItems || []);
  1547. items.forEach(function (item) {
  1548. if (item.legendItem && item.legendItem.element) {
  1549. component.proxyLegendItem(item);
  1550. }
  1551. });
  1552. },
  1553. /**
  1554. * @private
  1555. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  1556. */
  1557. proxyLegendItem: function (item) {
  1558. if (!item.legendItem || !item.legendGroup) {
  1559. return;
  1560. }
  1561. var itemLabel = this.chart.langFormat('accessibility.legend.legendItem', {
  1562. chart: this.chart,
  1563. itemName: stripHTMLTags(item.name)
  1564. }),
  1565. attribs = {
  1566. tabindex: -1,
  1567. 'aria-pressed': !item.visible,
  1568. 'aria-label': itemLabel
  1569. },
  1570. // Considers useHTML
  1571. proxyPositioningElement = item.legendGroup.div ?
  1572. item.legendItem : item.legendGroup;
  1573. item.a11yProxyElement = this.createProxyButton(item.legendItem, this.legendProxyGroup, attribs, proxyPositioningElement);
  1574. this.proxyElementsList.push({
  1575. item: item,
  1576. element: item.a11yProxyElement,
  1577. posElement: proxyPositioningElement
  1578. });
  1579. },
  1580. /**
  1581. * Get keyboard navigation handler for this component.
  1582. * @return {Highcharts.KeyboardNavigationHandler}
  1583. */
  1584. getKeyboardNavigation: function () {
  1585. var keys = this.keyCodes,
  1586. component = this,
  1587. chart = this.chart;
  1588. return new KeyboardNavigationHandler(chart, {
  1589. keyCodeMap: [
  1590. [
  1591. [keys.left, keys.right, keys.up, keys.down],
  1592. function (keyCode) {
  1593. return component.onKbdArrowKey(this, keyCode);
  1594. }
  1595. ],
  1596. [
  1597. [keys.enter, keys.space],
  1598. function () {
  1599. return component.onKbdClick(this);
  1600. }
  1601. ]
  1602. ],
  1603. validate: function () {
  1604. return component.shouldHaveLegendNavigation();
  1605. },
  1606. init: function (direction) {
  1607. return component.onKbdNavigationInit(direction);
  1608. }
  1609. });
  1610. },
  1611. /**
  1612. * @private
  1613. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  1614. * @param {number} keyCode
  1615. * @return {number}
  1616. * Response code
  1617. */
  1618. onKbdArrowKey: function (keyboardNavigationHandler, keyCode) {
  1619. var keys = this.keyCodes,
  1620. response = keyboardNavigationHandler.response,
  1621. chart = this.chart,
  1622. a11yOptions = chart.options.accessibility,
  1623. numItems = chart.legend.allItems.length,
  1624. direction = (keyCode === keys.left || keyCode === keys.up) ? -1 : 1;
  1625. var res = chart.highlightLegendItem(this.highlightedLegendItemIx + direction);
  1626. if (res) {
  1627. this.highlightedLegendItemIx += direction;
  1628. return response.success;
  1629. }
  1630. if (numItems > 1 &&
  1631. a11yOptions.keyboardNavigation.wrapAround) {
  1632. keyboardNavigationHandler.init(direction);
  1633. return response.success;
  1634. }
  1635. // No wrap, move
  1636. return response[direction > 0 ? 'next' : 'prev'];
  1637. },
  1638. /**
  1639. * @private
  1640. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  1641. * @return {number}
  1642. * Response code
  1643. */
  1644. onKbdClick: function (keyboardNavigationHandler) {
  1645. var legendItem = this.chart.legend.allItems[this.highlightedLegendItemIx];
  1646. if (legendItem && legendItem.a11yProxyElement) {
  1647. fireEvent(legendItem.a11yProxyElement, 'click');
  1648. }
  1649. return keyboardNavigationHandler.response.success;
  1650. },
  1651. /**
  1652. * @private
  1653. * @return {boolean|undefined}
  1654. */
  1655. shouldHaveLegendNavigation: function () {
  1656. var chart = this.chart,
  1657. legendOptions = chart.options.legend || {},
  1658. hasLegend = chart.legend && chart.legend.allItems,
  1659. hasColorAxis = chart.colorAxis && chart.colorAxis.length,
  1660. legendA11yOptions = (legendOptions.accessibility || {});
  1661. return !!(hasLegend &&
  1662. chart.legend.display &&
  1663. !hasColorAxis &&
  1664. legendA11yOptions.enabled &&
  1665. legendA11yOptions.keyboardNavigation &&
  1666. legendA11yOptions.keyboardNavigation.enabled);
  1667. },
  1668. /**
  1669. * @private
  1670. * @param {number} direction
  1671. */
  1672. onKbdNavigationInit: function (direction) {
  1673. var chart = this.chart,
  1674. lastIx = chart.legend.allItems.length - 1,
  1675. ixToHighlight = direction > 0 ? 0 : lastIx;
  1676. chart.highlightLegendItem(ixToHighlight);
  1677. this.highlightedLegendItemIx = ixToHighlight;
  1678. }
  1679. });
  1680. return LegendComponent;
  1681. });
  1682. _registerModule(_modules, 'Accessibility/Components/MenuComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, U, AccessibilityComponent, KeyboardNavigationHandler, ChartUtilities, HTMLUtilities) {
  1683. /* *
  1684. *
  1685. * (c) 2009-2020 Øystein Moseng
  1686. *
  1687. * Accessibility component for exporting menu.
  1688. *
  1689. * License: www.highcharts.com/license
  1690. *
  1691. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1692. *
  1693. * */
  1694. var extend = U.extend;
  1695. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT;
  1696. var removeElement = HTMLUtilities.removeElement,
  1697. getFakeMouseEvent = HTMLUtilities.getFakeMouseEvent;
  1698. /* eslint-disable no-invalid-this, valid-jsdoc */
  1699. /**
  1700. * Get the wrapped export button element of a chart.
  1701. *
  1702. * @private
  1703. * @param {Highcharts.Chart} chart
  1704. * @returns {Highcharts.SVGElement}
  1705. */
  1706. function getExportMenuButtonElement(chart) {
  1707. return chart.exportSVGElements && chart.exportSVGElements[0];
  1708. }
  1709. /**
  1710. * Show the export menu and focus the first item (if exists).
  1711. *
  1712. * @private
  1713. * @function Highcharts.Chart#showExportMenu
  1714. */
  1715. H.Chart.prototype.showExportMenu = function () {
  1716. var exportButton = getExportMenuButtonElement(this);
  1717. if (exportButton) {
  1718. var el = exportButton.element;
  1719. if (el.onclick) {
  1720. el.onclick(getFakeMouseEvent('click'));
  1721. }
  1722. }
  1723. };
  1724. /**
  1725. * @private
  1726. * @function Highcharts.Chart#hideExportMenu
  1727. */
  1728. H.Chart.prototype.hideExportMenu = function () {
  1729. var chart = this,
  1730. exportList = chart.exportDivElements;
  1731. if (exportList && chart.exportContextMenu) {
  1732. // Reset hover states etc.
  1733. exportList.forEach(function (el) {
  1734. if (el.className === 'highcharts-menu-item' && el.onmouseout) {
  1735. el.onmouseout(getFakeMouseEvent('mouseout'));
  1736. }
  1737. });
  1738. chart.highlightedExportItemIx = 0;
  1739. // Hide the menu div
  1740. chart.exportContextMenu.hideMenu();
  1741. // Make sure the chart has focus and can capture keyboard events
  1742. chart.container.focus();
  1743. }
  1744. };
  1745. /**
  1746. * Highlight export menu item by index.
  1747. *
  1748. * @private
  1749. * @function Highcharts.Chart#highlightExportItem
  1750. *
  1751. * @param {number} ix
  1752. *
  1753. * @return {boolean}
  1754. */
  1755. H.Chart.prototype.highlightExportItem = function (ix) {
  1756. var listItem = this.exportDivElements && this.exportDivElements[ix],
  1757. curHighlighted = this.exportDivElements &&
  1758. this.exportDivElements[this.highlightedExportItemIx],
  1759. hasSVGFocusSupport;
  1760. if (listItem &&
  1761. listItem.tagName === 'LI' &&
  1762. !(listItem.children && listItem.children.length)) {
  1763. // Test if we have focus support for SVG elements
  1764. hasSVGFocusSupport = !!(this.renderTo.getElementsByTagName('g')[0] || {}).focus;
  1765. // Only focus if we can set focus back to the elements after
  1766. // destroying the menu (#7422)
  1767. if (listItem.focus && hasSVGFocusSupport) {
  1768. listItem.focus();
  1769. }
  1770. if (curHighlighted && curHighlighted.onmouseout) {
  1771. curHighlighted.onmouseout(getFakeMouseEvent('mouseout'));
  1772. }
  1773. if (listItem.onmouseover) {
  1774. listItem.onmouseover(getFakeMouseEvent('mouseover'));
  1775. }
  1776. this.highlightedExportItemIx = ix;
  1777. return true;
  1778. }
  1779. return false;
  1780. };
  1781. /**
  1782. * Try to highlight the last valid export menu item.
  1783. *
  1784. * @private
  1785. * @function Highcharts.Chart#highlightLastExportItem
  1786. * @return {boolean}
  1787. */
  1788. H.Chart.prototype.highlightLastExportItem = function () {
  1789. var chart = this,
  1790. i;
  1791. if (chart.exportDivElements) {
  1792. i = chart.exportDivElements.length;
  1793. while (i--) {
  1794. if (chart.highlightExportItem(i)) {
  1795. return true;
  1796. }
  1797. }
  1798. }
  1799. return false;
  1800. };
  1801. /**
  1802. * @private
  1803. * @param {Highcharts.Chart} chart
  1804. */
  1805. function exportingShouldHaveA11y(chart) {
  1806. var exportingOpts = chart.options.exporting,
  1807. exportButton = getExportMenuButtonElement(chart);
  1808. return !!(exportingOpts &&
  1809. exportingOpts.enabled !== false &&
  1810. exportingOpts.accessibility &&
  1811. exportingOpts.accessibility.enabled &&
  1812. exportButton &&
  1813. exportButton.element);
  1814. }
  1815. /**
  1816. * The MenuComponent class
  1817. *
  1818. * @private
  1819. * @class
  1820. * @name Highcharts.MenuComponent
  1821. */
  1822. var MenuComponent = function () { };
  1823. MenuComponent.prototype = new AccessibilityComponent();
  1824. extend(MenuComponent.prototype, /** @lends Highcharts.MenuComponent */ {
  1825. /**
  1826. * Init the component
  1827. */
  1828. init: function () {
  1829. var chart = this.chart,
  1830. component = this;
  1831. this.addEvent(chart, 'exportMenuShown', function () {
  1832. component.onMenuShown();
  1833. });
  1834. this.addEvent(chart, 'exportMenuHidden', function () {
  1835. component.onMenuHidden();
  1836. });
  1837. },
  1838. /**
  1839. * @private
  1840. */
  1841. onMenuHidden: function () {
  1842. var menu = this.chart.exportContextMenu;
  1843. if (menu) {
  1844. menu.setAttribute('aria-hidden', 'true');
  1845. }
  1846. this.isExportMenuShown = false;
  1847. this.setExportButtonExpandedState('false');
  1848. },
  1849. /**
  1850. * @private
  1851. */
  1852. onMenuShown: function () {
  1853. var chart = this.chart,
  1854. menu = chart.exportContextMenu;
  1855. if (menu) {
  1856. this.addAccessibleContextMenuAttribs();
  1857. unhideChartElementFromAT(chart, menu);
  1858. }
  1859. this.isExportMenuShown = true;
  1860. this.setExportButtonExpandedState('true');
  1861. },
  1862. /**
  1863. * @private
  1864. * @param {string} stateStr
  1865. */
  1866. setExportButtonExpandedState: function (stateStr) {
  1867. var button = this.exportButtonProxy;
  1868. if (button) {
  1869. button.setAttribute('aria-expanded', stateStr);
  1870. }
  1871. },
  1872. /**
  1873. * Called on each render of the chart. We need to update positioning of the
  1874. * proxy overlay.
  1875. */
  1876. onChartRender: function () {
  1877. var chart = this.chart,
  1878. a11yOptions = chart.options.accessibility;
  1879. // Always start with a clean slate
  1880. removeElement(this.exportProxyGroup);
  1881. // Set screen reader properties on export menu
  1882. if (exportingShouldHaveA11y(chart)) {
  1883. // Proxy button and group
  1884. this.exportProxyGroup = this.addProxyGroup(
  1885. // Wrap in a region div if verbosity is high
  1886. a11yOptions.landmarkVerbosity === 'all' ? {
  1887. 'aria-label': chart.langFormat('accessibility.exporting.exportRegionLabel', { chart: chart }),
  1888. 'role': 'region'
  1889. } : {});
  1890. var button = getExportMenuButtonElement(this.chart);
  1891. this.exportButtonProxy = this.createProxyButton(button, this.exportProxyGroup, {
  1892. 'aria-label': chart.langFormat('accessibility.exporting.menuButtonLabel', { chart: chart }),
  1893. 'aria-expanded': 'false'
  1894. });
  1895. }
  1896. },
  1897. /**
  1898. * @private
  1899. */
  1900. addAccessibleContextMenuAttribs: function () {
  1901. var chart = this.chart,
  1902. exportList = chart.exportDivElements;
  1903. if (exportList && exportList.length) {
  1904. // Set tabindex on the menu items to allow focusing by script
  1905. // Set role to give screen readers a chance to pick up the contents
  1906. exportList.forEach(function (item) {
  1907. if (item.tagName === 'LI' &&
  1908. !(item.children && item.children.length)) {
  1909. item.setAttribute('tabindex', -1);
  1910. }
  1911. else {
  1912. item.setAttribute('aria-hidden', 'true');
  1913. }
  1914. });
  1915. // Set accessibility properties on parent div
  1916. var parentDiv = exportList[0].parentNode;
  1917. parentDiv.removeAttribute('aria-hidden');
  1918. parentDiv.setAttribute('aria-label', chart.langFormat('accessibility.exporting.chartMenuLabel', { chart: chart }));
  1919. }
  1920. },
  1921. /**
  1922. * Get keyboard navigation handler for this component.
  1923. * @return {Highcharts.KeyboardNavigationHandler}
  1924. */
  1925. getKeyboardNavigation: function () {
  1926. var keys = this.keyCodes,
  1927. chart = this.chart,
  1928. component = this;
  1929. return new KeyboardNavigationHandler(chart, {
  1930. keyCodeMap: [
  1931. // Arrow prev handler
  1932. [
  1933. [keys.left, keys.up],
  1934. function () {
  1935. return component.onKbdPrevious(this);
  1936. }
  1937. ],
  1938. // Arrow next handler
  1939. [
  1940. [keys.right, keys.down],
  1941. function () {
  1942. return component.onKbdNext(this);
  1943. }
  1944. ],
  1945. // Click handler
  1946. [
  1947. [keys.enter, keys.space],
  1948. function () {
  1949. return component.onKbdClick(this);
  1950. }
  1951. ]
  1952. ],
  1953. // Only run exporting navigation if exporting support exists and is
  1954. // enabled on chart
  1955. validate: function () {
  1956. return chart.exportChart &&
  1957. chart.options.exporting.enabled !== false &&
  1958. chart.options.exporting.accessibility.enabled !==
  1959. false;
  1960. },
  1961. // Focus export menu button
  1962. init: function () {
  1963. var exportBtn = component.exportButtonProxy,
  1964. exportGroup = chart.exportingGroup;
  1965. if (exportGroup && exportBtn) {
  1966. chart.setFocusToElement(exportGroup, exportBtn);
  1967. }
  1968. },
  1969. // Hide the menu
  1970. terminate: function () {
  1971. chart.hideExportMenu();
  1972. }
  1973. });
  1974. },
  1975. /**
  1976. * @private
  1977. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  1978. * @return {number}
  1979. * Response code
  1980. */
  1981. onKbdPrevious: function (keyboardNavigationHandler) {
  1982. var chart = this.chart,
  1983. a11yOptions = chart.options.accessibility,
  1984. response = keyboardNavigationHandler.response,
  1985. i = chart.highlightedExportItemIx || 0;
  1986. // Try to highlight prev item in list. Highlighting e.g.
  1987. // separators will fail.
  1988. while (i--) {
  1989. if (chart.highlightExportItem(i)) {
  1990. return response.success;
  1991. }
  1992. }
  1993. // We failed, so wrap around or move to prev module
  1994. if (a11yOptions.keyboardNavigation.wrapAround) {
  1995. chart.highlightLastExportItem();
  1996. return response.success;
  1997. }
  1998. return response.prev;
  1999. },
  2000. /**
  2001. * @private
  2002. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  2003. * @return {number}
  2004. * Response code
  2005. */
  2006. onKbdNext: function (keyboardNavigationHandler) {
  2007. var chart = this.chart,
  2008. a11yOptions = chart.options.accessibility,
  2009. response = keyboardNavigationHandler.response,
  2010. i = (chart.highlightedExportItemIx || 0) + 1;
  2011. // Try to highlight next item in list. Highlighting e.g.
  2012. // separators will fail.
  2013. for (; i < chart.exportDivElements.length; ++i) {
  2014. if (chart.highlightExportItem(i)) {
  2015. return response.success;
  2016. }
  2017. }
  2018. // We failed, so wrap around or move to next module
  2019. if (a11yOptions.keyboardNavigation.wrapAround) {
  2020. chart.highlightExportItem(0);
  2021. return response.success;
  2022. }
  2023. return response.next;
  2024. },
  2025. /**
  2026. * @private
  2027. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  2028. * @return {number}
  2029. * Response code
  2030. */
  2031. onKbdClick: function (keyboardNavigationHandler) {
  2032. var chart = this.chart,
  2033. curHighlightedItem = chart.exportDivElements[chart.highlightedExportItemIx],
  2034. exportButtonElement = getExportMenuButtonElement(chart).element;
  2035. if (this.isExportMenuShown) {
  2036. this.fakeClickEvent(curHighlightedItem);
  2037. }
  2038. else {
  2039. this.fakeClickEvent(exportButtonElement);
  2040. chart.highlightExportItem(0);
  2041. }
  2042. return keyboardNavigationHandler.response.success;
  2043. }
  2044. });
  2045. return MenuComponent;
  2046. });
  2047. _registerModule(_modules, 'Accessibility/Components/SeriesComponent/SeriesKeyboardNavigation.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Accessibility/Utils/EventProvider.js'], _modules['Accessibility/Utils/ChartUtilities.js']], function (Chart, H, Point, U, KeyboardNavigationHandler, EventProvider, ChartUtilities) {
  2048. /* *
  2049. *
  2050. * (c) 2009-2020 Øystein Moseng
  2051. *
  2052. * Handle keyboard navigation for series.
  2053. *
  2054. * License: www.highcharts.com/license
  2055. *
  2056. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2057. *
  2058. * */
  2059. var defined = U.defined,
  2060. extend = U.extend;
  2061. var getPointFromXY = ChartUtilities.getPointFromXY,
  2062. getSeriesFromName = ChartUtilities.getSeriesFromName,
  2063. scrollToPoint = ChartUtilities.scrollToPoint;
  2064. /* eslint-disable no-invalid-this, valid-jsdoc */
  2065. /*
  2066. * Set for which series types it makes sense to move to the closest point with
  2067. * up/down arrows, and which series types should just move to next series.
  2068. */
  2069. H.Series.prototype.keyboardMoveVertical = true;
  2070. ['column', 'pie'].forEach(function (type) {
  2071. if (H.seriesTypes[type]) {
  2072. H.seriesTypes[type].prototype.keyboardMoveVertical = false;
  2073. }
  2074. });
  2075. /**
  2076. * Get the index of a point in a series. This is needed when using e.g. data
  2077. * grouping.
  2078. *
  2079. * @private
  2080. * @function getPointIndex
  2081. *
  2082. * @param {Highcharts.AccessibilityPoint} point
  2083. * The point to find index of.
  2084. *
  2085. * @return {number|undefined}
  2086. * The index in the series.points array of the point.
  2087. */
  2088. function getPointIndex(point) {
  2089. var index = point.index,
  2090. points = point.series.points,
  2091. i = points.length;
  2092. if (points[index] !== point) {
  2093. while (i--) {
  2094. if (points[i] === point) {
  2095. return i;
  2096. }
  2097. }
  2098. }
  2099. else {
  2100. return index;
  2101. }
  2102. }
  2103. /**
  2104. * Determine if series navigation should be skipped
  2105. *
  2106. * @private
  2107. * @function isSkipSeries
  2108. *
  2109. * @param {Highcharts.Series} series
  2110. *
  2111. * @return {boolean|number|undefined}
  2112. */
  2113. function isSkipSeries(series) {
  2114. var a11yOptions = series.chart.options.accessibility,
  2115. seriesNavOptions = a11yOptions.keyboardNavigation.seriesNavigation,
  2116. seriesA11yOptions = series.options.accessibility || {},
  2117. seriesKbdNavOptions = seriesA11yOptions.keyboardNavigation;
  2118. return seriesKbdNavOptions && seriesKbdNavOptions.enabled === false ||
  2119. seriesA11yOptions.enabled === false ||
  2120. series.options.enableMouseTracking === false || // #8440
  2121. !series.visible ||
  2122. // Skip all points in a series where pointNavigationEnabledThreshold is
  2123. // reached
  2124. (seriesNavOptions.pointNavigationEnabledThreshold &&
  2125. seriesNavOptions.pointNavigationEnabledThreshold <=
  2126. series.points.length);
  2127. }
  2128. /**
  2129. * Determine if navigation for a point should be skipped
  2130. *
  2131. * @private
  2132. * @function isSkipPoint
  2133. *
  2134. * @param {Highcharts.Point} point
  2135. *
  2136. * @return {boolean|number|undefined}
  2137. */
  2138. function isSkipPoint(point) {
  2139. var a11yOptions = point.series.chart.options.accessibility;
  2140. return point.isNull &&
  2141. a11yOptions.keyboardNavigation.seriesNavigation.skipNullPoints ||
  2142. point.visible === false ||
  2143. isSkipSeries(point.series);
  2144. }
  2145. /**
  2146. * Get the point in a series that is closest (in pixel distance) to a reference
  2147. * point. Optionally supply weight factors for x and y directions.
  2148. *
  2149. * @private
  2150. * @function getClosestPoint
  2151. *
  2152. * @param {Highcharts.Point} point
  2153. * @param {Highcharts.Series} series
  2154. * @param {number} [xWeight]
  2155. * @param {number} [yWeight]
  2156. *
  2157. * @return {Highcharts.Point|undefined}
  2158. */
  2159. function getClosestPoint(point, series, xWeight, yWeight) {
  2160. var minDistance = Infinity,
  2161. dPoint,
  2162. minIx,
  2163. distance,
  2164. i = series.points.length,
  2165. hasUndefinedPosition = function (point) {
  2166. return !(defined(point.plotX) && defined(point.plotY));
  2167. };
  2168. if (hasUndefinedPosition(point)) {
  2169. return;
  2170. }
  2171. while (i--) {
  2172. dPoint = series.points[i];
  2173. if (hasUndefinedPosition(dPoint)) {
  2174. continue;
  2175. }
  2176. distance = (point.plotX - dPoint.plotX) *
  2177. (point.plotX - dPoint.plotX) *
  2178. (xWeight || 1) +
  2179. (point.plotY - dPoint.plotY) *
  2180. (point.plotY - dPoint.plotY) *
  2181. (yWeight || 1);
  2182. if (distance < minDistance) {
  2183. minDistance = distance;
  2184. minIx = i;
  2185. }
  2186. }
  2187. return defined(minIx) ? series.points[minIx] : void 0;
  2188. }
  2189. /**
  2190. * Highlights a point (show tooltip and display hover state).
  2191. *
  2192. * @private
  2193. * @function Highcharts.Point#highlight
  2194. *
  2195. * @return {Highcharts.Point}
  2196. * This highlighted point.
  2197. */
  2198. Point.prototype.highlight = function () {
  2199. var chart = this.series.chart;
  2200. if (!this.isNull) {
  2201. this.onMouseOver(); // Show the hover marker and tooltip
  2202. }
  2203. else {
  2204. if (chart.tooltip) {
  2205. chart.tooltip.hide(0);
  2206. }
  2207. // Don't call blur on the element, as it messes up the chart div's focus
  2208. }
  2209. scrollToPoint(this);
  2210. // We focus only after calling onMouseOver because the state change can
  2211. // change z-index and mess up the element.
  2212. if (this.graphic) {
  2213. chart.setFocusToElement(this.graphic);
  2214. }
  2215. chart.highlightedPoint = this;
  2216. return this;
  2217. };
  2218. /**
  2219. * Function to highlight next/previous point in chart.
  2220. *
  2221. * @private
  2222. * @function Highcharts.Chart#highlightAdjacentPoint
  2223. *
  2224. * @param {boolean} next
  2225. * Flag for the direction.
  2226. *
  2227. * @return {Highcharts.Point|boolean}
  2228. * Returns highlighted point on success, false on failure (no adjacent
  2229. * point to highlight in chosen direction).
  2230. */
  2231. Chart.prototype.highlightAdjacentPoint = function (next) {
  2232. var chart = this,
  2233. series = chart.series,
  2234. curPoint = chart.highlightedPoint,
  2235. curPointIndex = curPoint && getPointIndex(curPoint) || 0,
  2236. curPoints = (curPoint && curPoint.series.points),
  2237. lastSeries = chart.series && chart.series[chart.series.length - 1],
  2238. lastPoint = lastSeries && lastSeries.points &&
  2239. lastSeries.points[lastSeries.points.length - 1],
  2240. newSeries,
  2241. newPoint;
  2242. // If no points, return false
  2243. if (!series[0] || !series[0].points) {
  2244. return false;
  2245. }
  2246. if (!curPoint) {
  2247. // No point is highlighted yet. Try first/last point depending on move
  2248. // direction
  2249. newPoint = next ? series[0].points[0] : lastPoint;
  2250. }
  2251. else {
  2252. // We have a highlighted point.
  2253. // Grab next/prev point & series
  2254. newSeries = series[curPoint.series.index + (next ? 1 : -1)];
  2255. newPoint = curPoints[curPointIndex + (next ? 1 : -1)];
  2256. if (!newPoint && newSeries) {
  2257. // Done with this series, try next one
  2258. newPoint = newSeries.points[next ? 0 : newSeries.points.length - 1];
  2259. }
  2260. // If there is no adjacent point, we return false
  2261. if (!newPoint) {
  2262. return false;
  2263. }
  2264. }
  2265. // Recursively skip points
  2266. if (isSkipPoint(newPoint)) {
  2267. // If we skip this whole series, move to the end of the series before we
  2268. // recurse, just to optimize
  2269. newSeries = newPoint.series;
  2270. if (isSkipSeries(newSeries)) {
  2271. chart.highlightedPoint = next ?
  2272. newSeries.points[newSeries.points.length - 1] :
  2273. newSeries.points[0];
  2274. }
  2275. else {
  2276. // Otherwise, just move one point
  2277. chart.highlightedPoint = newPoint;
  2278. }
  2279. // Retry
  2280. return chart.highlightAdjacentPoint(next);
  2281. }
  2282. // There is an adjacent point, highlight it
  2283. return newPoint.highlight();
  2284. };
  2285. /**
  2286. * Highlight first valid point in a series. Returns the point if successfully
  2287. * highlighted, otherwise false. If there is a highlighted point in the series,
  2288. * use that as starting point.
  2289. *
  2290. * @private
  2291. * @function Highcharts.Series#highlightFirstValidPoint
  2292. *
  2293. * @return {boolean|Highcharts.Point}
  2294. */
  2295. H.Series.prototype.highlightFirstValidPoint = function () {
  2296. var curPoint = this.chart.highlightedPoint,
  2297. start = (curPoint && curPoint.series) === this ?
  2298. getPointIndex(curPoint) :
  2299. 0,
  2300. points = this.points,
  2301. len = points.length;
  2302. if (points && len) {
  2303. for (var i = start; i < len; ++i) {
  2304. if (!isSkipPoint(points[i])) {
  2305. return points[i].highlight();
  2306. }
  2307. }
  2308. for (var j = start; j >= 0; --j) {
  2309. if (!isSkipPoint(points[j])) {
  2310. return points[j].highlight();
  2311. }
  2312. }
  2313. }
  2314. return false;
  2315. };
  2316. /**
  2317. * Highlight next/previous series in chart. Returns false if no adjacent series
  2318. * in the direction, otherwise returns new highlighted point.
  2319. *
  2320. * @private
  2321. * @function Highcharts.Chart#highlightAdjacentSeries
  2322. *
  2323. * @param {boolean} down
  2324. *
  2325. * @return {Highcharts.Point|boolean}
  2326. */
  2327. Chart.prototype.highlightAdjacentSeries = function (down) {
  2328. var chart = this,
  2329. newSeries,
  2330. newPoint,
  2331. adjacentNewPoint,
  2332. curPoint = chart.highlightedPoint,
  2333. lastSeries = chart.series && chart.series[chart.series.length - 1],
  2334. lastPoint = lastSeries && lastSeries.points &&
  2335. lastSeries.points[lastSeries.points.length - 1];
  2336. // If no point is highlighted, highlight the first/last point
  2337. if (!chart.highlightedPoint) {
  2338. newSeries = down ? (chart.series && chart.series[0]) : lastSeries;
  2339. newPoint = down ?
  2340. (newSeries && newSeries.points && newSeries.points[0]) : lastPoint;
  2341. return newPoint ? newPoint.highlight() : false;
  2342. }
  2343. newSeries = chart.series[curPoint.series.index + (down ? -1 : 1)];
  2344. if (!newSeries) {
  2345. return false;
  2346. }
  2347. // We have a new series in this direction, find the right point
  2348. // Weigh xDistance as counting much higher than Y distance
  2349. newPoint = getClosestPoint(curPoint, newSeries, 4);
  2350. if (!newPoint) {
  2351. return false;
  2352. }
  2353. // New series and point exists, but we might want to skip it
  2354. if (isSkipSeries(newSeries)) {
  2355. // Skip the series
  2356. newPoint.highlight();
  2357. adjacentNewPoint = chart.highlightAdjacentSeries(down); // Try recurse
  2358. if (!adjacentNewPoint) {
  2359. // Recurse failed
  2360. curPoint.highlight();
  2361. return false;
  2362. }
  2363. // Recurse succeeded
  2364. return adjacentNewPoint;
  2365. }
  2366. // Highlight the new point or any first valid point back or forwards from it
  2367. newPoint.highlight();
  2368. return newPoint.series.highlightFirstValidPoint();
  2369. };
  2370. /**
  2371. * Highlight the closest point vertically.
  2372. *
  2373. * @private
  2374. * @function Highcharts.Chart#highlightAdjacentPointVertical
  2375. *
  2376. * @param {boolean} down
  2377. *
  2378. * @return {Highcharts.Point|boolean}
  2379. */
  2380. Chart.prototype.highlightAdjacentPointVertical = function (down) {
  2381. var curPoint = this.highlightedPoint,
  2382. minDistance = Infinity,
  2383. bestPoint;
  2384. if (!defined(curPoint.plotX) || !defined(curPoint.plotY)) {
  2385. return false;
  2386. }
  2387. this.series.forEach(function (series) {
  2388. if (isSkipSeries(series)) {
  2389. return;
  2390. }
  2391. series.points.forEach(function (point) {
  2392. if (!defined(point.plotY) || !defined(point.plotX) ||
  2393. point === curPoint) {
  2394. return;
  2395. }
  2396. var yDistance = point.plotY - curPoint.plotY,
  2397. width = Math.abs(point.plotX - curPoint.plotX),
  2398. distance = Math.abs(yDistance) * Math.abs(yDistance) +
  2399. width * width * 4; // Weigh horizontal distance highly
  2400. // Reverse distance number if axis is reversed
  2401. if (series.yAxis && series.yAxis.reversed) {
  2402. yDistance *= -1;
  2403. }
  2404. if (yDistance <= 0 && down || yDistance >= 0 && !down || // Chk dir
  2405. distance < 5 || // Points in same spot => infinite loop
  2406. isSkipPoint(point)) {
  2407. return;
  2408. }
  2409. if (distance < minDistance) {
  2410. minDistance = distance;
  2411. bestPoint = point;
  2412. }
  2413. });
  2414. });
  2415. return bestPoint ? bestPoint.highlight() : false;
  2416. };
  2417. /**
  2418. * @private
  2419. * @param {Highcharts.Chart} chart
  2420. * @return {Highcharts.Point|boolean}
  2421. */
  2422. function highlightFirstValidPointInChart(chart) {
  2423. var res = false;
  2424. delete chart.highlightedPoint;
  2425. res = chart.series.reduce(function (acc, cur) {
  2426. return acc || cur.highlightFirstValidPoint();
  2427. }, false);
  2428. return res;
  2429. }
  2430. /**
  2431. * @private
  2432. * @param {Highcharts.Chart} chart
  2433. * @return {Highcharts.Point|boolean}
  2434. */
  2435. function highlightLastValidPointInChart(chart) {
  2436. var numSeries = chart.series.length,
  2437. i = numSeries,
  2438. res = false;
  2439. while (i--) {
  2440. chart.highlightedPoint = chart.series[i].points[chart.series[i].points.length - 1];
  2441. // Highlight first valid point in the series will also
  2442. // look backwards. It always starts from currently
  2443. // highlighted point.
  2444. res = chart.series[i].highlightFirstValidPoint();
  2445. if (res) {
  2446. break;
  2447. }
  2448. }
  2449. return res;
  2450. }
  2451. /**
  2452. * @private
  2453. * @param {Highcharts.Chart} chart
  2454. */
  2455. function updateChartFocusAfterDrilling(chart) {
  2456. highlightFirstValidPointInChart(chart);
  2457. if (chart.focusElement) {
  2458. chart.focusElement.removeFocusBorder();
  2459. }
  2460. }
  2461. /**
  2462. * @private
  2463. * @class
  2464. * @name Highcharts.SeriesKeyboardNavigation
  2465. */
  2466. function SeriesKeyboardNavigation(chart, keyCodes) {
  2467. this.keyCodes = keyCodes;
  2468. this.chart = chart;
  2469. }
  2470. extend(SeriesKeyboardNavigation.prototype, /** @lends Highcharts.SeriesKeyboardNavigation */ {
  2471. /**
  2472. * Init the keyboard navigation
  2473. */
  2474. init: function () {
  2475. var keyboardNavigation = this,
  2476. chart = this.chart,
  2477. e = this.eventProvider = new EventProvider();
  2478. e.addEvent(H.Series, 'destroy', function () {
  2479. return keyboardNavigation.onSeriesDestroy(this);
  2480. });
  2481. e.addEvent(chart, 'afterDrilldown', function () {
  2482. updateChartFocusAfterDrilling(this);
  2483. });
  2484. e.addEvent(chart, 'drilldown', function (e) {
  2485. var point = e.point,
  2486. series = point.series;
  2487. keyboardNavigation.lastDrilledDownPoint = {
  2488. x: point.x,
  2489. y: point.y,
  2490. seriesName: series ? series.name : ''
  2491. };
  2492. });
  2493. e.addEvent(chart, 'drillupall', function () {
  2494. setTimeout(function () {
  2495. keyboardNavigation.onDrillupAll();
  2496. }, 10);
  2497. });
  2498. },
  2499. onDrillupAll: function () {
  2500. // After drillup we want to find the point that was drilled down to and
  2501. // highlight it.
  2502. var last = this.lastDrilledDownPoint,
  2503. chart = this.chart,
  2504. series = last && getSeriesFromName(chart,
  2505. last.seriesName),
  2506. point;
  2507. if (last && series && defined(last.x) && defined(last.y)) {
  2508. point = getPointFromXY(series, last.x, last.y);
  2509. }
  2510. // Container focus can be lost on drillup due to deleted elements.
  2511. if (chart.container) {
  2512. chart.container.focus();
  2513. }
  2514. if (point && point.highlight) {
  2515. point.highlight();
  2516. }
  2517. if (chart.focusElement) {
  2518. chart.focusElement.removeFocusBorder();
  2519. }
  2520. },
  2521. /**
  2522. * @return {Highcharts.KeyboardNavigationHandler}
  2523. */
  2524. getKeyboardNavigationHandler: function () {
  2525. var keyboardNavigation = this,
  2526. keys = this.keyCodes,
  2527. chart = this.chart,
  2528. inverted = chart.inverted;
  2529. return new KeyboardNavigationHandler(chart, {
  2530. keyCodeMap: [
  2531. [inverted ? [keys.up, keys.down] : [keys.left, keys.right], function (keyCode) {
  2532. return keyboardNavigation.onKbdSideways(this, keyCode);
  2533. }],
  2534. [inverted ? [keys.left, keys.right] : [keys.up, keys.down], function (keyCode) {
  2535. return keyboardNavigation.onKbdVertical(this, keyCode);
  2536. }],
  2537. [[keys.enter, keys.space], function () {
  2538. if (chart.highlightedPoint) {
  2539. chart.highlightedPoint.firePointEvent('click');
  2540. }
  2541. return this.response.success;
  2542. }]
  2543. ],
  2544. init: function (dir) {
  2545. return keyboardNavigation.onHandlerInit(this, dir);
  2546. },
  2547. terminate: function () {
  2548. return keyboardNavigation.onHandlerTerminate();
  2549. }
  2550. });
  2551. },
  2552. /**
  2553. * @private
  2554. * @param {Highcharts.KeyboardNavigationHandler} handler
  2555. * @param {number} keyCode
  2556. * @return {number}
  2557. * response
  2558. */
  2559. onKbdSideways: function (handler, keyCode) {
  2560. var keys = this.keyCodes,
  2561. isNext = keyCode === keys.right || keyCode === keys.down;
  2562. return this.attemptHighlightAdjacentPoint(handler, isNext);
  2563. },
  2564. /**
  2565. * @private
  2566. * @param {Highcharts.KeyboardNavigationHandler} handler
  2567. * @param {number} keyCode
  2568. * @return {number}
  2569. * response
  2570. */
  2571. onKbdVertical: function (handler, keyCode) {
  2572. var chart = this.chart,
  2573. keys = this.keyCodes,
  2574. isNext = keyCode === keys.down || keyCode === keys.right,
  2575. navOptions = chart.options.accessibility.keyboardNavigation
  2576. .seriesNavigation;
  2577. // Handle serialized mode, act like left/right
  2578. if (navOptions.mode && navOptions.mode === 'serialize') {
  2579. return this.attemptHighlightAdjacentPoint(handler, isNext);
  2580. }
  2581. // Normal mode, move between series
  2582. var highlightMethod = (chart.highlightedPoint &&
  2583. chart.highlightedPoint.series.keyboardMoveVertical) ?
  2584. 'highlightAdjacentPointVertical' :
  2585. 'highlightAdjacentSeries';
  2586. chart[highlightMethod](isNext);
  2587. return handler.response.success;
  2588. },
  2589. /**
  2590. * @private
  2591. * @param {Highcharts.KeyboardNavigationHandler} handler
  2592. * @param {number} initDirection
  2593. * @return {number}
  2594. * response
  2595. */
  2596. onHandlerInit: function (handler, initDirection) {
  2597. var chart = this.chart;
  2598. if (initDirection > 0) {
  2599. highlightFirstValidPointInChart(chart);
  2600. }
  2601. else {
  2602. highlightLastValidPointInChart(chart);
  2603. }
  2604. return handler.response.success;
  2605. },
  2606. /**
  2607. * @private
  2608. */
  2609. onHandlerTerminate: function () {
  2610. var _a,
  2611. _b;
  2612. var chart = this.chart;
  2613. var curPoint = chart.highlightedPoint;
  2614. (_a = chart.tooltip) === null || _a === void 0 ? void 0 : _a.hide(0);
  2615. (_b = curPoint === null || curPoint === void 0 ? void 0 : curPoint.onMouseOut) === null || _b === void 0 ? void 0 : _b.call(curPoint);
  2616. delete chart.highlightedPoint;
  2617. },
  2618. /**
  2619. * Function that attempts to highlight next/prev point. Handles wrap around.
  2620. * @private
  2621. * @param {Highcharts.KeyboardNavigationHandler} handler
  2622. * @param {boolean} directionIsNext
  2623. * @return {number}
  2624. * response
  2625. */
  2626. attemptHighlightAdjacentPoint: function (handler, directionIsNext) {
  2627. var chart = this.chart,
  2628. wrapAround = chart.options.accessibility.keyboardNavigation
  2629. .wrapAround,
  2630. highlightSuccessful = chart.highlightAdjacentPoint(directionIsNext);
  2631. if (!highlightSuccessful) {
  2632. if (wrapAround) {
  2633. return handler.init(directionIsNext ? 1 : -1);
  2634. }
  2635. return handler.response[directionIsNext ? 'next' : 'prev'];
  2636. }
  2637. return handler.response.success;
  2638. },
  2639. /**
  2640. * @private
  2641. */
  2642. onSeriesDestroy: function (series) {
  2643. var chart = this.chart,
  2644. currentHighlightedPointDestroyed = chart.highlightedPoint &&
  2645. chart.highlightedPoint.series === series;
  2646. if (currentHighlightedPointDestroyed) {
  2647. delete chart.highlightedPoint;
  2648. if (chart.focusElement) {
  2649. chart.focusElement.removeFocusBorder();
  2650. }
  2651. }
  2652. },
  2653. /**
  2654. * @private
  2655. */
  2656. destroy: function () {
  2657. this.eventProvider.removeAddedEvents();
  2658. }
  2659. });
  2660. return SeriesKeyboardNavigation;
  2661. });
  2662. _registerModule(_modules, 'Accessibility/Components/AnnotationsA11y.js', [_modules['Accessibility/Utils/HTMLUtilities.js']], function (HTMLUtilities) {
  2663. /* *
  2664. *
  2665. * (c) 2009-2019 Øystein Moseng
  2666. *
  2667. * Annotations accessibility code.
  2668. *
  2669. * License: www.highcharts.com/license
  2670. *
  2671. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2672. *
  2673. * */
  2674. var escapeStringForHTML = HTMLUtilities.escapeStringForHTML,
  2675. stripHTMLTagsFromString = HTMLUtilities.stripHTMLTagsFromString;
  2676. /**
  2677. * Get list of all annotation labels in the chart.
  2678. *
  2679. * @private
  2680. * @param {Highcharts.Chart} chart The chart to get annotation info on.
  2681. * @return {Array<object>} The labels, or empty array if none.
  2682. */
  2683. function getChartAnnotationLabels(chart) {
  2684. var annotations = chart.annotations || [];
  2685. return annotations.reduce(function (acc, cur) {
  2686. var _a;
  2687. if (((_a = cur.options) === null || _a === void 0 ? void 0 : _a.visible) !== false) {
  2688. acc = acc.concat(cur.labels);
  2689. }
  2690. return acc;
  2691. }, []);
  2692. }
  2693. /**
  2694. * Get the text of an annotation label.
  2695. *
  2696. * @private
  2697. * @param {object} label The annotation label object
  2698. * @return {string} The text in the label.
  2699. */
  2700. function getLabelText(label) {
  2701. var _a,
  2702. _b,
  2703. _c,
  2704. _d;
  2705. var a11yDesc = (_b = (_a = label.options) === null || _a === void 0 ? void 0 : _a.accessibility) === null || _b === void 0 ? void 0 : _b.description;
  2706. return a11yDesc ? a11yDesc : ((_d = (_c = label.graphic) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.textStr) || '';
  2707. }
  2708. /**
  2709. * Describe an annotation label.
  2710. *
  2711. * @private
  2712. * @param {object} label The annotation label object to describe
  2713. * @return {string} The description for the label.
  2714. */
  2715. function getAnnotationLabelDescription(label) {
  2716. var _a,
  2717. _b;
  2718. var a11yDesc = (_b = (_a = label.options) === null || _a === void 0 ? void 0 : _a.accessibility) === null || _b === void 0 ? void 0 : _b.description;
  2719. if (a11yDesc) {
  2720. return a11yDesc;
  2721. }
  2722. var chart = label.chart;
  2723. var labelText = getLabelText(label);
  2724. var points = label.points;
  2725. var getAriaLabel = function (point) { var _a,
  2726. _b; return ((_b = (_a = point === null || point === void 0 ? void 0 : point.graphic) === null || _a === void 0 ? void 0 : _a.element) === null || _b === void 0 ? void 0 : _b.getAttribute('aria-label')) || ''; };
  2727. var getValueDesc = function (point) {
  2728. var _a;
  2729. var valDesc = ((_a = point === null || point === void 0 ? void 0 : point.accessibility) === null || _a === void 0 ? void 0 : _a.valueDescription) || getAriaLabel(point);
  2730. var seriesName = (point === null || point === void 0 ? void 0 : point.series.name) || '';
  2731. return (seriesName ? seriesName + ', ' : '') + 'data point ' + valDesc;
  2732. };
  2733. var pointValueDescriptions = points
  2734. .filter(function (p) { return !!p.graphic; }) // Filter out mock points
  2735. .map(getValueDesc)
  2736. .filter(function (desc) { return !!desc; }); // Filter out points we can't describe
  2737. var numPoints = pointValueDescriptions.length;
  2738. var pointsSelector = numPoints > 1 ? 'MultiplePoints' : numPoints ? 'SinglePoint' : 'NoPoints';
  2739. var langFormatStr = 'accessibility.screenReaderSection.annotations.description' + pointsSelector;
  2740. var context = {
  2741. annotationText: labelText,
  2742. numPoints: numPoints,
  2743. annotationPoint: pointValueDescriptions[0],
  2744. additionalAnnotationPoints: pointValueDescriptions.slice(1)
  2745. };
  2746. return chart.langFormat(langFormatStr, context);
  2747. }
  2748. /**
  2749. * Return array of HTML strings for each annotation label in the chart.
  2750. *
  2751. * @private
  2752. * @param {Highcharts.Chart} chart The chart to get annotation info on.
  2753. * @return {Array<string>} Array of strings with HTML content for each annotation label.
  2754. */
  2755. function getAnnotationListItems(chart) {
  2756. var labels = getChartAnnotationLabels(chart);
  2757. return labels.map(function (label) {
  2758. var desc = escapeStringForHTML(stripHTMLTagsFromString(getAnnotationLabelDescription(label)));
  2759. return desc ? "<li>" + desc + "</li>" : '';
  2760. });
  2761. }
  2762. /**
  2763. * Return the annotation info for a chart as string.
  2764. *
  2765. * @private
  2766. * @param {Highcharts.Chart} chart The chart to get annotation info on.
  2767. * @return {string} String with HTML content or empty string if no annotations.
  2768. */
  2769. function getAnnotationsInfoHTML(chart) {
  2770. var annotations = chart.annotations;
  2771. if (!(annotations && annotations.length)) {
  2772. return '';
  2773. }
  2774. var annotationItems = getAnnotationListItems(chart);
  2775. return "<ul>" + annotationItems.join(' ') + "</ul>";
  2776. }
  2777. /**
  2778. * Return the texts for the annotation(s) connected to a point, or empty array
  2779. * if none.
  2780. *
  2781. * @private
  2782. * @param {Highcharts.Point} point The data point to get the annotation info from.
  2783. * @return {Array<string>} Annotation texts
  2784. */
  2785. function getPointAnnotationTexts(point) {
  2786. var labels = getChartAnnotationLabels(point.series.chart);
  2787. var pointLabels = labels
  2788. .filter(function (label) { return label.points.indexOf(point) > -1; });
  2789. if (!pointLabels.length) {
  2790. return [];
  2791. }
  2792. return pointLabels.map(function (label) { return "" + getLabelText(label); });
  2793. }
  2794. var AnnotationsA11y = {
  2795. getAnnotationsInfoHTML: getAnnotationsInfoHTML,
  2796. getAnnotationLabelDescription: getAnnotationLabelDescription,
  2797. getAnnotationListItems: getAnnotationListItems,
  2798. getPointAnnotationTexts: getPointAnnotationTexts
  2799. };
  2800. return AnnotationsA11y;
  2801. });
  2802. _registerModule(_modules, 'Accessibility/Components/SeriesComponent/SeriesDescriber.js', [_modules['Core/Utilities.js'], _modules['Accessibility/Components/AnnotationsA11y.js'], _modules['Accessibility/Utils/HTMLUtilities.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Core/Tooltip.js']], function (U, AnnotationsA11y, HTMLUtilities, ChartUtilities, Tooltip) {
  2803. /* *
  2804. *
  2805. * (c) 2009-2020 Øystein Moseng
  2806. *
  2807. * Place desriptions on a series and its points.
  2808. *
  2809. * License: www.highcharts.com/license
  2810. *
  2811. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2812. *
  2813. * */
  2814. var find = U.find,
  2815. format = U.format,
  2816. isNumber = U.isNumber,
  2817. numberFormat = U.numberFormat,
  2818. pick = U.pick,
  2819. defined = U.defined;
  2820. var getPointAnnotationTexts = AnnotationsA11y.getPointAnnotationTexts;
  2821. var escapeStringForHTML = HTMLUtilities.escapeStringForHTML,
  2822. reverseChildNodes = HTMLUtilities.reverseChildNodes,
  2823. stripHTMLTags = HTMLUtilities.stripHTMLTagsFromString;
  2824. var getAxisDescription = ChartUtilities.getAxisDescription,
  2825. getSeriesFirstPointElement = ChartUtilities.getSeriesFirstPointElement,
  2826. getSeriesA11yElement = ChartUtilities.getSeriesA11yElement,
  2827. unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT;
  2828. /* eslint-disable valid-jsdoc */
  2829. /**
  2830. * @private
  2831. */
  2832. function findFirstPointWithGraphic(point) {
  2833. var sourcePointIndex = point.index;
  2834. if (!point.series || !point.series.data || !defined(sourcePointIndex)) {
  2835. return null;
  2836. }
  2837. return find(point.series.data, function (p) {
  2838. return !!(p &&
  2839. typeof p.index !== 'undefined' &&
  2840. p.index > sourcePointIndex &&
  2841. p.graphic &&
  2842. p.graphic.element);
  2843. }) || null;
  2844. }
  2845. /**
  2846. * @private
  2847. */
  2848. function shouldAddDummyPoint(point) {
  2849. // Note: Sunburst series use isNull for hidden points on drilldown.
  2850. // Ignore these.
  2851. var isSunburst = point.series && point.series.is('sunburst'),
  2852. isNull = point.isNull;
  2853. return isNull && !isSunburst;
  2854. }
  2855. /**
  2856. * @private
  2857. */
  2858. function makeDummyElement(point, pos) {
  2859. var renderer = point.series.chart.renderer,
  2860. dummy = renderer.rect(pos.x,
  2861. pos.y, 1, 1);
  2862. dummy.attr({
  2863. 'class': 'highcharts-a11y-dummy-point',
  2864. fill: 'none',
  2865. opacity: 0,
  2866. 'fill-opacity': 0,
  2867. 'stroke-opacity': 0
  2868. });
  2869. return dummy;
  2870. }
  2871. /**
  2872. * @private
  2873. * @param {Highcharts.Point} point
  2874. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement|undefined}
  2875. */
  2876. function addDummyPointElement(point) {
  2877. var series = point.series,
  2878. firstPointWithGraphic = findFirstPointWithGraphic(point),
  2879. firstGraphic = firstPointWithGraphic && firstPointWithGraphic.graphic,
  2880. parentGroup = firstGraphic ?
  2881. firstGraphic.parentGroup :
  2882. series.graph || series.group,
  2883. dummyPos = firstPointWithGraphic ? {
  2884. x: pick(point.plotX,
  2885. firstPointWithGraphic.plotX, 0),
  2886. y: pick(point.plotY,
  2887. firstPointWithGraphic.plotY, 0)
  2888. } : {
  2889. x: pick(point.plotX, 0),
  2890. y: pick(point.plotY, 0)
  2891. },
  2892. dummyElement = makeDummyElement(point,
  2893. dummyPos);
  2894. if (parentGroup && parentGroup.element) {
  2895. point.graphic = dummyElement;
  2896. point.hasDummyGraphic = true;
  2897. dummyElement.add(parentGroup);
  2898. // Move to correct pos in DOM
  2899. parentGroup.element.insertBefore(dummyElement.element, firstGraphic ? firstGraphic.element : null);
  2900. return dummyElement.element;
  2901. }
  2902. }
  2903. /**
  2904. * @private
  2905. * @param {Highcharts.Series} series
  2906. * @return {boolean}
  2907. */
  2908. function hasMorePointsThanDescriptionThreshold(series) {
  2909. var chartA11yOptions = series.chart.options.accessibility,
  2910. threshold = (chartA11yOptions.series.pointDescriptionEnabledThreshold);
  2911. return !!(threshold !== false &&
  2912. series.points &&
  2913. series.points.length >= threshold);
  2914. }
  2915. /**
  2916. * @private
  2917. * @param {Highcharts.Series} series
  2918. * @return {boolean}
  2919. */
  2920. function shouldSetScreenReaderPropsOnPoints(series) {
  2921. var seriesA11yOptions = series.options.accessibility || {};
  2922. return !hasMorePointsThanDescriptionThreshold(series) &&
  2923. !seriesA11yOptions.exposeAsGroupOnly;
  2924. }
  2925. /**
  2926. * @private
  2927. * @param {Highcharts.Series} series
  2928. * @return {boolean}
  2929. */
  2930. function shouldSetKeyboardNavPropsOnPoints(series) {
  2931. var chartA11yOptions = series.chart.options.accessibility,
  2932. seriesNavOptions = chartA11yOptions.keyboardNavigation.seriesNavigation;
  2933. return !!(series.points && (series.points.length <
  2934. seriesNavOptions.pointNavigationEnabledThreshold ||
  2935. seriesNavOptions.pointNavigationEnabledThreshold === false));
  2936. }
  2937. /**
  2938. * @private
  2939. * @param {Highcharts.Series} series
  2940. * @return {boolean}
  2941. */
  2942. function shouldDescribeSeriesElement(series) {
  2943. var chart = series.chart,
  2944. chartOptions = chart.options.chart || {},
  2945. chartHas3d = chartOptions.options3d && chartOptions.options3d.enabled,
  2946. hasMultipleSeries = chart.series.length > 1,
  2947. describeSingleSeriesOption = chart.options.accessibility.series.describeSingleSeries,
  2948. exposeAsGroupOnlyOption = (series.options.accessibility || {}).exposeAsGroupOnly,
  2949. noDescribe3D = chartHas3d && hasMultipleSeries;
  2950. return !noDescribe3D && (hasMultipleSeries || describeSingleSeriesOption ||
  2951. exposeAsGroupOnlyOption || hasMorePointsThanDescriptionThreshold(series));
  2952. }
  2953. /**
  2954. * @private
  2955. * @param {Highcharts.Point} point
  2956. * @param {number} value
  2957. * @return {string}
  2958. */
  2959. function pointNumberToString(point, value) {
  2960. var chart = point.series.chart,
  2961. a11yPointOptions = chart.options.accessibility.point || {},
  2962. tooltipOptions = point.series.tooltipOptions || {},
  2963. lang = chart.options.lang;
  2964. if (isNumber(value)) {
  2965. return numberFormat(value, a11yPointOptions.valueDecimals ||
  2966. tooltipOptions.valueDecimals ||
  2967. -1, lang.decimalPoint, lang.accessibility.thousandsSep || lang.thousandsSep);
  2968. }
  2969. return value;
  2970. }
  2971. /**
  2972. * @private
  2973. * @param {Highcharts.Series} series
  2974. * @return {string}
  2975. */
  2976. function getSeriesDescriptionText(series) {
  2977. var seriesA11yOptions = series.options.accessibility || {},
  2978. descOpt = seriesA11yOptions.description;
  2979. return descOpt && series.chart.langFormat('accessibility.series.description', {
  2980. description: descOpt,
  2981. series: series
  2982. }) || '';
  2983. }
  2984. /**
  2985. * @private
  2986. * @param {Highcharts.series} series
  2987. * @param {string} axisCollection
  2988. * @return {string}
  2989. */
  2990. function getSeriesAxisDescriptionText(series, axisCollection) {
  2991. var axis = series[axisCollection];
  2992. return series.chart.langFormat('accessibility.series.' + axisCollection + 'Description', {
  2993. name: getAxisDescription(axis),
  2994. series: series
  2995. });
  2996. }
  2997. /**
  2998. * Get accessible time description for a point on a datetime axis.
  2999. *
  3000. * @private
  3001. * @function Highcharts.Point#getTimeDescription
  3002. * @param {Highcharts.Point} point
  3003. * @return {string|undefined}
  3004. * The description as string.
  3005. */
  3006. function getPointA11yTimeDescription(point) {
  3007. var series = point.series,
  3008. chart = series.chart,
  3009. a11yOptions = chart.options.accessibility.point || {},
  3010. hasDateXAxis = series.xAxis && series.xAxis.dateTime;
  3011. if (hasDateXAxis) {
  3012. var tooltipDateFormat = Tooltip.prototype.getXDateFormat.call({
  3013. getDateFormat: Tooltip.prototype.getDateFormat,
  3014. chart: chart
  3015. },
  3016. point,
  3017. chart.options.tooltip,
  3018. series.xAxis),
  3019. dateFormat = a11yOptions.dateFormatter &&
  3020. a11yOptions.dateFormatter(point) ||
  3021. a11yOptions.dateFormat ||
  3022. tooltipDateFormat;
  3023. return chart.time.dateFormat(dateFormat, point.x, void 0);
  3024. }
  3025. }
  3026. /**
  3027. * @private
  3028. * @param {Highcharts.Point} point
  3029. * @return {string}
  3030. */
  3031. function getPointXDescription(point) {
  3032. var timeDesc = getPointA11yTimeDescription(point), xAxis = point.series.xAxis || {}, pointCategory = xAxis.categories && defined(point.category) &&
  3033. ('' + point.category).replace('<br/>', ' '), canUseId = point.id && point.id.indexOf('highcharts-') < 0, fallback = 'x, ' + point.x;
  3034. return point.name || timeDesc || pointCategory ||
  3035. (canUseId ? point.id : fallback);
  3036. }
  3037. /**
  3038. * @private
  3039. * @param {Highcharts.Point} point
  3040. * @param {string} prefix
  3041. * @param {string} suffix
  3042. * @return {string}
  3043. */
  3044. function getPointArrayMapValueDescription(point, prefix, suffix) {
  3045. var pre = prefix || '', suf = suffix || '', keyToValStr = function (key) {
  3046. var num = pointNumberToString(point, pick(point[key], point.options[key]));
  3047. return key + ': ' + pre + num + suf;
  3048. }, pointArrayMap = point.series.pointArrayMap;
  3049. return pointArrayMap.reduce(function (desc, key) {
  3050. return desc + (desc.length ? ', ' : '') + keyToValStr(key);
  3051. }, '');
  3052. }
  3053. /**
  3054. * @private
  3055. * @param {Highcharts.Point} point
  3056. * @return {string}
  3057. */
  3058. function getPointValue(point) {
  3059. var series = point.series,
  3060. a11yPointOpts = series.chart.options.accessibility.point || {},
  3061. tooltipOptions = series.tooltipOptions || {},
  3062. valuePrefix = a11yPointOpts.valuePrefix ||
  3063. tooltipOptions.valuePrefix || '',
  3064. valueSuffix = a11yPointOpts.valueSuffix ||
  3065. tooltipOptions.valueSuffix || '',
  3066. fallbackKey = (typeof point.value !==
  3067. 'undefined' ?
  3068. 'value' : 'y'),
  3069. fallbackDesc = pointNumberToString(point,
  3070. point[fallbackKey]);
  3071. if (point.isNull) {
  3072. return series.chart.langFormat('accessibility.series.nullPointValue', {
  3073. point: point
  3074. });
  3075. }
  3076. if (series.pointArrayMap) {
  3077. return getPointArrayMapValueDescription(point, valuePrefix, valueSuffix);
  3078. }
  3079. return valuePrefix + fallbackDesc + valueSuffix;
  3080. }
  3081. /**
  3082. * Return the description for the annotation(s) connected to a point, or empty
  3083. * string if none.
  3084. *
  3085. * @private
  3086. * @param {Highcharts.Point} point The data point to get the annotation info from.
  3087. * @return {string} Annotation description
  3088. */
  3089. function getPointAnnotationDescription(point) {
  3090. var chart = point.series.chart;
  3091. var langKey = 'accessibility.series.pointAnnotationsDescription';
  3092. var annotations = getPointAnnotationTexts(point);
  3093. var context = { point: point,
  3094. annotations: annotations };
  3095. return annotations.length ? chart.langFormat(langKey, context) : '';
  3096. }
  3097. /**
  3098. * Return string with information about point.
  3099. * @private
  3100. * @return {string}
  3101. */
  3102. function getPointValueDescription(point) {
  3103. var series = point.series, chart = series.chart, pointValueDescriptionFormat = chart.options.accessibility
  3104. .point.valueDescriptionFormat, showXDescription = pick(series.xAxis &&
  3105. series.xAxis.options.accessibility &&
  3106. series.xAxis.options.accessibility.enabled, !chart.angular), xDesc = showXDescription ? getPointXDescription(point) : '', context = {
  3107. point: point,
  3108. index: defined(point.index) ? (point.index + 1) : '',
  3109. xDescription: xDesc,
  3110. value: getPointValue(point),
  3111. separator: showXDescription ? ', ' : ''
  3112. };
  3113. return format(pointValueDescriptionFormat, context, chart);
  3114. }
  3115. /**
  3116. * Return string with information about point.
  3117. * @private
  3118. * @return {string}
  3119. */
  3120. function defaultPointDescriptionFormatter(point) {
  3121. var series = point.series, chart = series.chart, valText = getPointValueDescription(point), description = point.options && point.options.accessibility &&
  3122. point.options.accessibility.description, userDescText = description ? ' ' + description : '', seriesNameText = chart.series.length > 1 && series.name ?
  3123. ' ' + series.name + '.' : '', annotationsDesc = getPointAnnotationDescription(point), pointAnnotationsText = annotationsDesc ? ' ' + annotationsDesc : '';
  3124. point.accessibility = point.accessibility || {};
  3125. point.accessibility.valueDescription = valText;
  3126. return valText + userDescText + seriesNameText + pointAnnotationsText;
  3127. }
  3128. /**
  3129. * Set a11y props on a point element
  3130. * @private
  3131. * @param {Highcharts.Point} point
  3132. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} pointElement
  3133. */
  3134. function setPointScreenReaderAttribs(point, pointElement) {
  3135. var series = point.series,
  3136. a11yPointOptions = series.chart.options.accessibility.point || {},
  3137. seriesA11yOptions = series.options.accessibility || {},
  3138. label = escapeStringForHTML(stripHTMLTags(seriesA11yOptions.pointDescriptionFormatter &&
  3139. seriesA11yOptions.pointDescriptionFormatter(point) ||
  3140. a11yPointOptions.descriptionFormatter &&
  3141. a11yPointOptions.descriptionFormatter(point) ||
  3142. defaultPointDescriptionFormatter(point)));
  3143. pointElement.setAttribute('role', 'img');
  3144. pointElement.setAttribute('aria-label', label);
  3145. }
  3146. /**
  3147. * Add accessible info to individual point elements of a series
  3148. * @private
  3149. * @param {Highcharts.Series} series
  3150. */
  3151. function describePointsInSeries(series) {
  3152. var setScreenReaderProps = shouldSetScreenReaderPropsOnPoints(series),
  3153. setKeyboardProps = shouldSetKeyboardNavPropsOnPoints(series);
  3154. if (setScreenReaderProps || setKeyboardProps) {
  3155. series.points.forEach(function (point) {
  3156. var pointEl = point.graphic && point.graphic.element ||
  3157. shouldAddDummyPoint(point) && addDummyPointElement(point);
  3158. if (pointEl) {
  3159. // We always set tabindex, as long as we are setting props.
  3160. // When setting tabindex, also remove default outline to
  3161. // avoid ugly border on click.
  3162. pointEl.setAttribute('tabindex', '-1');
  3163. pointEl.style.outline = '0';
  3164. if (setScreenReaderProps) {
  3165. setPointScreenReaderAttribs(point, pointEl);
  3166. }
  3167. else {
  3168. pointEl.setAttribute('aria-hidden', true);
  3169. }
  3170. }
  3171. });
  3172. }
  3173. }
  3174. /**
  3175. * Return string with information about series.
  3176. * @private
  3177. * @return {string}
  3178. */
  3179. function defaultSeriesDescriptionFormatter(series) {
  3180. var chart = series.chart,
  3181. chartTypes = chart.types || [],
  3182. description = getSeriesDescriptionText(series),
  3183. shouldDescribeAxis = function (coll) {
  3184. return chart[coll] && chart[coll].length > 1 && series[coll];
  3185. }, xAxisInfo = getSeriesAxisDescriptionText(series, 'xAxis'), yAxisInfo = getSeriesAxisDescriptionText(series, 'yAxis'), summaryContext = {
  3186. name: series.name || '',
  3187. ix: series.index + 1,
  3188. numSeries: chart.series && chart.series.length,
  3189. numPoints: series.points && series.points.length,
  3190. series: series
  3191. }, combinationSuffix = chartTypes.length > 1 ? 'Combination' : '', summary = chart.langFormat('accessibility.series.summary.' + series.type + combinationSuffix, summaryContext) || chart.langFormat('accessibility.series.summary.default' + combinationSuffix, summaryContext);
  3192. return summary + (description ? ' ' + description : '') + (shouldDescribeAxis('yAxis') ? ' ' + yAxisInfo : '') + (shouldDescribeAxis('xAxis') ? ' ' + xAxisInfo : '');
  3193. }
  3194. /**
  3195. * Set a11y props on a series element
  3196. * @private
  3197. * @param {Highcharts.Series} series
  3198. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} seriesElement
  3199. */
  3200. function describeSeriesElement(series, seriesElement) {
  3201. var seriesA11yOptions = series.options.accessibility || {},
  3202. a11yOptions = series.chart.options.accessibility,
  3203. landmarkVerbosity = a11yOptions.landmarkVerbosity;
  3204. // Handle role attribute
  3205. if (seriesA11yOptions.exposeAsGroupOnly) {
  3206. seriesElement.setAttribute('role', 'img');
  3207. }
  3208. else if (landmarkVerbosity === 'all') {
  3209. seriesElement.setAttribute('role', 'region');
  3210. } /* else do not add role */
  3211. seriesElement.setAttribute('tabindex', '-1');
  3212. seriesElement.style.outline = '0'; // Don't show browser outline on click, despite tabindex
  3213. seriesElement.setAttribute('aria-label', escapeStringForHTML(stripHTMLTags(a11yOptions.series.descriptionFormatter &&
  3214. a11yOptions.series.descriptionFormatter(series) ||
  3215. defaultSeriesDescriptionFormatter(series))));
  3216. }
  3217. /**
  3218. * Put accessible info on series and points of a series.
  3219. * @param {Highcharts.Series} series The series to add info on.
  3220. */
  3221. function describeSeries(series) {
  3222. var chart = series.chart,
  3223. firstPointEl = getSeriesFirstPointElement(series),
  3224. seriesEl = getSeriesA11yElement(series),
  3225. is3d = chart.is3d && chart.is3d();
  3226. if (seriesEl) {
  3227. // For some series types the order of elements do not match the
  3228. // order of points in series. In that case we have to reverse them
  3229. // in order for AT to read them out in an understandable order.
  3230. // Due to z-index issues we can not do this for 3D charts.
  3231. if (seriesEl.lastChild === firstPointEl && !is3d) {
  3232. reverseChildNodes(seriesEl);
  3233. }
  3234. describePointsInSeries(series);
  3235. unhideChartElementFromAT(chart, seriesEl);
  3236. if (shouldDescribeSeriesElement(series)) {
  3237. describeSeriesElement(series, seriesEl);
  3238. }
  3239. else {
  3240. seriesEl.setAttribute('aria-label', '');
  3241. }
  3242. }
  3243. }
  3244. var SeriesDescriber = {
  3245. describeSeries: describeSeries,
  3246. defaultPointDescriptionFormatter: defaultPointDescriptionFormatter,
  3247. defaultSeriesDescriptionFormatter: defaultSeriesDescriptionFormatter,
  3248. getPointA11yTimeDescription: getPointA11yTimeDescription,
  3249. getPointXDescription: getPointXDescription,
  3250. getPointValue: getPointValue,
  3251. getPointValueDescription: getPointValueDescription
  3252. };
  3253. return SeriesDescriber;
  3254. });
  3255. _registerModule(_modules, 'Accessibility/Utils/Announcer.js', [_modules['Core/Globals.js'], _modules['Accessibility/Utils/DOMElementProvider.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, DOMElementProvider, HTMLUtilities) {
  3256. /* *
  3257. *
  3258. * (c) 2009-2020 Øystein Moseng
  3259. *
  3260. * Create announcer to speak messages to screen readers and other AT.
  3261. *
  3262. * License: www.highcharts.com/license
  3263. *
  3264. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3265. *
  3266. * */
  3267. var visuallyHideElement = HTMLUtilities.visuallyHideElement;
  3268. var Announcer = /** @class */ (function () {
  3269. function Announcer(chart, type) {
  3270. this.chart = chart;
  3271. this.domElementProvider = new DOMElementProvider();
  3272. this.announceRegion = this.addAnnounceRegion(type);
  3273. }
  3274. Announcer.prototype.destroy = function () {
  3275. this.domElementProvider.destroyCreatedElements();
  3276. };
  3277. Announcer.prototype.announce = function (message) {
  3278. var _this = this;
  3279. this.announceRegion.innerHTML = message;
  3280. // Delete contents after a little while to avoid user finding the live
  3281. // region in the DOM.
  3282. if (this.clearAnnouncementRegionTimer) {
  3283. clearTimeout(this.clearAnnouncementRegionTimer);
  3284. }
  3285. this.clearAnnouncementRegionTimer = setTimeout(function () {
  3286. _this.announceRegion.innerHTML = '';
  3287. delete _this.clearAnnouncementRegionTimer;
  3288. }, 1000);
  3289. };
  3290. Announcer.prototype.addAnnounceRegion = function (type) {
  3291. var chartContainer = this.chart.renderTo;
  3292. var div = this.domElementProvider.createElement('div');
  3293. div.setAttribute('aria-hidden', false);
  3294. div.setAttribute('aria-live', type);
  3295. visuallyHideElement(div);
  3296. chartContainer.insertBefore(div, chartContainer.firstChild);
  3297. return div;
  3298. };
  3299. return Announcer;
  3300. }());
  3301. H.Announcer = Announcer;
  3302. return Announcer;
  3303. });
  3304. _registerModule(_modules, 'Accessibility/Components/SeriesComponent/NewDataAnnouncer.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Components/SeriesComponent/SeriesDescriber.js'], _modules['Accessibility/Utils/Announcer.js'], _modules['Accessibility/Utils/EventProvider.js']], function (H, U, ChartUtilities, SeriesDescriber, Announcer, EventProvider) {
  3305. /* *
  3306. *
  3307. * (c) 2009-2020 Øystein Moseng
  3308. *
  3309. * Handle announcing new data for a chart.
  3310. *
  3311. * License: www.highcharts.com/license
  3312. *
  3313. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3314. *
  3315. * */
  3316. var extend = U.extend,
  3317. defined = U.defined;
  3318. var getChartTitle = ChartUtilities.getChartTitle;
  3319. var defaultPointDescriptionFormatter = SeriesDescriber
  3320. .defaultPointDescriptionFormatter,
  3321. defaultSeriesDescriptionFormatter = SeriesDescriber
  3322. .defaultSeriesDescriptionFormatter;
  3323. /* eslint-disable no-invalid-this, valid-jsdoc */
  3324. /**
  3325. * @private
  3326. */
  3327. function chartHasAnnounceEnabled(chart) {
  3328. return !!chart.options.accessibility.announceNewData.enabled;
  3329. }
  3330. /**
  3331. * @private
  3332. */
  3333. function findPointInDataArray(point) {
  3334. var candidates = point.series.data.filter(function (candidate) {
  3335. return point.x === candidate.x && point.y === candidate.y;
  3336. });
  3337. return candidates.length === 1 ? candidates[0] : point;
  3338. }
  3339. /**
  3340. * Get array of unique series from two arrays
  3341. * @private
  3342. */
  3343. function getUniqueSeries(arrayA, arrayB) {
  3344. var uniqueSeries = (arrayA || []).concat(arrayB || [])
  3345. .reduce(function (acc,
  3346. cur) {
  3347. acc[cur.name + cur.index] = cur;
  3348. return acc;
  3349. }, {});
  3350. return Object.keys(uniqueSeries).map(function (ix) {
  3351. return uniqueSeries[ix];
  3352. });
  3353. }
  3354. /**
  3355. * @private
  3356. * @class
  3357. */
  3358. var NewDataAnnouncer = function (chart) {
  3359. this.chart = chart;
  3360. };
  3361. extend(NewDataAnnouncer.prototype, {
  3362. /**
  3363. * Initialize the new data announcer.
  3364. * @private
  3365. */
  3366. init: function () {
  3367. var chart = this.chart;
  3368. var announceOptions = chart.options.accessibility.announceNewData;
  3369. var announceType = announceOptions.interruptUser ? 'assertive' : 'polite';
  3370. this.lastAnnouncementTime = 0;
  3371. this.dirty = {
  3372. allSeries: {}
  3373. };
  3374. this.eventProvider = new EventProvider();
  3375. this.announcer = new Announcer(chart, announceType);
  3376. this.addEventListeners();
  3377. },
  3378. /**
  3379. * Remove traces of announcer.
  3380. * @private
  3381. */
  3382. destroy: function () {
  3383. this.eventProvider.removeAddedEvents();
  3384. this.announcer.destroy();
  3385. },
  3386. /**
  3387. * Add event listeners for the announcer
  3388. * @private
  3389. */
  3390. addEventListeners: function () {
  3391. var announcer = this,
  3392. chart = this.chart,
  3393. e = this.eventProvider;
  3394. e.addEvent(chart, 'afterDrilldown', function () {
  3395. announcer.lastAnnouncementTime = 0;
  3396. });
  3397. e.addEvent(H.Series, 'updatedData', function () {
  3398. announcer.onSeriesUpdatedData(this);
  3399. });
  3400. e.addEvent(chart, 'afterAddSeries', function (e) {
  3401. announcer.onSeriesAdded(e.series);
  3402. });
  3403. e.addEvent(H.Series, 'addPoint', function (e) {
  3404. announcer.onPointAdded(e.point);
  3405. });
  3406. e.addEvent(chart, 'redraw', function () {
  3407. announcer.announceDirtyData();
  3408. });
  3409. },
  3410. /**
  3411. * On new data in the series, make sure we add it to the dirty list.
  3412. * @private
  3413. * @param {Highcharts.Series} series
  3414. */
  3415. onSeriesUpdatedData: function (series) {
  3416. var chart = this.chart;
  3417. if (series.chart === chart && chartHasAnnounceEnabled(chart)) {
  3418. this.dirty.hasDirty = true;
  3419. this.dirty.allSeries[series.name + series.index] = series;
  3420. }
  3421. },
  3422. /**
  3423. * On new data series added, update dirty list.
  3424. * @private
  3425. * @param {Highcharts.Series} series
  3426. */
  3427. onSeriesAdded: function (series) {
  3428. if (chartHasAnnounceEnabled(this.chart)) {
  3429. this.dirty.hasDirty = true;
  3430. this.dirty.allSeries[series.name + series.index] = series;
  3431. // Add it to newSeries storage unless we already have one
  3432. this.dirty.newSeries = defined(this.dirty.newSeries) ?
  3433. void 0 : series;
  3434. }
  3435. },
  3436. /**
  3437. * On new point added, update dirty list.
  3438. * @private
  3439. * @param {Highcharts.Point} point
  3440. */
  3441. onPointAdded: function (point) {
  3442. var chart = point.series.chart;
  3443. if (this.chart === chart && chartHasAnnounceEnabled(chart)) {
  3444. // Add it to newPoint storage unless we already have one
  3445. this.dirty.newPoint = defined(this.dirty.newPoint) ?
  3446. void 0 : point;
  3447. }
  3448. },
  3449. /**
  3450. * Gather what we know and announce the data to user.
  3451. * @private
  3452. */
  3453. announceDirtyData: function () {
  3454. var chart = this.chart,
  3455. announcer = this;
  3456. if (chart.options.accessibility.announceNewData &&
  3457. this.dirty.hasDirty) {
  3458. var newPoint = this.dirty.newPoint;
  3459. // If we have a single new point, see if we can find it in the
  3460. // data array. Otherwise we can only pass through options to
  3461. // the description builder, and it is a bit sparse in info.
  3462. if (newPoint) {
  3463. newPoint = findPointInDataArray(newPoint);
  3464. }
  3465. this.queueAnnouncement(Object.keys(this.dirty.allSeries).map(function (ix) {
  3466. return announcer.dirty.allSeries[ix];
  3467. }), this.dirty.newSeries, newPoint);
  3468. // Reset
  3469. this.dirty = {
  3470. allSeries: {}
  3471. };
  3472. }
  3473. },
  3474. /**
  3475. * Announce to user that there is new data.
  3476. * @private
  3477. * @param {Array<Highcharts.Series>} dirtySeries
  3478. * Array of series with new data.
  3479. * @param {Highcharts.Series} [newSeries]
  3480. * If a single new series was added, a reference to this series.
  3481. * @param {Highcharts.Point} [newPoint]
  3482. * If a single point was added, a reference to this point.
  3483. */
  3484. queueAnnouncement: function (dirtySeries, newSeries, newPoint) {
  3485. var _this = this;
  3486. var chart = this.chart;
  3487. var annOptions = chart.options.accessibility.announceNewData;
  3488. if (annOptions.enabled) {
  3489. var now = +new Date();
  3490. var dTime = now - this.lastAnnouncementTime;
  3491. var time = Math.max(0,
  3492. annOptions.minAnnounceInterval - dTime);
  3493. // Add series from previously queued announcement.
  3494. var allSeries = getUniqueSeries(this.queuedAnnouncement && this.queuedAnnouncement.series,
  3495. dirtySeries);
  3496. // Build message and announce
  3497. var message = this.buildAnnouncementMessage(allSeries,
  3498. newSeries,
  3499. newPoint);
  3500. if (message) {
  3501. // Is there already one queued?
  3502. if (this.queuedAnnouncement) {
  3503. clearTimeout(this.queuedAnnouncementTimer);
  3504. }
  3505. // Build the announcement
  3506. this.queuedAnnouncement = {
  3507. time: now,
  3508. message: message,
  3509. series: allSeries
  3510. };
  3511. // Queue the announcement
  3512. this.queuedAnnouncementTimer = setTimeout(function () {
  3513. if (_this && _this.announcer) {
  3514. _this.lastAnnouncementTime = +new Date();
  3515. _this.announcer.announce(_this.queuedAnnouncement.message);
  3516. delete _this.queuedAnnouncement;
  3517. delete _this.queuedAnnouncementTimer;
  3518. }
  3519. }, time);
  3520. }
  3521. }
  3522. },
  3523. /**
  3524. * Get announcement message for new data.
  3525. * @private
  3526. * @param {Array<Highcharts.Series>} dirtySeries
  3527. * Array of series with new data.
  3528. * @param {Highcharts.Series} [newSeries]
  3529. * If a single new series was added, a reference to this series.
  3530. * @param {Highcharts.Point} [newPoint]
  3531. * If a single point was added, a reference to this point.
  3532. *
  3533. * @return {string|null}
  3534. * The announcement message to give to user.
  3535. */
  3536. buildAnnouncementMessage: function (dirtySeries, newSeries, newPoint) {
  3537. var chart = this.chart,
  3538. annOptions = chart.options.accessibility.announceNewData;
  3539. // User supplied formatter?
  3540. if (annOptions.announcementFormatter) {
  3541. var formatterRes = annOptions.announcementFormatter(dirtySeries,
  3542. newSeries,
  3543. newPoint);
  3544. if (formatterRes !== false) {
  3545. return formatterRes.length ? formatterRes : null;
  3546. }
  3547. }
  3548. // Default formatter - use lang options
  3549. var multiple = H.charts && H.charts.length > 1 ? 'Multiple' : 'Single', langKey = newSeries ? 'newSeriesAnnounce' + multiple :
  3550. newPoint ? 'newPointAnnounce' + multiple : 'newDataAnnounce', chartTitle = getChartTitle(chart);
  3551. return chart.langFormat('accessibility.announceNewData.' + langKey, {
  3552. chartTitle: chartTitle,
  3553. seriesDesc: newSeries ?
  3554. defaultSeriesDescriptionFormatter(newSeries) :
  3555. null,
  3556. pointDesc: newPoint ?
  3557. defaultPointDescriptionFormatter(newPoint) :
  3558. null,
  3559. point: newPoint,
  3560. series: newSeries
  3561. });
  3562. }
  3563. });
  3564. return NewDataAnnouncer;
  3565. });
  3566. _registerModule(_modules, 'Accessibility/Components/SeriesComponent/ForcedMarkers.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  3567. /* *
  3568. *
  3569. * (c) 2009-2020 Øystein Moseng
  3570. *
  3571. * Handle forcing series markers.
  3572. *
  3573. * License: www.highcharts.com/license
  3574. *
  3575. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3576. *
  3577. * */
  3578. var addEvent = U.addEvent,
  3579. merge = U.merge;
  3580. /* eslint-disable no-invalid-this, valid-jsdoc */
  3581. /**
  3582. * @private
  3583. */
  3584. function isWithinDescriptionThreshold(series) {
  3585. var a11yOptions = series.chart.options.accessibility;
  3586. return series.points.length <
  3587. a11yOptions.series.pointDescriptionEnabledThreshold ||
  3588. a11yOptions.series.pointDescriptionEnabledThreshold === false;
  3589. }
  3590. /**
  3591. * @private
  3592. */
  3593. function shouldForceMarkers(series) {
  3594. var chart = series.chart,
  3595. chartA11yEnabled = chart.options.accessibility.enabled,
  3596. seriesA11yEnabled = (series.options.accessibility &&
  3597. series.options.accessibility.enabled) !== false;
  3598. return chartA11yEnabled && seriesA11yEnabled && isWithinDescriptionThreshold(series);
  3599. }
  3600. /**
  3601. * @private
  3602. */
  3603. function hasIndividualPointMarkerOptions(series) {
  3604. return !!(series._hasPointMarkers && series.points && series.points.length);
  3605. }
  3606. /**
  3607. * @private
  3608. */
  3609. function unforceSeriesMarkerOptions(series) {
  3610. var resetMarkerOptions = series.resetA11yMarkerOptions;
  3611. if (resetMarkerOptions) {
  3612. merge(true, series.options, {
  3613. marker: {
  3614. enabled: resetMarkerOptions.enabled,
  3615. states: {
  3616. normal: {
  3617. opacity: resetMarkerOptions.states &&
  3618. resetMarkerOptions.states.normal &&
  3619. resetMarkerOptions.states.normal.opacity
  3620. }
  3621. }
  3622. }
  3623. });
  3624. }
  3625. }
  3626. /**
  3627. * @private
  3628. */
  3629. function forceZeroOpacityMarkerOptions(options) {
  3630. merge(true, options, {
  3631. marker: {
  3632. enabled: true,
  3633. states: {
  3634. normal: {
  3635. opacity: 0
  3636. }
  3637. }
  3638. }
  3639. });
  3640. }
  3641. /**
  3642. * @private
  3643. */
  3644. function getPointMarkerOpacity(pointOptions) {
  3645. return pointOptions.marker.states &&
  3646. pointOptions.marker.states.normal &&
  3647. pointOptions.marker.states.normal.opacity || 1;
  3648. }
  3649. /**
  3650. * @private
  3651. */
  3652. function unforcePointMarkerOptions(pointOptions) {
  3653. merge(true, pointOptions.marker, {
  3654. states: {
  3655. normal: {
  3656. opacity: getPointMarkerOpacity(pointOptions)
  3657. }
  3658. }
  3659. });
  3660. }
  3661. /**
  3662. * @private
  3663. */
  3664. function handleForcePointMarkers(series) {
  3665. var i = series.points.length;
  3666. while (i--) {
  3667. var point = series.points[i];
  3668. var pointOptions = point.options;
  3669. delete point.hasForcedA11yMarker;
  3670. if (pointOptions.marker) {
  3671. if (pointOptions.marker.enabled) {
  3672. unforcePointMarkerOptions(pointOptions);
  3673. point.hasForcedA11yMarker = false;
  3674. }
  3675. else {
  3676. forceZeroOpacityMarkerOptions(pointOptions);
  3677. point.hasForcedA11yMarker = true;
  3678. }
  3679. }
  3680. }
  3681. }
  3682. /**
  3683. * @private
  3684. */
  3685. function addForceMarkersEvents() {
  3686. /**
  3687. * Keep track of forcing markers.
  3688. * @private
  3689. */
  3690. addEvent(H.Series, 'render', function () {
  3691. var series = this,
  3692. options = series.options;
  3693. if (shouldForceMarkers(series)) {
  3694. if (options.marker && options.marker.enabled === false) {
  3695. series.a11yMarkersForced = true;
  3696. forceZeroOpacityMarkerOptions(series.options);
  3697. }
  3698. if (hasIndividualPointMarkerOptions(series)) {
  3699. handleForcePointMarkers(series);
  3700. }
  3701. }
  3702. else if (series.a11yMarkersForced) {
  3703. delete series.a11yMarkersForced;
  3704. unforceSeriesMarkerOptions(series);
  3705. }
  3706. });
  3707. /**
  3708. * Keep track of options to reset markers to if no longer forced.
  3709. * @private
  3710. */
  3711. addEvent(H.Series, 'afterSetOptions', function (e) {
  3712. this.resetA11yMarkerOptions = merge(e.options.marker || {}, this.userOptions.marker || {});
  3713. });
  3714. /**
  3715. * Process marker graphics after render
  3716. * @private
  3717. */
  3718. addEvent(H.Series, 'afterRender', function () {
  3719. var series = this;
  3720. // For styled mode the rendered graphic does not reflect the style
  3721. // options, and we need to add/remove classes to achieve the same.
  3722. if (series.chart.styledMode) {
  3723. if (series.markerGroup) {
  3724. series.markerGroup[series.a11yMarkersForced ? 'addClass' : 'removeClass']('highcharts-a11y-markers-hidden');
  3725. }
  3726. // Do we need to handle individual points?
  3727. if (hasIndividualPointMarkerOptions(series)) {
  3728. series.points.forEach(function (point) {
  3729. if (point.graphic) {
  3730. point.graphic[point.hasForcedA11yMarker ? 'addClass' : 'removeClass']('highcharts-a11y-marker-hidden');
  3731. point.graphic[point.hasForcedA11yMarker === false ? 'addClass' : 'removeClass']('highcharts-a11y-marker-visible');
  3732. }
  3733. });
  3734. }
  3735. }
  3736. });
  3737. }
  3738. return addForceMarkersEvents;
  3739. });
  3740. _registerModule(_modules, 'Accessibility/Components/SeriesComponent/SeriesComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/Components/SeriesComponent/SeriesKeyboardNavigation.js'], _modules['Accessibility/Components/SeriesComponent/NewDataAnnouncer.js'], _modules['Accessibility/Components/SeriesComponent/ForcedMarkers.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Components/SeriesComponent/SeriesDescriber.js'], _modules['Core/Tooltip.js']], function (H, U, AccessibilityComponent, SeriesKeyboardNavigation, NewDataAnnouncer, addForceMarkersEvents, ChartUtilities, SeriesDescriber, Tooltip) {
  3741. /* *
  3742. *
  3743. * (c) 2009-2020 Øystein Moseng
  3744. *
  3745. * Accessibility component for series and points.
  3746. *
  3747. * License: www.highcharts.com/license
  3748. *
  3749. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3750. *
  3751. * */
  3752. var extend = U.extend;
  3753. var hideSeriesFromAT = ChartUtilities.hideSeriesFromAT;
  3754. var describeSeries = SeriesDescriber.describeSeries;
  3755. // Expose functionality to users
  3756. H.SeriesAccessibilityDescriber = SeriesDescriber;
  3757. // Handle forcing markers
  3758. addForceMarkersEvents();
  3759. /* eslint-disable no-invalid-this, valid-jsdoc */
  3760. /**
  3761. * The SeriesComponent class
  3762. *
  3763. * @private
  3764. * @class
  3765. * @name Highcharts.SeriesComponent
  3766. */
  3767. var SeriesComponent = function () { };
  3768. SeriesComponent.prototype = new AccessibilityComponent();
  3769. extend(SeriesComponent.prototype, /** @lends Highcharts.SeriesComponent */ {
  3770. /**
  3771. * Init the component.
  3772. */
  3773. init: function () {
  3774. this.newDataAnnouncer = new NewDataAnnouncer(this.chart);
  3775. this.newDataAnnouncer.init();
  3776. this.keyboardNavigation = new SeriesKeyboardNavigation(this.chart, this.keyCodes);
  3777. this.keyboardNavigation.init();
  3778. this.hideTooltipFromATWhenShown();
  3779. this.hideSeriesLabelsFromATWhenShown();
  3780. },
  3781. /**
  3782. * @private
  3783. */
  3784. hideTooltipFromATWhenShown: function () {
  3785. var component = this;
  3786. this.addEvent(Tooltip, 'refresh', function () {
  3787. if (this.chart === component.chart &&
  3788. this.label &&
  3789. this.label.element) {
  3790. this.label.element.setAttribute('aria-hidden', true);
  3791. }
  3792. });
  3793. },
  3794. /**
  3795. * @private
  3796. */
  3797. hideSeriesLabelsFromATWhenShown: function () {
  3798. this.addEvent(this.chart, 'afterDrawSeriesLabels', function () {
  3799. this.series.forEach(function (series) {
  3800. if (series.labelBySeries) {
  3801. series.labelBySeries.attr('aria-hidden', true);
  3802. }
  3803. });
  3804. });
  3805. },
  3806. /**
  3807. * Called on chart render. It is necessary to do this for render in case
  3808. * markers change on zoom/pixel density.
  3809. */
  3810. onChartRender: function () {
  3811. var chart = this.chart;
  3812. chart.series.forEach(function (series) {
  3813. var shouldDescribeSeries = (series.options.accessibility &&
  3814. series.options.accessibility.enabled) !== false &&
  3815. series.visible;
  3816. if (shouldDescribeSeries) {
  3817. describeSeries(series);
  3818. }
  3819. else {
  3820. hideSeriesFromAT(series);
  3821. }
  3822. });
  3823. },
  3824. /**
  3825. * Get keyboard navigation handler for this component.
  3826. * @return {Highcharts.KeyboardNavigationHandler}
  3827. */
  3828. getKeyboardNavigation: function () {
  3829. return this.keyboardNavigation.getKeyboardNavigationHandler();
  3830. },
  3831. /**
  3832. * Remove traces
  3833. */
  3834. destroy: function () {
  3835. this.newDataAnnouncer.destroy();
  3836. this.keyboardNavigation.destroy();
  3837. }
  3838. });
  3839. return SeriesComponent;
  3840. });
  3841. _registerModule(_modules, 'Accessibility/Components/ZoomComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, U, AccessibilityComponent, KeyboardNavigationHandler, ChartUtilities, HTMLUtilities) {
  3842. /* *
  3843. *
  3844. * (c) 2009-2020 Øystein Moseng
  3845. *
  3846. * Accessibility component for chart zoom.
  3847. *
  3848. * License: www.highcharts.com/license
  3849. *
  3850. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3851. *
  3852. * */
  3853. var extend = U.extend,
  3854. pick = U.pick;
  3855. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT;
  3856. var setElAttrs = HTMLUtilities.setElAttrs,
  3857. removeElement = HTMLUtilities.removeElement;
  3858. /* eslint-disable no-invalid-this, valid-jsdoc */
  3859. /**
  3860. * @private
  3861. */
  3862. function chartHasMapZoom(chart) {
  3863. return !!(chart.mapZoom &&
  3864. chart.mapNavButtons &&
  3865. chart.mapNavButtons.length);
  3866. }
  3867. /**
  3868. * Pan along axis in a direction (1 or -1), optionally with a defined
  3869. * granularity (number of steps it takes to walk across current view)
  3870. *
  3871. * @private
  3872. * @function Highcharts.Axis#panStep
  3873. *
  3874. * @param {number} direction
  3875. * @param {number} [granularity]
  3876. */
  3877. H.Axis.prototype.panStep = function (direction, granularity) {
  3878. var gran = granularity || 3,
  3879. extremes = this.getExtremes(),
  3880. step = (extremes.max - extremes.min) / gran * direction,
  3881. newMax = extremes.max + step,
  3882. newMin = extremes.min + step,
  3883. size = newMax - newMin;
  3884. if (direction < 0 && newMin < extremes.dataMin) {
  3885. newMin = extremes.dataMin;
  3886. newMax = newMin + size;
  3887. }
  3888. else if (direction > 0 && newMax > extremes.dataMax) {
  3889. newMax = extremes.dataMax;
  3890. newMin = newMax - size;
  3891. }
  3892. this.setExtremes(newMin, newMax);
  3893. };
  3894. /**
  3895. * The ZoomComponent class
  3896. *
  3897. * @private
  3898. * @class
  3899. * @name Highcharts.ZoomComponent
  3900. */
  3901. var ZoomComponent = function () { };
  3902. ZoomComponent.prototype = new AccessibilityComponent();
  3903. extend(ZoomComponent.prototype, /** @lends Highcharts.ZoomComponent */ {
  3904. /**
  3905. * Initialize the component
  3906. */
  3907. init: function () {
  3908. var component = this,
  3909. chart = this.chart;
  3910. [
  3911. 'afterShowResetZoom', 'afterDrilldown', 'drillupall'
  3912. ].forEach(function (eventType) {
  3913. component.addEvent(chart, eventType, function () {
  3914. component.updateProxyOverlays();
  3915. });
  3916. });
  3917. },
  3918. /**
  3919. * Called when chart is updated
  3920. */
  3921. onChartUpdate: function () {
  3922. var chart = this.chart,
  3923. component = this;
  3924. // Make map zoom buttons accessible
  3925. if (chart.mapNavButtons) {
  3926. chart.mapNavButtons.forEach(function (button, i) {
  3927. unhideChartElementFromAT(chart, button.element);
  3928. component.setMapNavButtonAttrs(button.element, 'accessibility.zoom.mapZoom' + (i ? 'Out' : 'In'));
  3929. });
  3930. }
  3931. },
  3932. /**
  3933. * @private
  3934. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} button
  3935. * @param {string} labelFormatKey
  3936. */
  3937. setMapNavButtonAttrs: function (button, labelFormatKey) {
  3938. var chart = this.chart,
  3939. label = chart.langFormat(labelFormatKey, { chart: chart });
  3940. setElAttrs(button, {
  3941. tabindex: -1,
  3942. role: 'button',
  3943. 'aria-label': label
  3944. });
  3945. },
  3946. /**
  3947. * Update the proxy overlays on every new render to ensure positions are
  3948. * correct.
  3949. */
  3950. onChartRender: function () {
  3951. this.updateProxyOverlays();
  3952. },
  3953. /**
  3954. * Update proxy overlays, recreating the buttons.
  3955. */
  3956. updateProxyOverlays: function () {
  3957. var chart = this.chart;
  3958. // Always start with a clean slate
  3959. removeElement(this.drillUpProxyGroup);
  3960. removeElement(this.resetZoomProxyGroup);
  3961. if (chart.resetZoomButton) {
  3962. this.recreateProxyButtonAndGroup(chart.resetZoomButton, 'resetZoomProxyButton', 'resetZoomProxyGroup', chart.langFormat('accessibility.zoom.resetZoomButton', { chart: chart }));
  3963. }
  3964. if (chart.drillUpButton) {
  3965. this.recreateProxyButtonAndGroup(chart.drillUpButton, 'drillUpProxyButton', 'drillUpProxyGroup', chart.langFormat('accessibility.drillUpButton', {
  3966. chart: chart,
  3967. buttonText: chart.getDrilldownBackText()
  3968. }));
  3969. }
  3970. },
  3971. /**
  3972. * @private
  3973. * @param {Highcharts.SVGElement} buttonEl
  3974. * @param {string} buttonProp
  3975. * @param {string} groupProp
  3976. * @param {string} label
  3977. */
  3978. recreateProxyButtonAndGroup: function (buttonEl, buttonProp, groupProp, label) {
  3979. removeElement(this[groupProp]);
  3980. this[groupProp] = this.addProxyGroup();
  3981. this[buttonProp] = this.createProxyButton(buttonEl, this[groupProp], { 'aria-label': label, tabindex: -1 });
  3982. },
  3983. /**
  3984. * Get keyboard navigation handler for map zoom.
  3985. * @private
  3986. * @return {Highcharts.KeyboardNavigationHandler} The module object
  3987. */
  3988. getMapZoomNavigation: function () {
  3989. var keys = this.keyCodes,
  3990. chart = this.chart,
  3991. component = this;
  3992. return new KeyboardNavigationHandler(chart, {
  3993. keyCodeMap: [
  3994. [
  3995. [keys.up, keys.down, keys.left, keys.right],
  3996. function (keyCode) {
  3997. return component.onMapKbdArrow(this, keyCode);
  3998. }
  3999. ],
  4000. [
  4001. [keys.tab],
  4002. function (_keyCode, e) {
  4003. return component.onMapKbdTab(this, e);
  4004. }
  4005. ],
  4006. [
  4007. [keys.space, keys.enter],
  4008. function () {
  4009. return component.onMapKbdClick(this);
  4010. }
  4011. ]
  4012. ],
  4013. validate: function () {
  4014. return chartHasMapZoom(chart);
  4015. },
  4016. init: function (direction) {
  4017. return component.onMapNavInit(direction);
  4018. }
  4019. });
  4020. },
  4021. /**
  4022. * @private
  4023. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  4024. * @param {number} keyCode
  4025. * @return {number} Response code
  4026. */
  4027. onMapKbdArrow: function (keyboardNavigationHandler, keyCode) {
  4028. var keys = this.keyCodes,
  4029. panAxis = (keyCode === keys.up || keyCode === keys.down) ?
  4030. 'yAxis' : 'xAxis',
  4031. stepDirection = (keyCode === keys.left || keyCode === keys.up) ?
  4032. -1 : 1;
  4033. this.chart[panAxis][0].panStep(stepDirection);
  4034. return keyboardNavigationHandler.response.success;
  4035. },
  4036. /**
  4037. * @private
  4038. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  4039. * @param {global.KeyboardEvent} event
  4040. * @return {number} Response code
  4041. */
  4042. onMapKbdTab: function (keyboardNavigationHandler, event) {
  4043. var button,
  4044. chart = this.chart,
  4045. response = keyboardNavigationHandler.response,
  4046. isBackwards = event.shiftKey,
  4047. isMoveOutOfRange = isBackwards && !this.focusedMapNavButtonIx ||
  4048. !isBackwards && this.focusedMapNavButtonIx;
  4049. // Deselect old
  4050. chart.mapNavButtons[this.focusedMapNavButtonIx].setState(0);
  4051. if (isMoveOutOfRange) {
  4052. chart.mapZoom(); // Reset zoom
  4053. return response[isBackwards ? 'prev' : 'next'];
  4054. }
  4055. // Select other button
  4056. this.focusedMapNavButtonIx += isBackwards ? -1 : 1;
  4057. button = chart.mapNavButtons[this.focusedMapNavButtonIx];
  4058. chart.setFocusToElement(button.box, button.element);
  4059. button.setState(2);
  4060. return response.success;
  4061. },
  4062. /**
  4063. * @private
  4064. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  4065. * @return {number} Response code
  4066. */
  4067. onMapKbdClick: function (keyboardNavigationHandler) {
  4068. this.fakeClickEvent(this.chart.mapNavButtons[this.focusedMapNavButtonIx]
  4069. .element);
  4070. return keyboardNavigationHandler.response.success;
  4071. },
  4072. /**
  4073. * @private
  4074. * @param {number} direction
  4075. */
  4076. onMapNavInit: function (direction) {
  4077. var chart = this.chart,
  4078. zoomIn = chart.mapNavButtons[0],
  4079. zoomOut = chart.mapNavButtons[1],
  4080. initialButton = direction > 0 ? zoomIn : zoomOut;
  4081. chart.setFocusToElement(initialButton.box, initialButton.element);
  4082. initialButton.setState(2);
  4083. this.focusedMapNavButtonIx = direction > 0 ? 0 : 1;
  4084. },
  4085. /**
  4086. * Get keyboard navigation handler for a simple chart button. Provide the
  4087. * button reference for the chart, and a function to call on click.
  4088. *
  4089. * @private
  4090. * @param {string} buttonProp The property on chart referencing the button.
  4091. * @return {Highcharts.KeyboardNavigationHandler} The module object
  4092. */
  4093. simpleButtonNavigation: function (buttonProp, proxyProp, onClick) {
  4094. var keys = this.keyCodes,
  4095. component = this,
  4096. chart = this.chart;
  4097. return new KeyboardNavigationHandler(chart, {
  4098. keyCodeMap: [
  4099. [
  4100. [keys.tab, keys.up, keys.down, keys.left, keys.right],
  4101. function (keyCode, e) {
  4102. var isBackwards = keyCode === keys.tab && e.shiftKey ||
  4103. keyCode === keys.left || keyCode === keys.up;
  4104. // Arrow/tab => just move
  4105. return this.response[isBackwards ? 'prev' : 'next'];
  4106. }
  4107. ],
  4108. [
  4109. [keys.space, keys.enter],
  4110. function () {
  4111. var res = onClick(this,
  4112. chart);
  4113. return pick(res, this.response.success);
  4114. }
  4115. ]
  4116. ],
  4117. validate: function () {
  4118. var hasButton = (chart[buttonProp] &&
  4119. chart[buttonProp].box &&
  4120. component[proxyProp]);
  4121. return hasButton;
  4122. },
  4123. init: function () {
  4124. chart.setFocusToElement(chart[buttonProp].box, component[proxyProp]);
  4125. }
  4126. });
  4127. },
  4128. /**
  4129. * Get keyboard navigation handlers for this component.
  4130. * @return {Array<Highcharts.KeyboardNavigationHandler>}
  4131. * List of module objects
  4132. */
  4133. getKeyboardNavigation: function () {
  4134. return [
  4135. this.simpleButtonNavigation('resetZoomButton', 'resetZoomProxyButton', function (_handler, chart) {
  4136. chart.zoomOut();
  4137. }),
  4138. this.simpleButtonNavigation('drillUpButton', 'drillUpProxyButton', function (handler, chart) {
  4139. chart.drillUp();
  4140. return handler.response.prev;
  4141. }),
  4142. this.getMapZoomNavigation()
  4143. ];
  4144. }
  4145. });
  4146. return ZoomComponent;
  4147. });
  4148. _registerModule(_modules, 'Accessibility/Components/RangeSelectorComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, U, AccessibilityComponent, KeyboardNavigationHandler, ChartUtilities, HTMLUtilities) {
  4149. /* *
  4150. *
  4151. * (c) 2009-2020 Øystein Moseng
  4152. *
  4153. * Accessibility component for the range selector.
  4154. *
  4155. * License: www.highcharts.com/license
  4156. *
  4157. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4158. *
  4159. * */
  4160. var extend = U.extend;
  4161. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT;
  4162. var setElAttrs = HTMLUtilities.setElAttrs;
  4163. /* eslint-disable no-invalid-this, valid-jsdoc */
  4164. /**
  4165. * @private
  4166. */
  4167. function shouldRunInputNavigation(chart) {
  4168. var inputVisible = (chart.rangeSelector &&
  4169. chart.rangeSelector.inputGroup &&
  4170. chart.rangeSelector.inputGroup.element
  4171. .getAttribute('visibility') !== 'hidden');
  4172. return (inputVisible &&
  4173. chart.options.rangeSelector.inputEnabled !== false &&
  4174. chart.rangeSelector.minInput &&
  4175. chart.rangeSelector.maxInput);
  4176. }
  4177. /**
  4178. * Highlight range selector button by index.
  4179. *
  4180. * @private
  4181. * @function Highcharts.Chart#highlightRangeSelectorButton
  4182. *
  4183. * @param {number} ix
  4184. *
  4185. * @return {boolean}
  4186. */
  4187. H.Chart.prototype.highlightRangeSelectorButton = function (ix) {
  4188. var buttons = this.rangeSelector.buttons,
  4189. curSelectedIx = this.highlightedRangeSelectorItemIx;
  4190. // Deselect old
  4191. if (typeof curSelectedIx !== 'undefined' && buttons[curSelectedIx]) {
  4192. buttons[curSelectedIx].setState(this.oldRangeSelectorItemState || 0);
  4193. }
  4194. // Select new
  4195. this.highlightedRangeSelectorItemIx = ix;
  4196. if (buttons[ix]) {
  4197. this.setFocusToElement(buttons[ix].box, buttons[ix].element);
  4198. this.oldRangeSelectorItemState = buttons[ix].state;
  4199. buttons[ix].setState(2);
  4200. return true;
  4201. }
  4202. return false;
  4203. };
  4204. /**
  4205. * The RangeSelectorComponent class
  4206. *
  4207. * @private
  4208. * @class
  4209. * @name Highcharts.RangeSelectorComponent
  4210. */
  4211. var RangeSelectorComponent = function () { };
  4212. RangeSelectorComponent.prototype = new AccessibilityComponent();
  4213. extend(RangeSelectorComponent.prototype, /** @lends Highcharts.RangeSelectorComponent */ {
  4214. /**
  4215. * Called on first render/updates to the chart, including options changes.
  4216. */
  4217. onChartUpdate: function () {
  4218. var chart = this.chart,
  4219. component = this,
  4220. rangeSelector = chart.rangeSelector;
  4221. if (!rangeSelector) {
  4222. return;
  4223. }
  4224. if (rangeSelector.buttons && rangeSelector.buttons.length) {
  4225. rangeSelector.buttons.forEach(function (button) {
  4226. unhideChartElementFromAT(chart, button.element);
  4227. component.setRangeButtonAttrs(button);
  4228. });
  4229. }
  4230. // Make sure input boxes are accessible and focusable
  4231. if (rangeSelector.maxInput && rangeSelector.minInput) {
  4232. ['minInput', 'maxInput'].forEach(function (key, i) {
  4233. var input = rangeSelector[key];
  4234. if (input) {
  4235. unhideChartElementFromAT(chart, input);
  4236. component.setRangeInputAttrs(input, 'accessibility.rangeSelector.' + (i ? 'max' : 'min') +
  4237. 'InputLabel');
  4238. }
  4239. });
  4240. }
  4241. },
  4242. /**
  4243. * @private
  4244. * @param {Highcharts.SVGElement} button
  4245. */
  4246. setRangeButtonAttrs: function (button) {
  4247. var chart = this.chart,
  4248. label = chart.langFormat('accessibility.rangeSelector.buttonText', {
  4249. chart: chart,
  4250. buttonText: button.text && button.text.textStr
  4251. });
  4252. setElAttrs(button.element, {
  4253. tabindex: -1,
  4254. role: 'button',
  4255. 'aria-label': label
  4256. });
  4257. },
  4258. /**
  4259. * @private
  4260. */
  4261. setRangeInputAttrs: function (input, langKey) {
  4262. var chart = this.chart;
  4263. setElAttrs(input, {
  4264. tabindex: -1,
  4265. role: 'textbox',
  4266. 'aria-label': chart.langFormat(langKey, { chart: chart })
  4267. });
  4268. },
  4269. /**
  4270. * Get navigation for the range selector buttons.
  4271. * @private
  4272. * @return {Highcharts.KeyboardNavigationHandler} The module object.
  4273. */
  4274. getRangeSelectorButtonNavigation: function () {
  4275. var chart = this.chart,
  4276. keys = this.keyCodes,
  4277. component = this;
  4278. return new KeyboardNavigationHandler(chart, {
  4279. keyCodeMap: [
  4280. [
  4281. [keys.left, keys.right, keys.up, keys.down],
  4282. function (keyCode) {
  4283. return component.onButtonNavKbdArrowKey(this, keyCode);
  4284. }
  4285. ],
  4286. [
  4287. [keys.enter, keys.space],
  4288. function () {
  4289. return component.onButtonNavKbdClick(this);
  4290. }
  4291. ]
  4292. ],
  4293. validate: function () {
  4294. var hasRangeSelector = chart.rangeSelector &&
  4295. chart.rangeSelector.buttons &&
  4296. chart.rangeSelector.buttons.length;
  4297. return hasRangeSelector;
  4298. },
  4299. init: function (direction) {
  4300. var lastButtonIx = (chart.rangeSelector.buttons.length - 1);
  4301. chart.highlightRangeSelectorButton(direction > 0 ? 0 : lastButtonIx);
  4302. }
  4303. });
  4304. },
  4305. /**
  4306. * @private
  4307. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  4308. * @param {number} keyCode
  4309. * @return {number} Response code
  4310. */
  4311. onButtonNavKbdArrowKey: function (keyboardNavigationHandler, keyCode) {
  4312. var response = keyboardNavigationHandler.response,
  4313. keys = this.keyCodes,
  4314. chart = this.chart,
  4315. wrapAround = chart.options.accessibility
  4316. .keyboardNavigation.wrapAround,
  4317. direction = (keyCode === keys.left || keyCode === keys.up) ? -1 : 1,
  4318. didHighlight = chart.highlightRangeSelectorButton(chart.highlightedRangeSelectorItemIx + direction);
  4319. if (!didHighlight) {
  4320. if (wrapAround) {
  4321. keyboardNavigationHandler.init(direction);
  4322. return response.success;
  4323. }
  4324. return response[direction > 0 ? 'next' : 'prev'];
  4325. }
  4326. return response.success;
  4327. },
  4328. /**
  4329. * @private
  4330. */
  4331. onButtonNavKbdClick: function (keyboardNavigationHandler) {
  4332. var response = keyboardNavigationHandler.response,
  4333. chart = this.chart,
  4334. wasDisabled = chart.oldRangeSelectorItemState === 3;
  4335. if (!wasDisabled) {
  4336. this.fakeClickEvent(chart.rangeSelector.buttons[chart.highlightedRangeSelectorItemIx].element);
  4337. }
  4338. return response.success;
  4339. },
  4340. /**
  4341. * Get navigation for the range selector input boxes.
  4342. * @private
  4343. * @return {Highcharts.KeyboardNavigationHandler}
  4344. * The module object.
  4345. */
  4346. getRangeSelectorInputNavigation: function () {
  4347. var chart = this.chart,
  4348. keys = this.keyCodes,
  4349. component = this;
  4350. return new KeyboardNavigationHandler(chart, {
  4351. keyCodeMap: [
  4352. [
  4353. [
  4354. keys.tab, keys.up, keys.down
  4355. ],
  4356. function (keyCode, e) {
  4357. var direction = (keyCode === keys.tab && e.shiftKey ||
  4358. keyCode === keys.up) ? -1 : 1;
  4359. return component.onInputKbdMove(this, direction);
  4360. }
  4361. ]
  4362. ],
  4363. validate: function () {
  4364. return shouldRunInputNavigation(chart);
  4365. },
  4366. init: function (direction) {
  4367. component.onInputNavInit(direction);
  4368. },
  4369. terminate: function () {
  4370. component.onInputNavTerminate();
  4371. }
  4372. });
  4373. },
  4374. /**
  4375. * @private
  4376. * @param {Highcharts.KeyboardNavigationHandler} keyboardNavigationHandler
  4377. * @param {number} direction
  4378. * @return {number} Response code
  4379. */
  4380. onInputKbdMove: function (keyboardNavigationHandler, direction) {
  4381. var chart = this.chart,
  4382. response = keyboardNavigationHandler.response,
  4383. newIx = chart.highlightedInputRangeIx =
  4384. chart.highlightedInputRangeIx + direction,
  4385. newIxOutOfRange = newIx > 1 || newIx < 0;
  4386. if (newIxOutOfRange) {
  4387. return response[direction > 0 ? 'next' : 'prev'];
  4388. }
  4389. chart.rangeSelector[newIx ? 'maxInput' : 'minInput'].focus();
  4390. return response.success;
  4391. },
  4392. /**
  4393. * @private
  4394. * @param {number} direction
  4395. */
  4396. onInputNavInit: function (direction) {
  4397. var chart = this.chart,
  4398. buttonIxToHighlight = direction > 0 ? 0 : 1;
  4399. chart.highlightedInputRangeIx = buttonIxToHighlight;
  4400. chart.rangeSelector[buttonIxToHighlight ? 'maxInput' : 'minInput'].focus();
  4401. },
  4402. /**
  4403. * @private
  4404. */
  4405. onInputNavTerminate: function () {
  4406. var rangeSel = (this.chart.rangeSelector || {});
  4407. if (rangeSel.maxInput) {
  4408. rangeSel.hideInput('max');
  4409. }
  4410. if (rangeSel.minInput) {
  4411. rangeSel.hideInput('min');
  4412. }
  4413. },
  4414. /**
  4415. * Get keyboard navigation handlers for this component.
  4416. * @return {Array<Highcharts.KeyboardNavigationHandler>}
  4417. * List of module objects.
  4418. */
  4419. getKeyboardNavigation: function () {
  4420. return [
  4421. this.getRangeSelectorButtonNavigation(),
  4422. this.getRangeSelectorInputNavigation()
  4423. ];
  4424. }
  4425. });
  4426. return RangeSelectorComponent;
  4427. });
  4428. _registerModule(_modules, 'Accessibility/Components/InfoRegionsComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/Utils/Announcer.js'], _modules['Accessibility/Components/AnnotationsA11y.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js']], function (H, U, AccessibilityComponent, Announcer, AnnotationsA11y, ChartUtilities, HTMLUtilities) {
  4429. /* *
  4430. *
  4431. * (c) 2009-2020 Øystein Moseng
  4432. *
  4433. * Accessibility component for chart info region and table.
  4434. *
  4435. * License: www.highcharts.com/license
  4436. *
  4437. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4438. *
  4439. * */
  4440. var doc = H.doc;
  4441. var extend = U.extend,
  4442. format = U.format,
  4443. pick = U.pick;
  4444. var getAnnotationsInfoHTML = AnnotationsA11y.getAnnotationsInfoHTML;
  4445. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT,
  4446. getChartTitle = ChartUtilities.getChartTitle,
  4447. getAxisDescription = ChartUtilities.getAxisDescription;
  4448. var addClass = HTMLUtilities.addClass,
  4449. setElAttrs = HTMLUtilities.setElAttrs,
  4450. escapeStringForHTML = HTMLUtilities.escapeStringForHTML,
  4451. stripHTMLTagsFromString = HTMLUtilities.stripHTMLTagsFromString,
  4452. getElement = HTMLUtilities.getElement,
  4453. visuallyHideElement = HTMLUtilities.visuallyHideElement;
  4454. /* eslint-disable no-invalid-this, valid-jsdoc */
  4455. /**
  4456. * @private
  4457. */
  4458. function getTypeDescForMapChart(chart, formatContext) {
  4459. return formatContext.mapTitle ?
  4460. chart.langFormat('accessibility.chartTypes.mapTypeDescription', formatContext) :
  4461. chart.langFormat('accessibility.chartTypes.unknownMap', formatContext);
  4462. }
  4463. /**
  4464. * @private
  4465. */
  4466. function getTypeDescForCombinationChart(chart, formatContext) {
  4467. return chart.langFormat('accessibility.chartTypes.combinationChart', formatContext);
  4468. }
  4469. /**
  4470. * @private
  4471. */
  4472. function getTypeDescForEmptyChart(chart, formatContext) {
  4473. return chart.langFormat('accessibility.chartTypes.emptyChart', formatContext);
  4474. }
  4475. /**
  4476. * @private
  4477. */
  4478. function buildTypeDescriptionFromSeries(chart, types, context) {
  4479. var firstType = types[0], typeExplaination = chart.langFormat('accessibility.seriesTypeDescriptions.' + firstType, context), multi = chart.series && chart.series.length < 2 ? 'Single' : 'Multiple';
  4480. return (chart.langFormat('accessibility.chartTypes.' + firstType + multi, context) ||
  4481. chart.langFormat('accessibility.chartTypes.default' + multi, context)) + (typeExplaination ? ' ' + typeExplaination : '');
  4482. }
  4483. /**
  4484. * @private
  4485. */
  4486. function getTableSummary(chart) {
  4487. return chart.langFormat('accessibility.table.tableSummary', { chart: chart });
  4488. }
  4489. /**
  4490. * @private
  4491. */
  4492. function stripEmptyHTMLTags(str) {
  4493. return str.replace(/<(\w+)[^>]*?>\s*<\/\1>/g, '');
  4494. }
  4495. /**
  4496. * @private
  4497. */
  4498. function enableSimpleHTML(str) {
  4499. return str
  4500. .replace(/&lt;(h[1-7]|p|div|ul|ol|li)&gt;/g, '<$1>')
  4501. .replace(/&lt;&#x2F;(h[1-7]|p|div|ul|ol|li|a|button)&gt;/g, '</$1>')
  4502. .replace(/&lt;(div|a|button) id=&quot;([a-zA-Z\-0-9#]*?)&quot;&gt;/g, '<$1 id="$2">');
  4503. }
  4504. /**
  4505. * @private
  4506. */
  4507. function stringToSimpleHTML(str) {
  4508. return stripEmptyHTMLTags(enableSimpleHTML(escapeStringForHTML(str)));
  4509. }
  4510. /**
  4511. * Return simplified explaination of chart type. Some types will not be familiar
  4512. * to most users, but in those cases we try to add an explaination of the type.
  4513. *
  4514. * @private
  4515. * @function Highcharts.Chart#getTypeDescription
  4516. * @param {Array<string>} types The series types in this chart.
  4517. * @return {string} The text description of the chart type.
  4518. */
  4519. H.Chart.prototype.getTypeDescription = function (types) {
  4520. var firstType = types[0],
  4521. firstSeries = this.series && this.series[0] || {},
  4522. formatContext = {
  4523. numSeries: this.series.length,
  4524. numPoints: firstSeries.points && firstSeries.points.length,
  4525. chart: this,
  4526. mapTitle: firstSeries.mapTitle
  4527. };
  4528. if (!firstType) {
  4529. return getTypeDescForEmptyChart(this, formatContext);
  4530. }
  4531. if (firstType === 'map') {
  4532. return getTypeDescForMapChart(this, formatContext);
  4533. }
  4534. if (this.types.length > 1) {
  4535. return getTypeDescForCombinationChart(this, formatContext);
  4536. }
  4537. return buildTypeDescriptionFromSeries(this, types, formatContext);
  4538. };
  4539. /**
  4540. * The InfoRegionsComponent class
  4541. *
  4542. * @private
  4543. * @class
  4544. * @name Highcharts.InfoRegionsComponent
  4545. */
  4546. var InfoRegionsComponent = function () { };
  4547. InfoRegionsComponent.prototype = new AccessibilityComponent();
  4548. extend(InfoRegionsComponent.prototype, /** @lends Highcharts.InfoRegionsComponent */ {
  4549. /**
  4550. * Init the component
  4551. * @private
  4552. */
  4553. init: function () {
  4554. var chart = this.chart;
  4555. var component = this;
  4556. this.initRegionsDefinitions();
  4557. this.addEvent(chart, 'afterGetTable', function (e) {
  4558. component.onDataTableCreated(e);
  4559. });
  4560. this.addEvent(chart, 'afterViewData', function (tableDiv) {
  4561. component.dataTableDiv = tableDiv;
  4562. // Use small delay to give browsers & AT time to register new table
  4563. setTimeout(function () {
  4564. component.focusDataTable();
  4565. }, 300);
  4566. });
  4567. this.announcer = new Announcer(chart, 'assertive');
  4568. },
  4569. /**
  4570. * @private
  4571. */
  4572. initRegionsDefinitions: function () {
  4573. var component = this;
  4574. this.screenReaderSections = {
  4575. before: {
  4576. element: null,
  4577. buildContent: function (chart) {
  4578. var formatter = chart.options.accessibility
  4579. .screenReaderSection.beforeChartFormatter;
  4580. return formatter ? formatter(chart) :
  4581. component.defaultBeforeChartFormatter(chart);
  4582. },
  4583. insertIntoDOM: function (el, chart) {
  4584. chart.renderTo.insertBefore(el, chart.renderTo.firstChild);
  4585. },
  4586. afterInserted: function () {
  4587. if (typeof component.sonifyButtonId !== 'undefined') {
  4588. component.initSonifyButton(component.sonifyButtonId);
  4589. }
  4590. if (typeof component.dataTableButtonId !== 'undefined') {
  4591. component.initDataTableButton(component.dataTableButtonId);
  4592. }
  4593. }
  4594. },
  4595. after: {
  4596. element: null,
  4597. buildContent: function (chart) {
  4598. var formatter = chart.options.accessibility.screenReaderSection
  4599. .afterChartFormatter;
  4600. return formatter ? formatter(chart) :
  4601. component.defaultAfterChartFormatter();
  4602. },
  4603. insertIntoDOM: function (el, chart) {
  4604. chart.renderTo.insertBefore(el, chart.container.nextSibling);
  4605. }
  4606. }
  4607. };
  4608. },
  4609. /**
  4610. * Called on chart render. Have to update the sections on render, in order
  4611. * to get a11y info from series.
  4612. */
  4613. onChartRender: function () {
  4614. var component = this;
  4615. this.linkedDescriptionElement = this.getLinkedDescriptionElement();
  4616. this.setLinkedDescriptionAttrs();
  4617. Object.keys(this.screenReaderSections).forEach(function (regionKey) {
  4618. component.updateScreenReaderSection(regionKey);
  4619. });
  4620. },
  4621. /**
  4622. * @private
  4623. */
  4624. getLinkedDescriptionElement: function () {
  4625. var chartOptions = this.chart.options,
  4626. linkedDescOption = chartOptions.accessibility.linkedDescription;
  4627. if (!linkedDescOption) {
  4628. return;
  4629. }
  4630. if (typeof linkedDescOption !== 'string') {
  4631. return linkedDescOption;
  4632. }
  4633. var query = format(linkedDescOption,
  4634. this.chart),
  4635. queryMatch = doc.querySelectorAll(query);
  4636. if (queryMatch.length === 1) {
  4637. return queryMatch[0];
  4638. }
  4639. },
  4640. /**
  4641. * @private
  4642. */
  4643. setLinkedDescriptionAttrs: function () {
  4644. var el = this.linkedDescriptionElement;
  4645. if (el) {
  4646. el.setAttribute('aria-hidden', 'true');
  4647. addClass(el, 'highcharts-linked-description');
  4648. }
  4649. },
  4650. /**
  4651. * @private
  4652. * @param {string} regionKey The name/key of the region to update
  4653. */
  4654. updateScreenReaderSection: function (regionKey) {
  4655. var chart = this.chart, region = this.screenReaderSections[regionKey], content = region.buildContent(chart), sectionDiv = region.element = (region.element || this.createElement('div')), hiddenDiv = (sectionDiv.firstChild || this.createElement('div'));
  4656. this.setScreenReaderSectionAttribs(sectionDiv, regionKey);
  4657. hiddenDiv.innerHTML = content;
  4658. sectionDiv.appendChild(hiddenDiv);
  4659. region.insertIntoDOM(sectionDiv, chart);
  4660. visuallyHideElement(hiddenDiv);
  4661. unhideChartElementFromAT(chart, hiddenDiv);
  4662. if (region.afterInserted) {
  4663. region.afterInserted();
  4664. }
  4665. },
  4666. /**
  4667. * @private
  4668. * @param {Highcharts.HTMLDOMElement} sectionDiv The section element
  4669. * @param {string} regionKey Name/key of the region we are setting attrs for
  4670. */
  4671. setScreenReaderSectionAttribs: function (sectionDiv, regionKey) {
  4672. var labelLangKey = ('accessibility.screenReaderSection.' + regionKey + 'RegionLabel'), chart = this.chart, labelText = chart.langFormat(labelLangKey, { chart: chart }), sectionId = 'highcharts-screen-reader-region-' + regionKey + '-' +
  4673. chart.index;
  4674. setElAttrs(sectionDiv, {
  4675. id: sectionId,
  4676. 'aria-label': labelText
  4677. });
  4678. // Sections are wrapped to be positioned relatively to chart in case
  4679. // elements inside are tabbed to.
  4680. sectionDiv.style.position = 'relative';
  4681. if (chart.options.accessibility.landmarkVerbosity === 'all' &&
  4682. labelText) {
  4683. sectionDiv.setAttribute('role', 'region');
  4684. }
  4685. },
  4686. /**
  4687. * @private
  4688. * @return {string}
  4689. */
  4690. defaultBeforeChartFormatter: function () {
  4691. var _a;
  4692. var chart = this.chart,
  4693. format = chart.options.accessibility
  4694. .screenReaderSection.beforeChartFormat,
  4695. axesDesc = this.getAxesDescription(),
  4696. shouldHaveSonifyBtn = chart.sonify && ((_a = chart.options.sonification) === null || _a === void 0 ? void 0 : _a.enabled),
  4697. sonifyButtonId = 'highcharts-a11y-sonify-data-btn-' +
  4698. chart.index,
  4699. dataTableButtonId = 'hc-linkto-highcharts-data-table-' +
  4700. chart.index,
  4701. annotationsList = getAnnotationsInfoHTML(chart),
  4702. annotationsTitleStr = chart.langFormat('accessibility.screenReaderSection.annotations.heading', { chart: chart }),
  4703. context = {
  4704. chartTitle: getChartTitle(chart),
  4705. typeDescription: this.getTypeDescriptionText(),
  4706. chartSubtitle: this.getSubtitleText(),
  4707. chartLongdesc: this.getLongdescText(),
  4708. xAxisDescription: axesDesc.xAxis,
  4709. yAxisDescription: axesDesc.yAxis,
  4710. playAsSoundButton: shouldHaveSonifyBtn ?
  4711. this.getSonifyButtonText(sonifyButtonId) : '',
  4712. viewTableButton: chart.getCSV ?
  4713. this.getDataTableButtonText(dataTableButtonId) : '',
  4714. annotationsTitle: annotationsList ? annotationsTitleStr : '',
  4715. annotationsList: annotationsList
  4716. },
  4717. formattedString = H.i18nFormat(format,
  4718. context,
  4719. chart);
  4720. this.dataTableButtonId = dataTableButtonId;
  4721. this.sonifyButtonId = sonifyButtonId;
  4722. return stringToSimpleHTML(formattedString);
  4723. },
  4724. /**
  4725. * @private
  4726. * @return {string}
  4727. */
  4728. defaultAfterChartFormatter: function () {
  4729. var chart = this.chart,
  4730. format = chart.options.accessibility
  4731. .screenReaderSection.afterChartFormat,
  4732. context = {
  4733. endOfChartMarker: this.getEndOfChartMarkerText()
  4734. },
  4735. formattedString = H.i18nFormat(format,
  4736. context,
  4737. chart);
  4738. return stringToSimpleHTML(formattedString);
  4739. },
  4740. /**
  4741. * @private
  4742. * @return {string}
  4743. */
  4744. getLinkedDescription: function () {
  4745. var el = this.linkedDescriptionElement,
  4746. content = el && el.innerHTML || '';
  4747. return stripHTMLTagsFromString(content);
  4748. },
  4749. /**
  4750. * @private
  4751. * @return {string}
  4752. */
  4753. getLongdescText: function () {
  4754. var chartOptions = this.chart.options,
  4755. captionOptions = chartOptions.caption,
  4756. captionText = captionOptions && captionOptions.text,
  4757. linkedDescription = this.getLinkedDescription();
  4758. return (chartOptions.accessibility.description ||
  4759. linkedDescription ||
  4760. captionText ||
  4761. '');
  4762. },
  4763. /**
  4764. * @private
  4765. * @return {string}
  4766. */
  4767. getTypeDescriptionText: function () {
  4768. var chart = this.chart;
  4769. return chart.types ?
  4770. chart.options.accessibility.typeDescription ||
  4771. chart.getTypeDescription(chart.types) : '';
  4772. },
  4773. /**
  4774. * @private
  4775. * @param {string} buttonId
  4776. * @return {string}
  4777. */
  4778. getDataTableButtonText: function (buttonId) {
  4779. var chart = this.chart,
  4780. buttonText = chart.langFormat('accessibility.table.viewAsDataTableButtonText', { chart: chart,
  4781. chartTitle: getChartTitle(chart) });
  4782. return '<button id="' + buttonId + '">' + buttonText + '</button>';
  4783. },
  4784. /**
  4785. * @private
  4786. * @param {string} buttonId
  4787. * @return {string}
  4788. */
  4789. getSonifyButtonText: function (buttonId) {
  4790. var _a;
  4791. var chart = this.chart;
  4792. if (((_a = chart.options.sonification) === null || _a === void 0 ? void 0 : _a.enabled) === false) {
  4793. return '';
  4794. }
  4795. var buttonText = chart.langFormat('accessibility.sonification.playAsSoundButtonText', { chart: chart,
  4796. chartTitle: getChartTitle(chart) });
  4797. return '<button id="' + buttonId + '">' + buttonText + '</button>';
  4798. },
  4799. /**
  4800. * @private
  4801. * @return {string}
  4802. */
  4803. getSubtitleText: function () {
  4804. var subtitle = (this.chart.options.subtitle);
  4805. return stripHTMLTagsFromString(subtitle && subtitle.text || '');
  4806. },
  4807. /**
  4808. * @private
  4809. * @return {string}
  4810. */
  4811. getEndOfChartMarkerText: function () {
  4812. var chart = this.chart, markerText = chart.langFormat('accessibility.screenReaderSection.endOfChartMarker', { chart: chart }), id = 'highcharts-end-of-chart-marker-' + chart.index;
  4813. return '<div id="' + id + '">' + markerText + '</div>';
  4814. },
  4815. /**
  4816. * @private
  4817. * @param {Highcharts.Dictionary<string>} e
  4818. */
  4819. onDataTableCreated: function (e) {
  4820. var chart = this.chart;
  4821. if (chart.options.accessibility.enabled) {
  4822. if (this.viewDataTableButton) {
  4823. this.viewDataTableButton.setAttribute('aria-expanded', 'true');
  4824. }
  4825. e.html = e.html.replace('<table ', '<table tabindex="-1" summary="' + getTableSummary(chart) + '"');
  4826. }
  4827. },
  4828. /**
  4829. * @private
  4830. */
  4831. focusDataTable: function () {
  4832. var tableDiv = this.dataTableDiv,
  4833. table = tableDiv && tableDiv.getElementsByTagName('table')[0];
  4834. if (table && table.focus) {
  4835. table.focus();
  4836. }
  4837. },
  4838. /**
  4839. * @private
  4840. * @param {string} sonifyButtonId
  4841. */
  4842. initSonifyButton: function (sonifyButtonId) {
  4843. var _this = this;
  4844. var el = this.sonifyButton = getElement(sonifyButtonId);
  4845. var chart = this.chart;
  4846. var defaultHandler = function (e) {
  4847. el === null || el === void 0 ? void 0 : el.setAttribute('aria-hidden', 'true');
  4848. el === null || el === void 0 ? void 0 : el.setAttribute('aria-label', '');
  4849. e.preventDefault();
  4850. e.stopPropagation();
  4851. var announceMsg = chart.langFormat('accessibility.sonification.playAsSoundClickAnnouncement', { chart: chart });
  4852. _this.announcer.announce(announceMsg);
  4853. setTimeout(function () {
  4854. el === null || el === void 0 ? void 0 : el.removeAttribute('aria-hidden');
  4855. el === null || el === void 0 ? void 0 : el.removeAttribute('aria-label');
  4856. if (chart.sonify) {
  4857. chart.sonify();
  4858. }
  4859. }, 1000); // Delay to let screen reader speak the button press
  4860. };
  4861. if (el && chart) {
  4862. setElAttrs(el, {
  4863. tabindex: '-1'
  4864. });
  4865. el.onclick = function (e) {
  4866. var _a;
  4867. var onPlayAsSoundClick = (_a = chart.options.accessibility) === null || _a === void 0 ? void 0 : _a.screenReaderSection.onPlayAsSoundClick;
  4868. (onPlayAsSoundClick || defaultHandler).call(this, e, chart);
  4869. };
  4870. }
  4871. },
  4872. /**
  4873. * Set attribs and handlers for default viewAsDataTable button if exists.
  4874. * @private
  4875. * @param {string} tableButtonId
  4876. */
  4877. initDataTableButton: function (tableButtonId) {
  4878. var el = this.viewDataTableButton = getElement(tableButtonId), chart = this.chart, tableId = tableButtonId.replace('hc-linkto-', '');
  4879. if (el) {
  4880. setElAttrs(el, {
  4881. tabindex: '-1',
  4882. 'aria-expanded': !!getElement(tableId)
  4883. });
  4884. el.onclick = chart.options.accessibility
  4885. .screenReaderSection.onViewDataTableClick ||
  4886. function () {
  4887. chart.viewData();
  4888. };
  4889. }
  4890. },
  4891. /**
  4892. * Return object with text description of each of the chart's axes.
  4893. * @private
  4894. * @return {Highcharts.Dictionary<string>}
  4895. */
  4896. getAxesDescription: function () {
  4897. var chart = this.chart,
  4898. shouldDescribeColl = function (collectionKey,
  4899. defaultCondition) {
  4900. var axes = chart[collectionKey];
  4901. return axes.length > 1 || axes[0] &&
  4902. pick(axes[0].options.accessibility &&
  4903. axes[0].options.accessibility.enabled, defaultCondition);
  4904. }, hasNoMap = !!chart.types && chart.types.indexOf('map') < 0, hasCartesian = !!chart.hasCartesianSeries, showXAxes = shouldDescribeColl('xAxis', !chart.angular && hasCartesian && hasNoMap), showYAxes = shouldDescribeColl('yAxis', hasCartesian && hasNoMap), desc = {};
  4905. if (showXAxes) {
  4906. desc.xAxis = this.getAxisDescriptionText('xAxis');
  4907. }
  4908. if (showYAxes) {
  4909. desc.yAxis = this.getAxisDescriptionText('yAxis');
  4910. }
  4911. return desc;
  4912. },
  4913. /**
  4914. * @private
  4915. * @param {string} collectionKey
  4916. * @return {string}
  4917. */
  4918. getAxisDescriptionText: function (collectionKey) {
  4919. var component = this,
  4920. chart = this.chart,
  4921. axes = chart[collectionKey];
  4922. return chart.langFormat('accessibility.axis.' + collectionKey + 'Description' + (axes.length > 1 ? 'Plural' : 'Singular'), {
  4923. chart: chart,
  4924. names: axes.map(function (axis) {
  4925. return getAxisDescription(axis);
  4926. }),
  4927. ranges: axes.map(function (axis) {
  4928. return component.getAxisRangeDescription(axis);
  4929. }),
  4930. numAxes: axes.length
  4931. });
  4932. },
  4933. /**
  4934. * Return string with text description of the axis range.
  4935. * @private
  4936. * @param {Highcharts.Axis} axis The axis to get range desc of.
  4937. * @return {string} A string with the range description for the axis.
  4938. */
  4939. getAxisRangeDescription: function (axis) {
  4940. var axisOptions = axis.options || {};
  4941. // Handle overridden range description
  4942. if (axisOptions.accessibility &&
  4943. typeof axisOptions.accessibility.rangeDescription !== 'undefined') {
  4944. return axisOptions.accessibility.rangeDescription;
  4945. }
  4946. // Handle category axes
  4947. if (axis.categories) {
  4948. return this.getCategoryAxisRangeDesc(axis);
  4949. }
  4950. // Use time range, not from-to?
  4951. if (axis.dateTime && (axis.min === 0 || axis.dataMin === 0)) {
  4952. return this.getAxisTimeLengthDesc(axis);
  4953. }
  4954. // Just use from and to.
  4955. // We have the range and the unit to use, find the desc format
  4956. return this.getAxisFromToDescription(axis);
  4957. },
  4958. /**
  4959. * @private
  4960. * @param {Highcharts.Axis} axis
  4961. * @return {string}
  4962. */
  4963. getCategoryAxisRangeDesc: function (axis) {
  4964. var chart = this.chart;
  4965. if (axis.dataMax && axis.dataMin) {
  4966. return chart.langFormat('accessibility.axis.rangeCategories', {
  4967. chart: chart,
  4968. axis: axis,
  4969. numCategories: axis.dataMax - axis.dataMin + 1
  4970. });
  4971. }
  4972. return '';
  4973. },
  4974. /**
  4975. * @private
  4976. * @param {Highcharts.Axis} axis
  4977. * @return {string}
  4978. */
  4979. getAxisTimeLengthDesc: function (axis) {
  4980. var chart = this.chart,
  4981. range = {},
  4982. rangeUnit = 'Seconds';
  4983. range.Seconds = ((axis.max || 0) - (axis.min || 0)) / 1000;
  4984. range.Minutes = range.Seconds / 60;
  4985. range.Hours = range.Minutes / 60;
  4986. range.Days = range.Hours / 24;
  4987. ['Minutes', 'Hours', 'Days'].forEach(function (unit) {
  4988. if (range[unit] > 2) {
  4989. rangeUnit = unit;
  4990. }
  4991. });
  4992. var rangeValue = range[rangeUnit].toFixed(rangeUnit !== 'Seconds' &&
  4993. rangeUnit !== 'Minutes' ? 1 : 0 // Use decimals for days/hours
  4994. );
  4995. // We have the range and the unit to use, find the desc format
  4996. return chart.langFormat('accessibility.axis.timeRange' + rangeUnit, {
  4997. chart: chart,
  4998. axis: axis,
  4999. range: rangeValue.replace('.0', '')
  5000. });
  5001. },
  5002. /**
  5003. * @private
  5004. * @param {Highcharts.Axis} axis
  5005. * @return {string}
  5006. */
  5007. getAxisFromToDescription: function (axis) {
  5008. var chart = this.chart,
  5009. dateRangeFormat = chart.options.accessibility
  5010. .screenReaderSection.axisRangeDateFormat,
  5011. format = function (axisKey) {
  5012. return axis.dateTime ? chart.time.dateFormat(dateRangeFormat,
  5013. axis[axisKey]) : axis[axisKey];
  5014. };
  5015. return chart.langFormat('accessibility.axis.rangeFromTo', {
  5016. chart: chart,
  5017. axis: axis,
  5018. rangeFrom: format('min'),
  5019. rangeTo: format('max')
  5020. });
  5021. },
  5022. /**
  5023. * Remove component traces
  5024. */
  5025. destroy: function () {
  5026. var _a;
  5027. (_a = this.announcer) === null || _a === void 0 ? void 0 : _a.destroy();
  5028. }
  5029. });
  5030. return InfoRegionsComponent;
  5031. });
  5032. _registerModule(_modules, 'Accessibility/Components/ContainerComponent.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Accessibility/Utils/HTMLUtilities.js'], _modules['Accessibility/Utils/ChartUtilities.js'], _modules['Accessibility/AccessibilityComponent.js']], function (H, U, HTMLUtilities, ChartUtilities, AccessibilityComponent) {
  5033. /* *
  5034. *
  5035. * (c) 2009-2020 Øystein Moseng
  5036. *
  5037. * Accessibility component for chart container.
  5038. *
  5039. * License: www.highcharts.com/license
  5040. *
  5041. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5042. *
  5043. * */
  5044. var doc = H.win.document;
  5045. var extend = U.extend;
  5046. var stripHTMLTags = HTMLUtilities.stripHTMLTagsFromString;
  5047. var unhideChartElementFromAT = ChartUtilities.unhideChartElementFromAT,
  5048. getChartTitle = ChartUtilities.getChartTitle;
  5049. /* eslint-disable valid-jsdoc */
  5050. /**
  5051. * The ContainerComponent class
  5052. *
  5053. * @private
  5054. * @class
  5055. * @name Highcharts.ContainerComponent
  5056. */
  5057. var ContainerComponent = function () { };
  5058. ContainerComponent.prototype = new AccessibilityComponent();
  5059. extend(ContainerComponent.prototype, /** @lends Highcharts.ContainerComponent */ {
  5060. /**
  5061. * Called on first render/updates to the chart, including options changes.
  5062. */
  5063. onChartUpdate: function () {
  5064. this.handleSVGTitleElement();
  5065. this.setSVGContainerLabel();
  5066. this.setGraphicContainerAttrs();
  5067. this.setRenderToAttrs();
  5068. this.makeCreditsAccessible();
  5069. },
  5070. /**
  5071. * @private
  5072. */
  5073. handleSVGTitleElement: function () {
  5074. var chart = this.chart, titleId = 'highcharts-title-' + chart.index, titleContents = stripHTMLTags(chart.langFormat('accessibility.svgContainerTitle', {
  5075. chartTitle: getChartTitle(chart)
  5076. }));
  5077. if (titleContents.length) {
  5078. var titleElement = this.svgTitleElement =
  5079. this.svgTitleElement || doc.createElementNS('http://www.w3.org/2000/svg', 'title');
  5080. titleElement.textContent = titleContents;
  5081. titleElement.id = titleId;
  5082. chart.renderTo.insertBefore(titleElement, chart.renderTo.firstChild);
  5083. }
  5084. },
  5085. /**
  5086. * @private
  5087. */
  5088. setSVGContainerLabel: function () {
  5089. var chart = this.chart,
  5090. svgContainerLabel = stripHTMLTags(chart.langFormat('accessibility.svgContainerLabel', {
  5091. chartTitle: getChartTitle(chart)
  5092. }));
  5093. if (chart.renderer.box && svgContainerLabel.length) {
  5094. chart.renderer.box.setAttribute('aria-label', svgContainerLabel);
  5095. }
  5096. },
  5097. /**
  5098. * @private
  5099. */
  5100. setGraphicContainerAttrs: function () {
  5101. var chart = this.chart,
  5102. label = chart.langFormat('accessibility.graphicContainerLabel', {
  5103. chartTitle: getChartTitle(chart)
  5104. });
  5105. if (label.length) {
  5106. chart.container.setAttribute('aria-label', label);
  5107. }
  5108. },
  5109. /**
  5110. * @private
  5111. */
  5112. setRenderToAttrs: function () {
  5113. var chart = this.chart;
  5114. if (chart.options.accessibility.landmarkVerbosity !== 'disabled') {
  5115. chart.renderTo.setAttribute('role', 'region');
  5116. }
  5117. else {
  5118. chart.renderTo.removeAttribute('role');
  5119. }
  5120. chart.renderTo.setAttribute('aria-label', chart.langFormat('accessibility.chartContainerLabel', {
  5121. title: getChartTitle(chart),
  5122. chart: chart
  5123. }));
  5124. },
  5125. /**
  5126. * @private
  5127. */
  5128. makeCreditsAccessible: function () {
  5129. var chart = this.chart,
  5130. credits = chart.credits;
  5131. if (credits) {
  5132. if (credits.textStr) {
  5133. credits.element.setAttribute('aria-label', stripHTMLTags(chart.langFormat('accessibility.credits', { creditsStr: credits.textStr })));
  5134. }
  5135. unhideChartElementFromAT(chart, credits.element);
  5136. }
  5137. },
  5138. /**
  5139. * Accessibility disabled/chart destroyed.
  5140. */
  5141. destroy: function () {
  5142. this.chart.renderTo.setAttribute('aria-hidden', true);
  5143. }
  5144. });
  5145. return ContainerComponent;
  5146. });
  5147. _registerModule(_modules, 'Accessibility/HighContrastMode.js', [_modules['Core/Globals.js']], function (H) {
  5148. /* *
  5149. *
  5150. * (c) 2009-2020 Øystein Moseng
  5151. *
  5152. * Handling for Windows High Contrast Mode.
  5153. *
  5154. * License: www.highcharts.com/license
  5155. *
  5156. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5157. *
  5158. * */
  5159. var isMS = H.isMS,
  5160. win = H.win,
  5161. doc = win.document;
  5162. var whcm = {
  5163. /**
  5164. * Detect WHCM in the browser.
  5165. *
  5166. * @function Highcharts#isHighContrastModeActive
  5167. * @private
  5168. * @return {boolean} Returns true if the browser is in High Contrast mode.
  5169. */
  5170. isHighContrastModeActive: function () {
  5171. // Use media query on Edge, but not on IE
  5172. var isEdge = /(Edg)/.test(win.navigator.userAgent);
  5173. if (win.matchMedia && isEdge) {
  5174. return win.matchMedia('(-ms-high-contrast: active)').matches;
  5175. }
  5176. // Test BG image for IE
  5177. if (isMS && win.getComputedStyle) {
  5178. var testDiv = doc.createElement('div');
  5179. var imageSrc = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
  5180. testDiv.style.backgroundImage = "url(" + imageSrc + ")"; // #13071
  5181. doc.body.appendChild(testDiv);
  5182. var bi = (testDiv.currentStyle ||
  5183. win.getComputedStyle(testDiv)).backgroundImage;
  5184. doc.body.removeChild(testDiv);
  5185. return bi === 'none';
  5186. }
  5187. // Not used for other browsers
  5188. return false;
  5189. },
  5190. /**
  5191. * Force high contrast theme for the chart. The default theme is defined in
  5192. * a separate file.
  5193. *
  5194. * @function Highcharts#setHighContrastTheme
  5195. * @private
  5196. * @param {Highcharts.AccessibilityChart} chart The chart to set the theme of.
  5197. * @return {void}
  5198. */
  5199. setHighContrastTheme: function (chart) {
  5200. // We might want to add additional functionality here in the future for
  5201. // storing the old state so that we can reset the theme if HC mode is
  5202. // disabled. For now, the user will have to reload the page.
  5203. chart.highContrastModeActive = true;
  5204. // Apply theme to chart
  5205. var theme = (chart.options.accessibility.highContrastTheme);
  5206. chart.update(theme, false);
  5207. // Force series colors (plotOptions is not enough)
  5208. chart.series.forEach(function (s) {
  5209. var plotOpts = theme.plotOptions[s.type] || {};
  5210. s.update({
  5211. color: plotOpts.color || 'windowText',
  5212. colors: [plotOpts.color || 'windowText'],
  5213. borderColor: plotOpts.borderColor || 'window'
  5214. });
  5215. // Force point colors if existing
  5216. s.points.forEach(function (p) {
  5217. if (p.options && p.options.color) {
  5218. p.update({
  5219. color: plotOpts.color || 'windowText',
  5220. borderColor: plotOpts.borderColor || 'window'
  5221. }, false);
  5222. }
  5223. });
  5224. });
  5225. // The redraw for each series and after is required for 3D pie
  5226. // (workaround)
  5227. chart.redraw();
  5228. }
  5229. };
  5230. return whcm;
  5231. });
  5232. _registerModule(_modules, 'Accessibility/HighContrastTheme.js', [], function () {
  5233. /* *
  5234. *
  5235. * (c) 2009-2020 Øystein Moseng
  5236. *
  5237. * Default theme for Windows High Contrast Mode.
  5238. *
  5239. * License: www.highcharts.com/license
  5240. *
  5241. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5242. *
  5243. * */
  5244. var theme = {
  5245. chart: {
  5246. backgroundColor: 'window'
  5247. },
  5248. title: {
  5249. style: {
  5250. color: 'windowText'
  5251. }
  5252. },
  5253. subtitle: {
  5254. style: {
  5255. color: 'windowText'
  5256. }
  5257. },
  5258. colorAxis: {
  5259. minColor: 'windowText',
  5260. maxColor: 'windowText',
  5261. stops: []
  5262. },
  5263. colors: ['windowText'],
  5264. xAxis: {
  5265. gridLineColor: 'windowText',
  5266. labels: {
  5267. style: {
  5268. color: 'windowText'
  5269. }
  5270. },
  5271. lineColor: 'windowText',
  5272. minorGridLineColor: 'windowText',
  5273. tickColor: 'windowText',
  5274. title: {
  5275. style: {
  5276. color: 'windowText'
  5277. }
  5278. }
  5279. },
  5280. yAxis: {
  5281. gridLineColor: 'windowText',
  5282. labels: {
  5283. style: {
  5284. color: 'windowText'
  5285. }
  5286. },
  5287. lineColor: 'windowText',
  5288. minorGridLineColor: 'windowText',
  5289. tickColor: 'windowText',
  5290. title: {
  5291. style: {
  5292. color: 'windowText'
  5293. }
  5294. }
  5295. },
  5296. tooltip: {
  5297. backgroundColor: 'window',
  5298. borderColor: 'windowText',
  5299. style: {
  5300. color: 'windowText'
  5301. }
  5302. },
  5303. plotOptions: {
  5304. series: {
  5305. lineColor: 'windowText',
  5306. fillColor: 'window',
  5307. borderColor: 'windowText',
  5308. edgeColor: 'windowText',
  5309. borderWidth: 1,
  5310. dataLabels: {
  5311. connectorColor: 'windowText',
  5312. color: 'windowText',
  5313. style: {
  5314. color: 'windowText',
  5315. textOutline: 'none'
  5316. }
  5317. },
  5318. marker: {
  5319. lineColor: 'windowText',
  5320. fillColor: 'windowText'
  5321. }
  5322. },
  5323. pie: {
  5324. color: 'window',
  5325. colors: ['window'],
  5326. borderColor: 'windowText',
  5327. borderWidth: 1
  5328. },
  5329. boxplot: {
  5330. fillColor: 'window'
  5331. },
  5332. candlestick: {
  5333. lineColor: 'windowText',
  5334. fillColor: 'window'
  5335. },
  5336. errorbar: {
  5337. fillColor: 'window'
  5338. }
  5339. },
  5340. legend: {
  5341. backgroundColor: 'window',
  5342. itemStyle: {
  5343. color: 'windowText'
  5344. },
  5345. itemHoverStyle: {
  5346. color: 'windowText'
  5347. },
  5348. itemHiddenStyle: {
  5349. color: '#555'
  5350. },
  5351. title: {
  5352. style: {
  5353. color: 'windowText'
  5354. }
  5355. }
  5356. },
  5357. credits: {
  5358. style: {
  5359. color: 'windowText'
  5360. }
  5361. },
  5362. labels: {
  5363. style: {
  5364. color: 'windowText'
  5365. }
  5366. },
  5367. drilldown: {
  5368. activeAxisLabelStyle: {
  5369. color: 'windowText'
  5370. },
  5371. activeDataLabelStyle: {
  5372. color: 'windowText'
  5373. }
  5374. },
  5375. navigation: {
  5376. buttonOptions: {
  5377. symbolStroke: 'windowText',
  5378. theme: {
  5379. fill: 'window'
  5380. }
  5381. }
  5382. },
  5383. rangeSelector: {
  5384. buttonTheme: {
  5385. fill: 'window',
  5386. stroke: 'windowText',
  5387. style: {
  5388. color: 'windowText'
  5389. },
  5390. states: {
  5391. hover: {
  5392. fill: 'window',
  5393. stroke: 'windowText',
  5394. style: {
  5395. color: 'windowText'
  5396. }
  5397. },
  5398. select: {
  5399. fill: '#444',
  5400. stroke: 'windowText',
  5401. style: {
  5402. color: 'windowText'
  5403. }
  5404. }
  5405. }
  5406. },
  5407. inputBoxBorderColor: 'windowText',
  5408. inputStyle: {
  5409. backgroundColor: 'window',
  5410. color: 'windowText'
  5411. },
  5412. labelStyle: {
  5413. color: 'windowText'
  5414. }
  5415. },
  5416. navigator: {
  5417. handles: {
  5418. backgroundColor: 'window',
  5419. borderColor: 'windowText'
  5420. },
  5421. outlineColor: 'windowText',
  5422. maskFill: 'transparent',
  5423. series: {
  5424. color: 'windowText',
  5425. lineColor: 'windowText'
  5426. },
  5427. xAxis: {
  5428. gridLineColor: 'windowText'
  5429. }
  5430. },
  5431. scrollbar: {
  5432. barBackgroundColor: '#444',
  5433. barBorderColor: 'windowText',
  5434. buttonArrowColor: 'windowText',
  5435. buttonBackgroundColor: 'window',
  5436. buttonBorderColor: 'windowText',
  5437. rifleColor: 'windowText',
  5438. trackBackgroundColor: 'window',
  5439. trackBorderColor: 'windowText'
  5440. }
  5441. };
  5442. return theme;
  5443. });
  5444. _registerModule(_modules, 'Accessibility/Options/Options.js', [], function () {
  5445. /* *
  5446. *
  5447. * (c) 2009-2020 Øystein Moseng
  5448. *
  5449. * Default options for accessibility.
  5450. *
  5451. * License: www.highcharts.com/license
  5452. *
  5453. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5454. *
  5455. * */
  5456. /**
  5457. * Formatter callback for the accessibility announcement.
  5458. *
  5459. * @callback Highcharts.AccessibilityAnnouncementFormatter
  5460. *
  5461. * @param {Array<Highcharts.Series>} updatedSeries
  5462. * Array of all series that received updates. If an announcement is already
  5463. * queued, the series that received updates for that announcement are also
  5464. * included in this array.
  5465. *
  5466. * @param {Highcharts.Series} [addedSeries]
  5467. * This is provided if {@link Highcharts.Chart#addSeries} was called, and there
  5468. * is a new series. In that case, this argument is a reference to the new
  5469. * series.
  5470. *
  5471. * @param {Highcharts.Point} [addedPoint]
  5472. * This is provided if {@link Highcharts.Series#addPoint} was called, and there
  5473. * is a new point. In that case, this argument is a reference to the new point.
  5474. *
  5475. * @return {false|string}
  5476. * The function should return a string with the text to announce to the user.
  5477. * Return empty string to not announce anything. Return `false` to use the
  5478. * default announcement format.
  5479. */
  5480. /**
  5481. * @interface Highcharts.PointAccessibilityOptionsObject
  5482. */ /**
  5483. * Provide a description of the data point, announced to screen readers.
  5484. * @name Highcharts.PointAccessibilityOptionsObject#description
  5485. * @type {string|undefined}
  5486. * @requires modules/accessibility
  5487. * @since 7.1.0
  5488. */
  5489. /* *
  5490. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  5491. */ /**
  5492. * @name Highcharts.PointOptionsObject#accessibility
  5493. * @type {Highcharts.PointAccessibilityOptionsObject|undefined}
  5494. * @requires modules/accessibility
  5495. * @since 7.1.0
  5496. */
  5497. /**
  5498. * @callback Highcharts.ScreenReaderClickCallbackFunction
  5499. *
  5500. * @param {global.MouseEvent} evt
  5501. * Mouse click event
  5502. *
  5503. * @return {void}
  5504. */
  5505. /**
  5506. * Creates a formatted string for the screen reader module.
  5507. *
  5508. * @callback Highcharts.ScreenReaderFormatterCallbackFunction<T>
  5509. *
  5510. * @param {T} context
  5511. * Context to format
  5512. *
  5513. * @return {string}
  5514. * Formatted string for the screen reader module.
  5515. */
  5516. var options = {
  5517. /**
  5518. * Options for configuring accessibility for the chart. Requires the
  5519. * [accessibility module](https://code.highcharts.com/modules/accessibility.js)
  5520. * to be loaded. For a description of the module and information
  5521. * on its features, see
  5522. * [Highcharts Accessibility](https://www.highcharts.com/docs/chart-concepts/accessibility).
  5523. *
  5524. * @since 5.0.0
  5525. * @requires modules/accessibility
  5526. * @optionparent accessibility
  5527. */
  5528. accessibility: {
  5529. /**
  5530. * Enable accessibility functionality for the chart.
  5531. *
  5532. * @since 5.0.0
  5533. */
  5534. enabled: true,
  5535. /**
  5536. * Accessibility options for the screen reader information sections
  5537. * added before and after the chart.
  5538. *
  5539. * @since 8.0.0
  5540. */
  5541. screenReaderSection: {
  5542. /**
  5543. * Function to run upon clicking the "View as Data Table" link in
  5544. * the screen reader region.
  5545. *
  5546. * By default Highcharts will insert and set focus to a data table
  5547. * representation of the chart.
  5548. *
  5549. * @type {Highcharts.ScreenReaderClickCallbackFunction}
  5550. * @since 8.0.0
  5551. * @apioption accessibility.screenReaderSection.onViewDataTableClick
  5552. */
  5553. /**
  5554. * Function to run upon clicking the "Play as sound" button in
  5555. * the screen reader region.
  5556. *
  5557. * By default Highcharts will call the `chart.sonify` function.
  5558. *
  5559. * @type {Highcharts.ScreenReaderClickCallbackFunction}
  5560. * @since 8.0.1
  5561. * @apioption accessibility.screenReaderSection.onPlayAsSoundClick
  5562. */
  5563. /**
  5564. * A formatter function to create the HTML contents of the hidden
  5565. * screen reader information region before the chart. Receives one
  5566. * argument, `chart`, referring to the chart object. Should return a
  5567. * string with the HTML content of the region. By default this
  5568. * returns an automatic description of the chart based on
  5569. * [beforeChartFormat](#accessibility.screenReaderSection.beforeChartFormat).
  5570. *
  5571. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Chart>}
  5572. * @since 8.0.0
  5573. * @apioption accessibility.screenReaderSection.beforeChartFormatter
  5574. */
  5575. /**
  5576. * Format for the screen reader information region before the chart.
  5577. * Supported HTML tags are `<h1-7>`, `<p>`, `<div>`, `<a>`, `<ul>`,
  5578. * `<ol>`, `<li>`, and `<button>`. Attributes are not supported,
  5579. * except for id on `<div>`, `<a>`, and `<button>`. Id is required
  5580. * on `<a>` and `<button>` in the format `<tag id="abcd">`. Numbers,
  5581. * lower- and uppercase letters, "-" and "#" are valid characters in
  5582. * IDs.
  5583. *
  5584. * @since 8.0.0
  5585. */
  5586. beforeChartFormat: '<h5>{chartTitle}</h5>' +
  5587. '<div>{typeDescription}</div>' +
  5588. '<div>{chartSubtitle}</div>' +
  5589. '<div>{chartLongdesc}</div>' +
  5590. '<div>{playAsSoundButton}</div>' +
  5591. '<div>{viewTableButton}</div>' +
  5592. '<div>{xAxisDescription}</div>' +
  5593. '<div>{yAxisDescription}</div>' +
  5594. '<div>{annotationsTitle}{annotationsList}</div>',
  5595. /**
  5596. * A formatter function to create the HTML contents of the hidden
  5597. * screen reader information region after the chart. Analogous to
  5598. * [beforeChartFormatter](#accessibility.screenReaderSection.beforeChartFormatter).
  5599. *
  5600. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Chart>}
  5601. * @since 8.0.0
  5602. * @apioption accessibility.screenReaderSection.afterChartFormatter
  5603. */
  5604. /**
  5605. * Format for the screen reader information region after the chart.
  5606. * Analogous to [beforeChartFormat](#accessibility.screenReaderSection.beforeChartFormat).
  5607. *
  5608. * @since 8.0.0
  5609. */
  5610. afterChartFormat: '{endOfChartMarker}',
  5611. /**
  5612. * Date format to use to describe range of datetime axes.
  5613. *
  5614. * For an overview of the replacement codes, see
  5615. * [dateFormat](/class-reference/Highcharts#dateFormat).
  5616. *
  5617. * @see [point.dateFormat](#accessibility.point.dateFormat)
  5618. *
  5619. * @since 8.0.0
  5620. */
  5621. axisRangeDateFormat: '%Y-%m-%d %H:%M:%S'
  5622. },
  5623. /**
  5624. * Accessibility options global to all data series. Individual series
  5625. * can also have specific [accessibility options](#plotOptions.series.accessibility)
  5626. * set.
  5627. *
  5628. * @since 8.0.0
  5629. */
  5630. series: {
  5631. /**
  5632. * Formatter function to use instead of the default for series
  5633. * descriptions. Receives one argument, `series`, referring to the
  5634. * series to describe. Should return a string with the description
  5635. * of the series for a screen reader user. If `false` is returned,
  5636. * the default formatter will be used for that series.
  5637. *
  5638. * @see [series.description](#plotOptions.series.description)
  5639. *
  5640. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Series>}
  5641. * @since 8.0.0
  5642. * @apioption accessibility.series.descriptionFormatter
  5643. */
  5644. /**
  5645. * Whether or not to add series descriptions to charts with a single
  5646. * series.
  5647. *
  5648. * @since 8.0.0
  5649. */
  5650. describeSingleSeries: false,
  5651. /**
  5652. * When a series contains more points than this, we no longer expose
  5653. * information about individual points to screen readers.
  5654. *
  5655. * Set to `false` to disable.
  5656. *
  5657. * @type {boolean|number}
  5658. * @since 8.0.0
  5659. */
  5660. pointDescriptionEnabledThreshold: 200
  5661. },
  5662. /**
  5663. * Options for descriptions of individual data points.
  5664. *
  5665. * @since 8.0.0
  5666. */
  5667. point: {
  5668. /**
  5669. * Date format to use for points on datetime axes when describing
  5670. * them to screen reader users.
  5671. *
  5672. * Defaults to the same format as in tooltip.
  5673. *
  5674. * For an overview of the replacement codes, see
  5675. * [dateFormat](/class-reference/Highcharts#dateFormat).
  5676. *
  5677. * @see [dateFormatter](#accessibility.point.dateFormatter)
  5678. *
  5679. * @type {string}
  5680. * @since 8.0.0
  5681. * @apioption accessibility.point.dateFormat
  5682. */
  5683. /**
  5684. * Formatter function to determine the date/time format used with
  5685. * points on datetime axes when describing them to screen reader
  5686. * users. Receives one argument, `point`, referring to the point
  5687. * to describe. Should return a date format string compatible with
  5688. * [dateFormat](/class-reference/Highcharts#dateFormat).
  5689. *
  5690. * @see [dateFormat](#accessibility.point.dateFormat)
  5691. *
  5692. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Point>}
  5693. * @since 8.0.0
  5694. * @apioption accessibility.point.dateFormatter
  5695. */
  5696. /**
  5697. * Prefix to add to the values in the point descriptions. Uses
  5698. * [tooltip.valuePrefix](#tooltip.valuePrefix) if not defined.
  5699. *
  5700. * @type {string}
  5701. * @since 8.0.0
  5702. * @apioption accessibility.point.valuePrefix
  5703. */
  5704. /**
  5705. * Suffix to add to the values in the point descriptions. Uses
  5706. * [tooltip.valueSuffix](#tooltip.valueSuffix) if not defined.
  5707. *
  5708. * @type {string}
  5709. * @since 8.0.0
  5710. * @apioption accessibility.point.valueSuffix
  5711. */
  5712. /**
  5713. * Decimals to use for the values in the point descriptions. Uses
  5714. * [tooltip.valueDecimals](#tooltip.valueDecimals) if not defined.
  5715. *
  5716. * @type {number}
  5717. * @since 8.0.0
  5718. * @apioption accessibility.point.valueDecimals
  5719. */
  5720. /**
  5721. * Formatter function to use instead of the default for point
  5722. * descriptions.
  5723. *
  5724. * Receives one argument, `point`, referring to the point to
  5725. * describe. Should return a string with the description of the
  5726. * point for a screen reader user. If `false` is returned, the
  5727. * default formatter will be used for that point.
  5728. *
  5729. * Note: Prefer using [accessibility.point.valueDescriptionFormat](#accessibility.point.valueDescriptionFormat)
  5730. * instead if possible, as default functionality such as describing
  5731. * annotations will be preserved.
  5732. *
  5733. * @see [accessibility.point.valueDescriptionFormat](#accessibility.point.valueDescriptionFormat)
  5734. * @see [point.accessibility.description](#series.line.data.accessibility.description)
  5735. *
  5736. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Point>}
  5737. * @since 8.0.0
  5738. * @apioption accessibility.point.descriptionFormatter
  5739. */
  5740. /**
  5741. * Format to use for describing the values of data points
  5742. * to assistive technology - including screen readers.
  5743. * The point context is available as `{point}`.
  5744. *
  5745. * Additionally, the series name, annotation info, and
  5746. * description added in `point.accessibility.description`
  5747. * is added by default if relevant. To override this, use the
  5748. * [accessibility.point.descriptionFormatter](#accessibility.point.descriptionFormatter)
  5749. * option.
  5750. *
  5751. * @see [point.accessibility.description](#series.line.data.accessibility.description)
  5752. * @see [accessibility.point.descriptionFormatter](#accessibility.point.descriptionFormatter)
  5753. *
  5754. * @type {string}
  5755. * @since 8.0.1
  5756. */
  5757. valueDescriptionFormat: '{index}. {xDescription}{separator}{value}.'
  5758. },
  5759. /**
  5760. * Amount of landmarks/regions to create for screen reader users. More
  5761. * landmarks can make navigation with screen readers easier, but can
  5762. * be distracting if there are lots of charts on the page. Three modes
  5763. * are available:
  5764. * - `all`: Adds regions for all series, legend, menu, information
  5765. * region.
  5766. * - `one`: Adds a single landmark per chart.
  5767. * - `disabled`: No landmarks are added.
  5768. *
  5769. * @since 7.1.0
  5770. * @validvalue ["all", "one", "disabled"]
  5771. */
  5772. landmarkVerbosity: 'all',
  5773. /**
  5774. * Link the chart to an HTML element describing the contents of the
  5775. * chart.
  5776. *
  5777. * It is always recommended to describe charts using visible text, to
  5778. * improve SEO as well as accessibility for users with disabilities.
  5779. * This option lets an HTML element with a description be linked to the
  5780. * chart, so that screen reader users can connect the two.
  5781. *
  5782. * By setting this option to a string, Highcharts runs the string as an
  5783. * HTML selector query on the entire document. If there is only a single
  5784. * match, this element is linked to the chart. The content of the linked
  5785. * element will be included in the chart description for screen reader
  5786. * users.
  5787. *
  5788. * By default, the chart looks for an adjacent sibling element with the
  5789. * `highcharts-description` class.
  5790. *
  5791. * The feature can be disabled by setting the option to an empty string,
  5792. * or overridden by providing the
  5793. * [accessibility.description](#accessibility.description) option.
  5794. * Alternatively, the HTML element to link can be passed in directly as
  5795. * an HTML node.
  5796. *
  5797. * If you need the description to be part of the exported image,
  5798. * consider using the [caption](#caption) feature.
  5799. *
  5800. * If you need the description to be hidden visually, use the
  5801. * [accessibility.description](#accessibility.description) option.
  5802. *
  5803. * @see [caption](#caption)
  5804. * @see [description](#accessibility.description)
  5805. * @see [typeDescription](#accessibility.typeDescription)
  5806. *
  5807. * @sample highcharts/accessibility/accessible-line
  5808. * Accessible line chart
  5809. *
  5810. * @type {string|Highcharts.HTMLDOMElement}
  5811. * @since 8.0.0
  5812. */
  5813. linkedDescription: '*[data-highcharts-chart="{index}"] + .highcharts-description',
  5814. /**
  5815. * A hook for adding custom components to the accessibility module.
  5816. * Should be an object mapping component names to instances of classes
  5817. * inheriting from the Highcharts.AccessibilityComponent base class.
  5818. * Remember to add the component to the
  5819. * [keyboardNavigation.order](#accessibility.keyboardNavigation.order)
  5820. * for the keyboard navigation to be usable.
  5821. *
  5822. * @sample highcharts/accessibility/custom-component
  5823. * Custom accessibility component
  5824. *
  5825. * @type {*}
  5826. * @since 7.1.0
  5827. * @apioption accessibility.customComponents
  5828. */
  5829. /**
  5830. * Theme to apply to the chart when Windows High Contrast Mode is
  5831. * detected. By default, a high contrast theme matching the high
  5832. * contrast system system colors is used.
  5833. *
  5834. * @type {*}
  5835. * @since 7.1.3
  5836. * @apioption accessibility.highContrastTheme
  5837. */
  5838. /**
  5839. * A text description of the chart.
  5840. *
  5841. * **Note: Prefer using [linkedDescription](#accessibility.linkedDescription)
  5842. * or [caption](#caption.text) instead.**
  5843. *
  5844. * If the Accessibility module is loaded, this option is included by
  5845. * default as a long description of the chart in the hidden screen
  5846. * reader information region.
  5847. *
  5848. * Note: Since Highcharts now supports captions and linked descriptions,
  5849. * it is preferred to define the description using those methods, as a
  5850. * visible caption/description benefits all users. If the
  5851. * `accessibility.description` option is defined, the linked description
  5852. * is ignored, and the caption is hidden from screen reader users.
  5853. *
  5854. * @see [linkedDescription](#accessibility.linkedDescription)
  5855. * @see [caption](#caption)
  5856. * @see [typeDescription](#accessibility.typeDescription)
  5857. *
  5858. * @type {string}
  5859. * @since 5.0.0
  5860. * @apioption accessibility.description
  5861. */
  5862. /**
  5863. * A text description of the chart type.
  5864. *
  5865. * If the Accessibility module is loaded, this will be included in the
  5866. * description of the chart in the screen reader information region.
  5867. *
  5868. * Highcharts will by default attempt to guess the chart type, but for
  5869. * more complex charts it is recommended to specify this property for
  5870. * clarity.
  5871. *
  5872. * @type {string}
  5873. * @since 5.0.0
  5874. * @apioption accessibility.typeDescription
  5875. */
  5876. /**
  5877. * Options for keyboard navigation.
  5878. *
  5879. * @declare Highcharts.KeyboardNavigationOptionsObject
  5880. * @since 5.0.0
  5881. */
  5882. keyboardNavigation: {
  5883. /**
  5884. * Enable keyboard navigation for the chart.
  5885. *
  5886. * @since 5.0.0
  5887. */
  5888. enabled: true,
  5889. /**
  5890. * Options for the focus border drawn around elements while
  5891. * navigating through them.
  5892. *
  5893. * @sample highcharts/accessibility/custom-focus
  5894. * Custom focus ring
  5895. *
  5896. * @declare Highcharts.KeyboardNavigationFocusBorderOptionsObject
  5897. * @since 6.0.3
  5898. */
  5899. focusBorder: {
  5900. /**
  5901. * Enable/disable focus border for chart.
  5902. *
  5903. * @since 6.0.3
  5904. */
  5905. enabled: true,
  5906. /**
  5907. * Hide the browser's default focus indicator.
  5908. *
  5909. * @since 6.0.4
  5910. */
  5911. hideBrowserFocusOutline: true,
  5912. /**
  5913. * Style options for the focus border drawn around elements
  5914. * while navigating through them. Note that some browsers in
  5915. * addition draw their own borders for focused elements. These
  5916. * automatic borders can not be styled by Highcharts.
  5917. *
  5918. * In styled mode, the border is given the
  5919. * `.highcharts-focus-border` class.
  5920. *
  5921. * @type {Highcharts.CSSObject}
  5922. * @since 6.0.3
  5923. */
  5924. style: {
  5925. /** @internal */
  5926. color: '#335cad',
  5927. /** @internal */
  5928. lineWidth: 2,
  5929. /** @internal */
  5930. borderRadius: 3
  5931. },
  5932. /**
  5933. * Focus border margin around the elements.
  5934. *
  5935. * @since 6.0.3
  5936. */
  5937. margin: 2
  5938. },
  5939. /**
  5940. * Order of tab navigation in the chart. Determines which elements
  5941. * are tabbed to first. Available elements are: `series`, `zoom`,
  5942. * `rangeSelector`, `chartMenu`, `legend`. In addition, any custom
  5943. * components can be added here.
  5944. *
  5945. * @type {Array<string>}
  5946. * @since 7.1.0
  5947. */
  5948. order: ['series', 'zoom', 'rangeSelector', 'legend', 'chartMenu'],
  5949. /**
  5950. * Whether or not to wrap around when reaching the end of arrow-key
  5951. * navigation for an element in the chart.
  5952. * @since 7.1.0
  5953. */
  5954. wrapAround: true,
  5955. /**
  5956. * Options for the keyboard navigation of data points and series.
  5957. *
  5958. * @declare Highcharts.KeyboardNavigationSeriesNavigationOptionsObject
  5959. * @since 8.0.0
  5960. */
  5961. seriesNavigation: {
  5962. /**
  5963. * Set the keyboard navigation mode for the chart. Can be
  5964. * "normal" or "serialize". In normal mode, left/right arrow
  5965. * keys move between points in a series, while up/down arrow
  5966. * keys move between series. Up/down navigation acts
  5967. * intelligently to figure out which series makes sense to move
  5968. * to from any given point.
  5969. *
  5970. * In "serialize" mode, points are instead navigated as a single
  5971. * list. Left/right behaves as in "normal" mode. Up/down arrow
  5972. * keys will behave like left/right. This can be useful for
  5973. * unifying navigation behavior with/without screen readers
  5974. * enabled.
  5975. *
  5976. * @type {string}
  5977. * @default normal
  5978. * @since 8.0.0
  5979. * @validvalue ["normal", "serialize"]
  5980. * @apioption accessibility.keyboardNavigation.seriesNavigation.mode
  5981. */
  5982. /**
  5983. * Skip null points when navigating through points with the
  5984. * keyboard.
  5985. *
  5986. * @since 8.0.0
  5987. */
  5988. skipNullPoints: true,
  5989. /**
  5990. * When a series contains more points than this, we no longer
  5991. * allow keyboard navigation for it.
  5992. *
  5993. * Set to `false` to disable.
  5994. *
  5995. * @type {boolean|number}
  5996. * @since 8.0.0
  5997. */
  5998. pointNavigationEnabledThreshold: false
  5999. }
  6000. },
  6001. /**
  6002. * Options for announcing new data to screen reader users. Useful
  6003. * for dynamic data applications and drilldown.
  6004. *
  6005. * Keep in mind that frequent announcements will not be useful to
  6006. * users, as they won't have time to explore the new data. For these
  6007. * applications, consider making snapshots of the data accessible, and
  6008. * do the announcements in batches.
  6009. *
  6010. * @declare Highcharts.AccessibilityAnnounceNewDataOptionsObject
  6011. * @since 7.1.0
  6012. */
  6013. announceNewData: {
  6014. /**
  6015. * Optional formatter callback for the announcement. Receives
  6016. * up to three arguments. The first argument is always an array
  6017. * of all series that received updates. If an announcement is
  6018. * already queued, the series that received updates for that
  6019. * announcement are also included in this array. The second
  6020. * argument is provided if `chart.addSeries` was called, and
  6021. * there is a new series. In that case, this argument is a
  6022. * reference to the new series. The third argument, similarly,
  6023. * is provided if `series.addPoint` was called, and there is a
  6024. * new point. In that case, this argument is a reference to the
  6025. * new point.
  6026. *
  6027. * The function should return a string with the text to announce
  6028. * to the user. Return empty string to not announce anything.
  6029. * Return `false` to use the default announcement format.
  6030. *
  6031. * @sample highcharts/accessibility/custom-dynamic
  6032. * High priority live alerts
  6033. *
  6034. * @type {Highcharts.AccessibilityAnnouncementFormatter}
  6035. * @apioption accessibility.announceNewData.announcementFormatter
  6036. */
  6037. /**
  6038. * Enable announcing new data to screen reader users
  6039. * @sample highcharts/accessibility/accessible-dynamic
  6040. * Dynamic data accessible
  6041. */
  6042. enabled: false,
  6043. /**
  6044. * Minimum interval between announcements in milliseconds. If
  6045. * new data arrives before this amount of time has passed, it is
  6046. * queued for announcement. If another new data event happens
  6047. * while an announcement is queued, the queued announcement is
  6048. * dropped, and the latest announcement is queued instead. Set
  6049. * to 0 to allow all announcements, but be warned that frequent
  6050. * announcements are disturbing to users.
  6051. */
  6052. minAnnounceInterval: 5000,
  6053. /**
  6054. * Choose whether or not the announcements should interrupt the
  6055. * screen reader. If not enabled, the user will be notified once
  6056. * idle. It is recommended not to enable this setting unless
  6057. * there is a specific reason to do so.
  6058. */
  6059. interruptUser: false
  6060. }
  6061. },
  6062. /**
  6063. * Accessibility options for a data point.
  6064. *
  6065. * @declare Highcharts.PointAccessibilityOptionsObject
  6066. * @since 7.1.0
  6067. * @apioption series.line.data.accessibility
  6068. */
  6069. /**
  6070. * Provide a description of the data point, announced to screen readers.
  6071. *
  6072. * @type {string}
  6073. * @since 7.1.0
  6074. * @apioption series.line.data.accessibility.description
  6075. */
  6076. /**
  6077. * Accessibility options for a series.
  6078. *
  6079. * @declare Highcharts.SeriesAccessibilityOptionsObject
  6080. * @since 7.1.0
  6081. * @requires modules/accessibility
  6082. * @apioption plotOptions.series.accessibility
  6083. */
  6084. /**
  6085. * Enable/disable accessibility functionality for a specific series.
  6086. *
  6087. * @type {boolean}
  6088. * @since 7.1.0
  6089. * @apioption plotOptions.series.accessibility.enabled
  6090. */
  6091. /**
  6092. * Provide a description of the series, announced to screen readers.
  6093. *
  6094. * @type {string}
  6095. * @since 7.1.0
  6096. * @apioption plotOptions.series.accessibility.description
  6097. */
  6098. /**
  6099. * Formatter function to use instead of the default for point
  6100. * descriptions. Same as `accessibility.point.descriptionFormatter`, but for
  6101. * a single series.
  6102. *
  6103. * @see [accessibility.point.descriptionFormatter](#accessibility.point.descriptionFormatter)
  6104. *
  6105. * @type {Highcharts.ScreenReaderFormatterCallbackFunction<Highcharts.Point>}
  6106. * @since 7.1.0
  6107. * @apioption plotOptions.series.accessibility.pointDescriptionFormatter
  6108. */
  6109. /**
  6110. * Expose only the series element to screen readers, not its points.
  6111. *
  6112. * @type {boolean}
  6113. * @since 7.1.0
  6114. * @apioption plotOptions.series.accessibility.exposeAsGroupOnly
  6115. */
  6116. /**
  6117. * Keyboard navigation for a series
  6118. *
  6119. * @declare Highcharts.SeriesAccessibilityKeyboardNavigationOptionsObject
  6120. * @since 7.1.0
  6121. * @apioption plotOptions.series.accessibility.keyboardNavigation
  6122. */
  6123. /**
  6124. * Enable/disable keyboard navigation support for a specific series.
  6125. *
  6126. * @type {boolean}
  6127. * @since 7.1.0
  6128. * @apioption plotOptions.series.accessibility.keyboardNavigation.enabled
  6129. */
  6130. /**
  6131. * Accessibility options for an annotation label.
  6132. *
  6133. * @declare Highcharts.AnnotationLabelAccessibilityOptionsObject
  6134. * @since 8.0.1
  6135. * @requires modules/accessibility
  6136. * @apioption annotations.labelOptions.accessibility
  6137. */
  6138. /**
  6139. * Description of an annotation label for screen readers and other assistive
  6140. * technology.
  6141. *
  6142. * @type {string}
  6143. * @since 8.0.1
  6144. * @apioption annotations.labelOptions.accessibility.description
  6145. */
  6146. /**
  6147. * Accessibility options for an axis. Requires the accessibility module.
  6148. *
  6149. * @declare Highcharts.AxisAccessibilityOptionsObject
  6150. * @since 7.1.0
  6151. * @requires modules/accessibility
  6152. * @apioption xAxis.accessibility
  6153. */
  6154. /**
  6155. * Enable axis accessibility features, including axis information in the
  6156. * screen reader information region. If this is disabled on the xAxis, the
  6157. * x values are not exposed to screen readers for the individual data points
  6158. * by default.
  6159. *
  6160. * @type {boolean}
  6161. * @since 7.1.0
  6162. * @apioption xAxis.accessibility.enabled
  6163. */
  6164. /**
  6165. * Description for an axis to expose to screen reader users.
  6166. *
  6167. * @type {string}
  6168. * @since 7.1.0
  6169. * @apioption xAxis.accessibility.description
  6170. */
  6171. /**
  6172. * Range description for an axis. Overrides the default range description.
  6173. * Set to empty to disable range description for this axis.
  6174. *
  6175. * @type {string}
  6176. * @since 7.1.0
  6177. * @apioption xAxis.accessibility.rangeDescription
  6178. */
  6179. /**
  6180. * @optionparent legend
  6181. */
  6182. legend: {
  6183. /**
  6184. * Accessibility options for the legend. Requires the Accessibility
  6185. * module.
  6186. *
  6187. * @since 7.1.0
  6188. * @requires modules/accessibility
  6189. */
  6190. accessibility: {
  6191. /**
  6192. * Enable accessibility support for the legend.
  6193. *
  6194. * @since 7.1.0
  6195. */
  6196. enabled: true,
  6197. /**
  6198. * Options for keyboard navigation for the legend.
  6199. *
  6200. * @since 7.1.0
  6201. * @requires modules/accessibility
  6202. */
  6203. keyboardNavigation: {
  6204. /**
  6205. * Enable keyboard navigation for the legend.
  6206. *
  6207. * @see [accessibility.keyboardNavigation](#accessibility.keyboardNavigation.enabled)
  6208. *
  6209. * @since 7.1.0
  6210. */
  6211. enabled: true
  6212. }
  6213. }
  6214. },
  6215. /**
  6216. * @optionparent exporting
  6217. */
  6218. exporting: {
  6219. /**
  6220. * Accessibility options for the exporting menu. Requires the
  6221. * Accessibility module.
  6222. *
  6223. * @since 7.1.0
  6224. * @requires modules/accessibility
  6225. */
  6226. accessibility: {
  6227. /**
  6228. * Enable accessibility support for the export menu.
  6229. *
  6230. * @since 7.1.0
  6231. */
  6232. enabled: true
  6233. }
  6234. }
  6235. };
  6236. return options;
  6237. });
  6238. _registerModule(_modules, 'Accessibility/Options/LangOptions.js', [], function () {
  6239. /* *
  6240. *
  6241. * (c) 2009-2020 Øystein Moseng
  6242. *
  6243. * Default lang/i18n options for accessibility.
  6244. *
  6245. * License: www.highcharts.com/license
  6246. *
  6247. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6248. *
  6249. * */
  6250. var langOptions = {
  6251. /**
  6252. * Configure the accessibility strings in the chart. Requires the
  6253. * [accessibility module](https://code.highcharts.com/modules/accessibility.js)
  6254. * to be loaded. For a description of the module and information on its
  6255. * features, see
  6256. * [Highcharts Accessibility](https://www.highcharts.com/docs/chart-concepts/accessibility).
  6257. *
  6258. * For more dynamic control over the accessibility functionality, see
  6259. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  6260. * [accessibility.seriesDescriptionFormatter](#accessibility.seriesDescriptionFormatter),
  6261. * and
  6262. * [accessibility.screenReaderSectionFormatter](#accessibility.screenReaderSectionFormatter).
  6263. *
  6264. * @since 6.0.6
  6265. * @optionparent lang.accessibility
  6266. */
  6267. accessibility: {
  6268. defaultChartTitle: 'Chart',
  6269. chartContainerLabel: '{title}. Highcharts interactive chart.',
  6270. svgContainerLabel: 'Interactive chart',
  6271. drillUpButton: '{buttonText}',
  6272. credits: 'Chart credits: {creditsStr}',
  6273. /**
  6274. * Thousands separator to use when formatting numbers for screen
  6275. * readers. Note that many screen readers will not handle space as a
  6276. * thousands separator, and will consider "11 700" as two numbers.
  6277. *
  6278. * Set to `null` to use the separator defined in
  6279. * [lang.thousandsSep](lang.thousandsSep).
  6280. *
  6281. * @since 7.1.0
  6282. */
  6283. thousandsSep: ',',
  6284. /**
  6285. * Title element text for the chart SVG element. Leave this
  6286. * empty to disable adding the title element. Browsers will display
  6287. * this content when hovering over elements in the chart. Assistive
  6288. * technology may use this element to label the chart.
  6289. *
  6290. * @since 6.0.8
  6291. */
  6292. svgContainerTitle: '',
  6293. /**
  6294. * Set a label on the container wrapping the SVG.
  6295. *
  6296. * @see [chartContainerLabel](#lang.accessibility.chartContainerLabel)
  6297. *
  6298. * @since 8.0.0
  6299. */
  6300. graphicContainerLabel: '',
  6301. /**
  6302. * Language options for the screen reader information sections added
  6303. * before and after the charts.
  6304. *
  6305. * @since 8.0.0
  6306. */
  6307. screenReaderSection: {
  6308. beforeRegionLabel: 'Chart screen reader information.',
  6309. afterRegionLabel: '',
  6310. /**
  6311. * Language options for annotation descriptions.
  6312. *
  6313. * @since 8.0.1
  6314. */
  6315. annotations: {
  6316. heading: 'Chart annotations summary',
  6317. descriptionSinglePoint: '{annotationText}. Related to {annotationPoint}',
  6318. descriptionMultiplePoints: '{annotationText}. Related to {annotationPoint}' +
  6319. '{ Also related to, #each(additionalAnnotationPoints)}',
  6320. descriptionNoPoints: '{annotationText}'
  6321. },
  6322. /**
  6323. * Label for the end of the chart. Announced by screen readers.
  6324. *
  6325. * @since 8.0.0
  6326. */
  6327. endOfChartMarker: 'End of interactive chart.'
  6328. },
  6329. /**
  6330. * Language options for sonification.
  6331. *
  6332. * @since 8.0.1
  6333. */
  6334. sonification: {
  6335. playAsSoundButtonText: 'Play as sound, {chartTitle}',
  6336. playAsSoundClickAnnouncement: 'Play'
  6337. },
  6338. /**
  6339. * Language options for accessibility of the legend.
  6340. *
  6341. * @since 8.0.0
  6342. */
  6343. legend: {
  6344. legendLabel: 'Toggle series visibility',
  6345. legendItem: 'Hide {itemName}'
  6346. },
  6347. /**
  6348. * Chart and map zoom accessibility language options.
  6349. *
  6350. * @since 8.0.0
  6351. */
  6352. zoom: {
  6353. mapZoomIn: 'Zoom chart',
  6354. mapZoomOut: 'Zoom out chart',
  6355. resetZoomButton: 'Reset zoom'
  6356. },
  6357. /**
  6358. * Range selector language options for accessibility.
  6359. *
  6360. * @since 8.0.0
  6361. */
  6362. rangeSelector: {
  6363. minInputLabel: 'Select start date.',
  6364. maxInputLabel: 'Select end date.',
  6365. buttonText: 'Select range {buttonText}'
  6366. },
  6367. /**
  6368. * Accessibility language options for the data table.
  6369. *
  6370. * @since 8.0.0
  6371. */
  6372. table: {
  6373. viewAsDataTableButtonText: 'View as data table, {chartTitle}',
  6374. tableSummary: 'Table representation of chart.'
  6375. },
  6376. /**
  6377. * Default announcement for new data in charts. If addPoint or
  6378. * addSeries is used, and only one series/point is added, the
  6379. * `newPointAnnounce` and `newSeriesAnnounce` strings are used.
  6380. * The `...Single` versions will be used if there is only one chart
  6381. * on the page, and the `...Multiple` versions will be used if there
  6382. * are multiple charts on the page. For all other new data events,
  6383. * the `newDataAnnounce` string will be used.
  6384. *
  6385. * @since 7.1.0
  6386. */
  6387. announceNewData: {
  6388. newDataAnnounce: 'Updated data for chart {chartTitle}',
  6389. newSeriesAnnounceSingle: 'New data series: {seriesDesc}',
  6390. newPointAnnounceSingle: 'New data point: {pointDesc}',
  6391. newSeriesAnnounceMultiple: 'New data series in chart {chartTitle}: {seriesDesc}',
  6392. newPointAnnounceMultiple: 'New data point in chart {chartTitle}: {pointDesc}'
  6393. },
  6394. /**
  6395. * Descriptions of lesser known series types. The relevant
  6396. * description is added to the screen reader information region
  6397. * when these series types are used.
  6398. *
  6399. * @since 6.0.6
  6400. */
  6401. seriesTypeDescriptions: {
  6402. boxplot: 'Box plot charts are typically used to display ' +
  6403. 'groups of statistical data. Each data point in the ' +
  6404. 'chart can have up to 5 values: minimum, lower quartile, ' +
  6405. 'median, upper quartile, and maximum.',
  6406. arearange: 'Arearange charts are line charts displaying a ' +
  6407. 'range between a lower and higher value for each point.',
  6408. areasplinerange: 'These charts are line charts displaying a ' +
  6409. 'range between a lower and higher value for each point.',
  6410. bubble: 'Bubble charts are scatter charts where each data ' +
  6411. 'point also has a size value.',
  6412. columnrange: 'Columnrange charts are column charts ' +
  6413. 'displaying a range between a lower and higher value for ' +
  6414. 'each point.',
  6415. errorbar: 'Errorbar series are used to display the ' +
  6416. 'variability of the data.',
  6417. funnel: 'Funnel charts are used to display reduction of data ' +
  6418. 'in stages.',
  6419. pyramid: 'Pyramid charts consist of a single pyramid with ' +
  6420. 'item heights corresponding to each point value.',
  6421. waterfall: 'A waterfall chart is a column chart where each ' +
  6422. 'column contributes towards a total end value.'
  6423. },
  6424. /**
  6425. * Chart type description strings. This is added to the chart
  6426. * information region.
  6427. *
  6428. * If there is only a single series type used in the chart, we use
  6429. * the format string for the series type, or default if missing.
  6430. * There is one format string for cases where there is only a single
  6431. * series in the chart, and one for multiple series of the same
  6432. * type.
  6433. *
  6434. * @since 6.0.6
  6435. */
  6436. chartTypes: {
  6437. /* eslint-disable max-len */
  6438. emptyChart: 'Empty chart',
  6439. mapTypeDescription: 'Map of {mapTitle} with {numSeries} data series.',
  6440. unknownMap: 'Map of unspecified region with {numSeries} data series.',
  6441. combinationChart: 'Combination chart with {numSeries} data series.',
  6442. defaultSingle: 'Chart with {numPoints} data {#plural(numPoints, points, point)}.',
  6443. defaultMultiple: 'Chart with {numSeries} data series.',
  6444. splineSingle: 'Line chart with {numPoints} data {#plural(numPoints, points, point)}.',
  6445. splineMultiple: 'Line chart with {numSeries} lines.',
  6446. lineSingle: 'Line chart with {numPoints} data {#plural(numPoints, points, point)}.',
  6447. lineMultiple: 'Line chart with {numSeries} lines.',
  6448. columnSingle: 'Bar chart with {numPoints} {#plural(numPoints, bars, bar)}.',
  6449. columnMultiple: 'Bar chart with {numSeries} data series.',
  6450. barSingle: 'Bar chart with {numPoints} {#plural(numPoints, bars, bar)}.',
  6451. barMultiple: 'Bar chart with {numSeries} data series.',
  6452. pieSingle: 'Pie chart with {numPoints} {#plural(numPoints, slices, slice)}.',
  6453. pieMultiple: 'Pie chart with {numSeries} pies.',
  6454. scatterSingle: 'Scatter chart with {numPoints} {#plural(numPoints, points, point)}.',
  6455. scatterMultiple: 'Scatter chart with {numSeries} data series.',
  6456. boxplotSingle: 'Boxplot with {numPoints} {#plural(numPoints, boxes, box)}.',
  6457. boxplotMultiple: 'Boxplot with {numSeries} data series.',
  6458. bubbleSingle: 'Bubble chart with {numPoints} {#plural(numPoints, bubbles, bubble)}.',
  6459. bubbleMultiple: 'Bubble chart with {numSeries} data series.'
  6460. },
  6461. /**
  6462. * Axis description format strings.
  6463. *
  6464. * @since 6.0.6
  6465. */
  6466. axis: {
  6467. /* eslint-disable max-len */
  6468. xAxisDescriptionSingular: 'The chart has 1 X axis displaying {names[0]}. {ranges[0]}',
  6469. xAxisDescriptionPlural: 'The chart has {numAxes} X axes displaying {#each(names, -1) }and {names[-1]}.',
  6470. yAxisDescriptionSingular: 'The chart has 1 Y axis displaying {names[0]}. {ranges[0]}',
  6471. yAxisDescriptionPlural: 'The chart has {numAxes} Y axes displaying {#each(names, -1) }and {names[-1]}.',
  6472. timeRangeDays: 'Range: {range} days.',
  6473. timeRangeHours: 'Range: {range} hours.',
  6474. timeRangeMinutes: 'Range: {range} minutes.',
  6475. timeRangeSeconds: 'Range: {range} seconds.',
  6476. rangeFromTo: 'Range: {rangeFrom} to {rangeTo}.',
  6477. rangeCategories: 'Range: {numCategories} categories.'
  6478. },
  6479. /**
  6480. * Exporting menu format strings for accessibility module.
  6481. *
  6482. * @since 6.0.6
  6483. */
  6484. exporting: {
  6485. chartMenuLabel: 'Chart menu',
  6486. menuButtonLabel: 'View chart menu',
  6487. exportRegionLabel: 'Chart menu'
  6488. },
  6489. /**
  6490. * Lang configuration for different series types. For more dynamic
  6491. * control over the series element descriptions, see
  6492. * [accessibility.seriesDescriptionFormatter](#accessibility.seriesDescriptionFormatter).
  6493. *
  6494. * @since 6.0.6
  6495. */
  6496. series: {
  6497. /**
  6498. * Lang configuration for the series main summary. Each series
  6499. * type has two modes:
  6500. *
  6501. * 1. This series type is the only series type used in the
  6502. * chart
  6503. *
  6504. * 2. This is a combination chart with multiple series types
  6505. *
  6506. * If a definition does not exist for the specific series type
  6507. * and mode, the 'default' lang definitions are used.
  6508. *
  6509. * @since 6.0.6
  6510. */
  6511. summary: {
  6512. /* eslint-disable max-len */
  6513. 'default': '{name}, series {ix} of {numSeries} with {numPoints} data {#plural(numPoints, points, point)}.',
  6514. defaultCombination: '{name}, series {ix} of {numSeries} with {numPoints} data {#plural(numPoints, points, point)}.',
  6515. line: '{name}, line {ix} of {numSeries} with {numPoints} data {#plural(numPoints, points, point)}.',
  6516. lineCombination: '{name}, series {ix} of {numSeries}. Line with {numPoints} data {#plural(numPoints, points, point)}.',
  6517. spline: '{name}, line {ix} of {numSeries} with {numPoints} data {#plural(numPoints, points, point)}.',
  6518. splineCombination: '{name}, series {ix} of {numSeries}. Line with {numPoints} data {#plural(numPoints, points, point)}.',
  6519. column: '{name}, bar series {ix} of {numSeries} with {numPoints} {#plural(numPoints, bars, bar)}.',
  6520. columnCombination: '{name}, series {ix} of {numSeries}. Bar series with {numPoints} {#plural(numPoints, bars, bar)}.',
  6521. bar: '{name}, bar series {ix} of {numSeries} with {numPoints} {#plural(numPoints, bars, bar)}.',
  6522. barCombination: '{name}, series {ix} of {numSeries}. Bar series with {numPoints} {#plural(numPoints, bars, bar)}.',
  6523. pie: '{name}, pie {ix} of {numSeries} with {numPoints} {#plural(numPoints, slices, slice)}.',
  6524. pieCombination: '{name}, series {ix} of {numSeries}. Pie with {numPoints} {#plural(numPoints, slices, slice)}.',
  6525. scatter: '{name}, scatter plot {ix} of {numSeries} with {numPoints} {#plural(numPoints, points, point)}.',
  6526. scatterCombination: '{name}, series {ix} of {numSeries}, scatter plot with {numPoints} {#plural(numPoints, points, point)}.',
  6527. boxplot: '{name}, boxplot {ix} of {numSeries} with {numPoints} {#plural(numPoints, boxes, box)}.',
  6528. boxplotCombination: '{name}, series {ix} of {numSeries}. Boxplot with {numPoints} {#plural(numPoints, boxes, box)}.',
  6529. bubble: '{name}, bubble series {ix} of {numSeries} with {numPoints} {#plural(numPoints, bubbles, bubble)}.',
  6530. bubbleCombination: '{name}, series {ix} of {numSeries}. Bubble series with {numPoints} {#plural(numPoints, bubbles, bubble)}.',
  6531. map: '{name}, map {ix} of {numSeries} with {numPoints} {#plural(numPoints, areas, area)}.',
  6532. mapCombination: '{name}, series {ix} of {numSeries}. Map with {numPoints} {#plural(numPoints, areas, area)}.',
  6533. mapline: '{name}, line {ix} of {numSeries} with {numPoints} data {#plural(numPoints, points, point)}.',
  6534. maplineCombination: '{name}, series {ix} of {numSeries}. Line with {numPoints} data {#plural(numPoints, points, point)}.',
  6535. mapbubble: '{name}, bubble series {ix} of {numSeries} with {numPoints} {#plural(numPoints, bubbles, bubble)}.',
  6536. mapbubbleCombination: '{name}, series {ix} of {numSeries}. Bubble series with {numPoints} {#plural(numPoints, bubbles, bubble)}.'
  6537. },
  6538. /**
  6539. * User supplied description text. This is added in the point
  6540. * comment description by default if present.
  6541. *
  6542. * @since 6.0.6
  6543. */
  6544. description: '{description}',
  6545. /**
  6546. * xAxis description for series if there are multiple xAxes in
  6547. * the chart.
  6548. *
  6549. * @since 6.0.6
  6550. */
  6551. xAxisDescription: 'X axis, {name}',
  6552. /**
  6553. * yAxis description for series if there are multiple yAxes in
  6554. * the chart.
  6555. *
  6556. * @since 6.0.6
  6557. */
  6558. yAxisDescription: 'Y axis, {name}',
  6559. /**
  6560. * Description for the value of null points.
  6561. *
  6562. * @since 8.0.0
  6563. */
  6564. nullPointValue: 'No value',
  6565. /**
  6566. * Description for annotations on a point, as it is made available
  6567. * to assistive technology.
  6568. *
  6569. * @since 8.0.1
  6570. */
  6571. pointAnnotationsDescription: '{Annotation: #each(annotations). }'
  6572. }
  6573. }
  6574. };
  6575. return langOptions;
  6576. });
  6577. _registerModule(_modules, 'Accessibility/Options/DeprecatedOptions.js', [_modules['Core/Utilities.js']], function (U) {
  6578. /* *
  6579. *
  6580. * (c) 2009-2020 Øystein Moseng
  6581. *
  6582. * Default options for accessibility.
  6583. *
  6584. * License: www.highcharts.com/license
  6585. *
  6586. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6587. *
  6588. * */
  6589. /* eslint-disable max-len */
  6590. /*
  6591. * List of deprecated options:
  6592. *
  6593. * chart.description -> accessibility.description
  6594. * chart.typeDescription -> accessibility.typeDescription
  6595. * series.description -> series.accessibility.description
  6596. * series.exposeElementToA11y -> series.accessibility.exposeAsGroupOnly
  6597. * series.pointDescriptionFormatter ->
  6598. * series.accessibility.pointDescriptionFormatter
  6599. * series.skipKeyboardNavigation ->
  6600. * series.accessibility.keyboardNavigation.enabled
  6601. * point.description -> point.accessibility.description !!!! WARNING: No longer deprecated and handled, removed for HC8.
  6602. * axis.description -> axis.accessibility.description
  6603. *
  6604. * accessibility.pointDateFormat -> accessibility.point.dateFormat
  6605. * accessibility.addTableShortcut -> Handled by screenReaderSection.beforeChartFormat
  6606. * accessibility.pointDateFormatter -> accessibility.point.dateFormatter
  6607. * accessibility.pointDescriptionFormatter -> accessibility.point.descriptionFormatter
  6608. * accessibility.pointDescriptionThreshold -> accessibility.series.pointDescriptionEnabledThreshold
  6609. * accessibility.pointNavigationThreshold -> accessibility.keyboardNavigation.seriesNavigation.pointNavigationEnabledThreshold
  6610. * accessibility.pointValueDecimals -> accessibility.point.valueDecimals
  6611. * accessibility.pointValuePrefix -> accessibility.point.valuePrefix
  6612. * accessibility.pointValueSuffix -> accessibility.point.valueSuffix
  6613. * accessibility.screenReaderSectionFormatter -> accessibility.screenReaderSection.beforeChartFormatter
  6614. * accessibility.describeSingleSeries -> accessibility.series.describeSingleSeries
  6615. * accessibility.seriesDescriptionFormatter -> accessibility.series.descriptionFormatter
  6616. * accessibility.onTableAnchorClick -> accessibility.screenReaderSection.onViewDataTableClick
  6617. * accessibility.axisRangeDateFormat -> accessibility.screenReaderSection.axisRangeDateFormat
  6618. * accessibility.keyboardNavigation.skipNullPoints -> accessibility.keyboardNavigation.seriesNavigation.skipNullPoints
  6619. * accessibility.keyboardNavigation.mode -> accessibility.keyboardNavigation.seriesNavigation.mode
  6620. *
  6621. * lang.accessibility.chartHeading -> no longer used, remove
  6622. * lang.accessibility.legendItem -> lang.accessibility.legend.legendItem
  6623. * lang.accessibility.legendLabel -> lang.accessibility.legend.legendLabel
  6624. * lang.accessibility.mapZoomIn -> lang.accessibility.zoom.mapZoomIn
  6625. * lang.accessibility.mapZoomOut -> lang.accessibility.zoom.mapZoomOut
  6626. * lang.accessibility.resetZoomButton -> lang.accessibility.zoom.resetZoomButton
  6627. * lang.accessibility.screenReaderRegionLabel -> lang.accessibility.screenReaderSection.beforeRegionLabel
  6628. * lang.accessibility.rangeSelectorButton -> lang.accessibility.rangeSelector.buttonText
  6629. * lang.accessibility.rangeSelectorMaxInput -> lang.accessibility.rangeSelector.maxInputLabel
  6630. * lang.accessibility.rangeSelectorMinInput -> lang.accessibility.rangeSelector.minInputLabel
  6631. * lang.accessibility.svgContainerEnd -> lang.accessibility.screenReaderSection.endOfChartMarker
  6632. * lang.accessibility.viewAsDataTable -> lang.accessibility.table.viewAsDataTableButtonText
  6633. * lang.accessibility.tableSummary -> lang.accessibility.table.tableSummary
  6634. *
  6635. */
  6636. /* eslint-enable max-len */
  6637. var error = U.error,
  6638. pick = U.pick;
  6639. /* eslint-disable valid-jsdoc */
  6640. /**
  6641. * Set a new option on a root prop, where the option is defined as an array of
  6642. * suboptions.
  6643. * @private
  6644. * @param root
  6645. * @param {Array<string>} optionAsArray
  6646. * @param {*} val
  6647. * @return {void}
  6648. */
  6649. function traverseSetOption(root, optionAsArray, val) {
  6650. var opt = root,
  6651. prop,
  6652. i = 0;
  6653. for (; i < optionAsArray.length - 1; ++i) {
  6654. prop = optionAsArray[i];
  6655. opt = opt[prop] = pick(opt[prop], {});
  6656. }
  6657. opt[optionAsArray[optionAsArray.length - 1]] = val;
  6658. }
  6659. /**
  6660. * If we have a clear root option node for old and new options and a mapping
  6661. * between, we can use this generic function for the copy and warn logic.
  6662. */
  6663. function deprecateFromOptionsMap(chart, rootOldAsArray, rootNewAsArray, mapToNewOptions) {
  6664. /**
  6665. * @private
  6666. */
  6667. function getChildProp(root, propAsArray) {
  6668. return propAsArray.reduce(function (acc, cur) {
  6669. return acc[cur];
  6670. }, root);
  6671. }
  6672. var rootOld = getChildProp(chart.options,
  6673. rootOldAsArray),
  6674. rootNew = getChildProp(chart.options,
  6675. rootNewAsArray);
  6676. Object.keys(mapToNewOptions).forEach(function (oldOptionKey) {
  6677. var _a;
  6678. var val = rootOld[oldOptionKey];
  6679. if (typeof val !== 'undefined') {
  6680. traverseSetOption(rootNew, mapToNewOptions[oldOptionKey], val);
  6681. error(32, false, chart, (_a = {},
  6682. _a[rootOldAsArray.join('.') + "." + oldOptionKey] = rootNewAsArray.join('.') + "." + mapToNewOptions[oldOptionKey].join('.'),
  6683. _a));
  6684. }
  6685. });
  6686. }
  6687. /**
  6688. * @private
  6689. */
  6690. function copyDeprecatedChartOptions(chart) {
  6691. var chartOptions = chart.options.chart || {},
  6692. a11yOptions = chart.options.accessibility || {};
  6693. ['description', 'typeDescription'].forEach(function (prop) {
  6694. var _a;
  6695. if (chartOptions[prop]) {
  6696. a11yOptions[prop] = chartOptions[prop];
  6697. error(32, false, chart, (_a = {}, _a["chart." + prop] = "use accessibility." + prop, _a));
  6698. }
  6699. });
  6700. }
  6701. /**
  6702. * @private
  6703. */
  6704. function copyDeprecatedAxisOptions(chart) {
  6705. chart.axes.forEach(function (axis) {
  6706. var opts = axis.options;
  6707. if (opts && opts.description) {
  6708. opts.accessibility = opts.accessibility || {};
  6709. opts.accessibility.description = opts.description;
  6710. error(32, false, chart, { 'axis.description': 'use axis.accessibility.description' });
  6711. }
  6712. });
  6713. }
  6714. /**
  6715. * @private
  6716. */
  6717. function copyDeprecatedSeriesOptions(chart) {
  6718. // Map of deprecated series options. New options are defined as
  6719. // arrays of paths under series.options.
  6720. var oldToNewSeriesOptions = {
  6721. description: ['accessibility', 'description'],
  6722. exposeElementToA11y: ['accessibility', 'exposeAsGroupOnly'],
  6723. pointDescriptionFormatter: [
  6724. 'accessibility', 'pointDescriptionFormatter'
  6725. ],
  6726. skipKeyboardNavigation: [
  6727. 'accessibility', 'keyboardNavigation', 'enabled'
  6728. ]
  6729. };
  6730. chart.series.forEach(function (series) {
  6731. // Handle series wide options
  6732. Object.keys(oldToNewSeriesOptions).forEach(function (oldOption) {
  6733. var _a;
  6734. var optionVal = series.options[oldOption];
  6735. if (typeof optionVal !== 'undefined') {
  6736. // Set the new option
  6737. traverseSetOption(series.options, oldToNewSeriesOptions[oldOption],
  6738. // Note that skipKeyboardNavigation has inverted option
  6739. // value, since we set enabled rather than disabled
  6740. oldOption === 'skipKeyboardNavigation' ?
  6741. !optionVal : optionVal);
  6742. error(32, false, chart, (_a = {}, _a["series." + oldOption] = "series." + oldToNewSeriesOptions[oldOption].join('.'), _a));
  6743. }
  6744. });
  6745. });
  6746. }
  6747. /**
  6748. * @private
  6749. */
  6750. function copyDeprecatedTopLevelAccessibilityOptions(chart) {
  6751. deprecateFromOptionsMap(chart, ['accessibility'], ['accessibility'], {
  6752. pointDateFormat: ['point', 'dateFormat'],
  6753. pointDateFormatter: ['point', 'dateFormatter'],
  6754. pointDescriptionFormatter: ['point', 'descriptionFormatter'],
  6755. pointDescriptionThreshold: ['series',
  6756. 'pointDescriptionEnabledThreshold'],
  6757. pointNavigationThreshold: ['keyboardNavigation', 'seriesNavigation',
  6758. 'pointNavigationEnabledThreshold'],
  6759. pointValueDecimals: ['point', 'valueDecimals'],
  6760. pointValuePrefix: ['point', 'valuePrefix'],
  6761. pointValueSuffix: ['point', 'valueSuffix'],
  6762. screenReaderSectionFormatter: ['screenReaderSection',
  6763. 'beforeChartFormatter'],
  6764. describeSingleSeries: ['series', 'describeSingleSeries'],
  6765. seriesDescriptionFormatter: ['series', 'descriptionFormatter'],
  6766. onTableAnchorClick: ['screenReaderSection', 'onViewDataTableClick'],
  6767. axisRangeDateFormat: ['screenReaderSection', 'axisRangeDateFormat']
  6768. });
  6769. }
  6770. /**
  6771. * @private
  6772. */
  6773. function copyDeprecatedKeyboardNavigationOptions(chart) {
  6774. deprecateFromOptionsMap(chart, ['accessibility', 'keyboardNavigation'], ['accessibility', 'keyboardNavigation', 'seriesNavigation'], {
  6775. skipNullPoints: ['skipNullPoints'],
  6776. mode: ['mode']
  6777. });
  6778. }
  6779. /**
  6780. * @private
  6781. */
  6782. function copyDeprecatedLangOptions(chart) {
  6783. deprecateFromOptionsMap(chart, ['lang', 'accessibility'], ['lang', 'accessibility'], {
  6784. legendItem: ['legend', 'legendItem'],
  6785. legendLabel: ['legend', 'legendLabel'],
  6786. mapZoomIn: ['zoom', 'mapZoomIn'],
  6787. mapZoomOut: ['zoom', 'mapZoomOut'],
  6788. resetZoomButton: ['zoom', 'resetZoomButton'],
  6789. screenReaderRegionLabel: ['screenReaderSection',
  6790. 'beforeRegionLabel'],
  6791. rangeSelectorButton: ['rangeSelector', 'buttonText'],
  6792. rangeSelectorMaxInput: ['rangeSelector', 'maxInputLabel'],
  6793. rangeSelectorMinInput: ['rangeSelector', 'minInputLabel'],
  6794. svgContainerEnd: ['screenReaderSection', 'endOfChartMarker'],
  6795. viewAsDataTable: ['table', 'viewAsDataTableButtonText'],
  6796. tableSummary: ['table', 'tableSummary']
  6797. });
  6798. }
  6799. /**
  6800. * Copy options that are deprecated over to new options. Logs warnings to
  6801. * console if deprecated options are used.
  6802. *
  6803. * @private
  6804. */
  6805. function copyDeprecatedOptions(chart) {
  6806. copyDeprecatedChartOptions(chart);
  6807. copyDeprecatedAxisOptions(chart);
  6808. if (chart.series) {
  6809. copyDeprecatedSeriesOptions(chart);
  6810. }
  6811. copyDeprecatedTopLevelAccessibilityOptions(chart);
  6812. copyDeprecatedKeyboardNavigationOptions(chart);
  6813. copyDeprecatedLangOptions(chart);
  6814. }
  6815. return copyDeprecatedOptions;
  6816. });
  6817. _registerModule(_modules, 'Accessibility/A11yI18n.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  6818. /* *
  6819. *
  6820. * Accessibility module - internationalization support
  6821. *
  6822. * (c) 2010-2020 Highsoft AS
  6823. * Author: Øystein Moseng
  6824. *
  6825. * License: www.highcharts.com/license
  6826. *
  6827. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6828. *
  6829. * */
  6830. var format = U.format,
  6831. pick = U.pick;
  6832. /* eslint-disable valid-jsdoc */
  6833. /**
  6834. * String trim that works for IE6-8 as well.
  6835. *
  6836. * @private
  6837. * @function stringTrim
  6838. *
  6839. * @param {string} str
  6840. * The input string
  6841. *
  6842. * @return {string}
  6843. * The trimmed string
  6844. */
  6845. function stringTrim(str) {
  6846. return str.trim && str.trim() || str.replace(/^\s+|\s+$/g, '');
  6847. }
  6848. /**
  6849. * i18n utility function. Format a single array or plural statement in a format
  6850. * string. If the statement is not an array or plural statement, returns the
  6851. * statement within brackets. Invalid array statements return an empty string.
  6852. *
  6853. * @private
  6854. * @function formatExtendedStatement
  6855. *
  6856. * @param {string} statement
  6857. *
  6858. * @param {Highcharts.Dictionary<*>} ctx
  6859. * Context to apply to the format string.
  6860. *
  6861. * @return {string}
  6862. */
  6863. function formatExtendedStatement(statement, ctx) {
  6864. var eachStart = statement.indexOf('#each('), pluralStart = statement.indexOf('#plural('), indexStart = statement.indexOf('['), indexEnd = statement.indexOf(']'), arr, result;
  6865. // Dealing with an each-function?
  6866. if (eachStart > -1) {
  6867. var eachEnd = statement.slice(eachStart).indexOf(')') + eachStart, preEach = statement.substring(0, eachStart), postEach = statement.substring(eachEnd + 1), eachStatement = statement.substring(eachStart + 6, eachEnd), eachArguments = eachStatement.split(','), lenArg = Number(eachArguments[1]), len;
  6868. result = '';
  6869. arr = ctx[eachArguments[0]];
  6870. if (arr) {
  6871. lenArg = isNaN(lenArg) ? arr.length : lenArg;
  6872. len = lenArg < 0 ?
  6873. arr.length + lenArg :
  6874. Math.min(lenArg, arr.length); // Overshoot
  6875. // Run through the array for the specified length
  6876. for (var i = 0; i < len; ++i) {
  6877. result += preEach + arr[i] + postEach;
  6878. }
  6879. }
  6880. return result.length ? result : '';
  6881. }
  6882. // Dealing with a plural-function?
  6883. if (pluralStart > -1) {
  6884. var pluralEnd = statement.slice(pluralStart).indexOf(')') + pluralStart, pluralStatement = statement.substring(pluralStart + 8, pluralEnd), pluralArguments = pluralStatement.split(','), num = Number(ctx[pluralArguments[0]]);
  6885. switch (num) {
  6886. case 0:
  6887. result = pick(pluralArguments[4], pluralArguments[1]);
  6888. break;
  6889. case 1:
  6890. result = pick(pluralArguments[2], pluralArguments[1]);
  6891. break;
  6892. case 2:
  6893. result = pick(pluralArguments[3], pluralArguments[1]);
  6894. break;
  6895. default:
  6896. result = pluralArguments[1];
  6897. }
  6898. return result ? stringTrim(result) : '';
  6899. }
  6900. // Array index
  6901. if (indexStart > -1) {
  6902. var arrayName = statement.substring(0,
  6903. indexStart),
  6904. ix = Number(statement.substring(indexStart + 1,
  6905. indexEnd)),
  6906. val;
  6907. arr = ctx[arrayName];
  6908. if (!isNaN(ix) && arr) {
  6909. if (ix < 0) {
  6910. val = arr[arr.length + ix];
  6911. // Handle negative overshoot
  6912. if (typeof val === 'undefined') {
  6913. val = arr[0];
  6914. }
  6915. }
  6916. else {
  6917. val = arr[ix];
  6918. // Handle positive overshoot
  6919. if (typeof val === 'undefined') {
  6920. val = arr[arr.length - 1];
  6921. }
  6922. }
  6923. }
  6924. return typeof val !== 'undefined' ? val : '';
  6925. }
  6926. // Standard substitution, delegate to format or similar
  6927. return '{' + statement + '}';
  6928. }
  6929. /**
  6930. * i18n formatting function. Extends Highcharts.format() functionality by also
  6931. * handling arrays and plural conditionals. Arrays can be indexed as follows:
  6932. *
  6933. * - Format: 'This is the first index: {myArray[0]}. The last: {myArray[-1]}.'
  6934. *
  6935. * - Context: { myArray: [0, 1, 2, 3, 4, 5] }
  6936. *
  6937. * - Result: 'This is the first index: 0. The last: 5.'
  6938. *
  6939. *
  6940. * They can also be iterated using the #each() function. This will repeat the
  6941. * contents of the bracket expression for each element. Example:
  6942. *
  6943. * - Format: 'List contains: {#each(myArray)cm }'
  6944. *
  6945. * - Context: { myArray: [0, 1, 2] }
  6946. *
  6947. * - Result: 'List contains: 0cm 1cm 2cm '
  6948. *
  6949. *
  6950. * The #each() function optionally takes a length parameter. If positive, this
  6951. * parameter specifies the max number of elements to iterate through. If
  6952. * negative, the function will subtract the number from the length of the array.
  6953. * Use this to stop iterating before the array ends. Example:
  6954. *
  6955. * - Format: 'List contains: {#each(myArray, -1) }and {myArray[-1]}.'
  6956. *
  6957. * - Context: { myArray: [0, 1, 2, 3] }
  6958. *
  6959. * - Result: 'List contains: 0, 1, 2, and 3.'
  6960. *
  6961. *
  6962. * Use the #plural() function to pick a string depending on whether or not a
  6963. * context object is 1. Arguments are #plural(obj, plural, singular). Example:
  6964. *
  6965. * - Format: 'Has {numPoints} {#plural(numPoints, points, point}.'
  6966. *
  6967. * - Context: { numPoints: 5 }
  6968. *
  6969. * - Result: 'Has 5 points.'
  6970. *
  6971. *
  6972. * Optionally there are additional parameters for dual and none: #plural(obj,
  6973. * plural, singular, dual, none). Example:
  6974. *
  6975. * - Format: 'Has {#plural(numPoints, many points, one point, two points,
  6976. * none}.'
  6977. *
  6978. * - Context: { numPoints: 2 }
  6979. *
  6980. * - Result: 'Has two points.'
  6981. *
  6982. *
  6983. * The dual or none parameters will take precedence if they are supplied.
  6984. *
  6985. * @requires modules/accessibility
  6986. *
  6987. * @function Highcharts.i18nFormat
  6988. *
  6989. * @param {string} formatString
  6990. * The string to format.
  6991. *
  6992. * @param {Highcharts.Dictionary<*>} context
  6993. * Context to apply to the format string.
  6994. *
  6995. * @param {Highcharts.Chart} chart
  6996. * A `Chart` instance with a time object and numberFormatter, passed on
  6997. * to format().
  6998. *
  6999. * @return {string}
  7000. * The formatted string.
  7001. */
  7002. H.i18nFormat = function (formatString, context, chart) {
  7003. var getFirstBracketStatement = function (sourceStr, offset) {
  7004. var str = sourceStr.slice(offset || 0), startBracket = str.indexOf('{'), endBracket = str.indexOf('}');
  7005. if (startBracket > -1 && endBracket > startBracket) {
  7006. return {
  7007. statement: str.substring(startBracket + 1, endBracket),
  7008. begin: offset + startBracket + 1,
  7009. end: offset + endBracket
  7010. };
  7011. }
  7012. }, tokens = [], bracketRes, constRes, cursor = 0;
  7013. // Tokenize format string into bracket statements and constants
  7014. do {
  7015. bracketRes = getFirstBracketStatement(formatString, cursor);
  7016. constRes = formatString.substring(cursor, bracketRes && bracketRes.begin - 1);
  7017. // If we have constant content before this bracket statement, add it
  7018. if (constRes.length) {
  7019. tokens.push({
  7020. value: constRes,
  7021. type: 'constant'
  7022. });
  7023. }
  7024. // Add the bracket statement
  7025. if (bracketRes) {
  7026. tokens.push({
  7027. value: bracketRes.statement,
  7028. type: 'statement'
  7029. });
  7030. }
  7031. cursor = bracketRes ? bracketRes.end + 1 : cursor + 1;
  7032. } while (bracketRes);
  7033. // Perform the formatting. The formatArrayStatement function returns the
  7034. // statement in brackets if it is not an array statement, which means it
  7035. // gets picked up by format below.
  7036. tokens.forEach(function (token) {
  7037. if (token.type === 'statement') {
  7038. token.value = formatExtendedStatement(token.value, context);
  7039. }
  7040. });
  7041. // Join string back together and pass to format to pick up non-array
  7042. // statements.
  7043. return format(tokens.reduce(function (acc, cur) {
  7044. return acc + cur.value;
  7045. }, ''), context, chart);
  7046. };
  7047. /**
  7048. * Apply context to a format string from lang options of the chart.
  7049. *
  7050. * @requires modules/accessibility
  7051. *
  7052. * @function Highcharts.Chart#langFormat
  7053. *
  7054. * @param {string} langKey
  7055. * Key (using dot notation) into lang option structure.
  7056. *
  7057. * @param {Highcharts.Dictionary<*>} context
  7058. * Context to apply to the format string.
  7059. *
  7060. * @return {string}
  7061. * The formatted string.
  7062. */
  7063. H.Chart.prototype.langFormat = function (langKey, context) {
  7064. var keys = langKey.split('.'),
  7065. formatString = this.options.lang,
  7066. i = 0;
  7067. for (; i < keys.length; ++i) {
  7068. formatString = formatString && formatString[keys[i]];
  7069. }
  7070. return typeof formatString === 'string' ?
  7071. H.i18nFormat(formatString, context, this) : '';
  7072. };
  7073. });
  7074. _registerModule(_modules, 'Accessibility/FocusBorder.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Utilities.js']], function (H, SVGElement, SVGLabel, U) {
  7075. /* *
  7076. *
  7077. * (c) 2009-2020 Øystein Moseng
  7078. *
  7079. * Extend SVG and Chart classes with focus border capabilities.
  7080. *
  7081. * License: www.highcharts.com/license
  7082. *
  7083. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7084. *
  7085. * */
  7086. var addEvent = U.addEvent,
  7087. extend = U.extend,
  7088. pick = U.pick;
  7089. /* eslint-disable no-invalid-this, valid-jsdoc */
  7090. // Attributes that trigger a focus border update
  7091. var svgElementBorderUpdateTriggers = [
  7092. 'x', 'y', 'transform', 'width', 'height', 'r', 'd', 'stroke-width'
  7093. ];
  7094. /**
  7095. * Add hook to destroy focus border if SVG element is destroyed, unless
  7096. * hook already exists.
  7097. * @private
  7098. * @param el Element to add destroy hook to
  7099. */
  7100. function addDestroyFocusBorderHook(el) {
  7101. if (el.focusBorderDestroyHook) {
  7102. return;
  7103. }
  7104. var origDestroy = el.destroy;
  7105. el.destroy = function () {
  7106. var _a,
  7107. _b;
  7108. (_b = (_a = el.focusBorder) === null || _a === void 0 ? void 0 : _a.destroy) === null || _b === void 0 ? void 0 : _b.call(_a);
  7109. return origDestroy.apply(el, arguments);
  7110. };
  7111. el.focusBorderDestroyHook = origDestroy;
  7112. }
  7113. /**
  7114. * Remove hook from SVG element added by addDestroyFocusBorderHook, if
  7115. * existing.
  7116. * @private
  7117. * @param el Element to remove destroy hook from
  7118. */
  7119. function removeDestroyFocusBorderHook(el) {
  7120. if (!el.focusBorderDestroyHook) {
  7121. return;
  7122. }
  7123. el.destroy = el.focusBorderDestroyHook;
  7124. delete el.focusBorderDestroyHook;
  7125. }
  7126. /**
  7127. * Add hooks to update the focus border of an element when the element
  7128. * size/position is updated, unless already added.
  7129. * @private
  7130. * @param el Element to add update hooks to
  7131. * @param updateParams Parameters to pass through to addFocusBorder when updating.
  7132. */
  7133. function addUpdateFocusBorderHooks(el) {
  7134. var updateParams = [];
  7135. for (var _i = 1; _i < arguments.length; _i++) {
  7136. updateParams[_i - 1] = arguments[_i];
  7137. }
  7138. if (el.focusBorderUpdateHooks) {
  7139. return;
  7140. }
  7141. el.focusBorderUpdateHooks = {};
  7142. svgElementBorderUpdateTriggers.forEach(function (trigger) {
  7143. var setterKey = trigger + 'Setter';
  7144. var origSetter = el[setterKey] || el._defaultSetter;
  7145. el.focusBorderUpdateHooks[setterKey] = origSetter;
  7146. el[setterKey] = function () {
  7147. var ret = origSetter.apply(el,
  7148. arguments);
  7149. el.addFocusBorder.apply(el, updateParams);
  7150. return ret;
  7151. };
  7152. });
  7153. }
  7154. /**
  7155. * Remove hooks from SVG element added by addUpdateFocusBorderHooks, if
  7156. * existing.
  7157. * @private
  7158. * @param el Element to remove update hooks from
  7159. */
  7160. function removeUpdateFocusBorderHooks(el) {
  7161. if (!el.focusBorderUpdateHooks) {
  7162. return;
  7163. }
  7164. Object.keys(el.focusBorderUpdateHooks).forEach(function (setterKey) {
  7165. var origSetter = el.focusBorderUpdateHooks[setterKey];
  7166. if (origSetter === el._defaultSetter) {
  7167. delete el[setterKey];
  7168. }
  7169. else {
  7170. el[setterKey] = origSetter;
  7171. }
  7172. });
  7173. delete el.focusBorderUpdateHooks;
  7174. }
  7175. /*
  7176. * Add focus border functionality to SVGElements. Draws a new rect on top of
  7177. * element around its bounding box. This is used by multiple components.
  7178. */
  7179. extend(SVGElement.prototype, {
  7180. /**
  7181. * @private
  7182. * @function Highcharts.SVGElement#addFocusBorder
  7183. *
  7184. * @param {number} margin
  7185. *
  7186. * @param {Highcharts.CSSObject} style
  7187. */
  7188. addFocusBorder: function (margin, style) {
  7189. // Allow updating by just adding new border
  7190. if (this.focusBorder) {
  7191. this.removeFocusBorder();
  7192. }
  7193. // Add the border rect
  7194. var bb = this.getBBox(),
  7195. pad = pick(margin, 3);
  7196. bb.x += this.translateX ? this.translateX : 0;
  7197. bb.y += this.translateY ? this.translateY : 0;
  7198. var borderPosX = bb.x - pad,
  7199. borderPosY = bb.y - pad,
  7200. borderWidth = bb.width + 2 * pad,
  7201. borderHeight = bb.height + 2 * pad;
  7202. // For text elements, apply x and y offset, #11397.
  7203. /**
  7204. * @private
  7205. * @function
  7206. *
  7207. * @param {Highcharts.SVGElement} text
  7208. *
  7209. * @return {TextAnchorCorrectionObject}
  7210. */
  7211. function getTextAnchorCorrection(text) {
  7212. var posXCorrection = 0,
  7213. posYCorrection = 0;
  7214. if (text.attr('text-anchor') === 'middle') {
  7215. posXCorrection = H.isFirefox && text.rotation ? 0.25 : 0.5;
  7216. posYCorrection = H.isFirefox && !text.rotation ? 0.75 : 0.5;
  7217. }
  7218. else if (!text.rotation) {
  7219. posYCorrection = 0.75;
  7220. }
  7221. else {
  7222. posXCorrection = 0.25;
  7223. }
  7224. return {
  7225. x: posXCorrection,
  7226. y: posYCorrection
  7227. };
  7228. }
  7229. var isLabel = this instanceof SVGLabel;
  7230. if (this.element.nodeName === 'text' || isLabel) {
  7231. var isRotated = !!this.rotation,
  7232. correction = !isLabel ? getTextAnchorCorrection(this) :
  7233. {
  7234. x: isRotated ? 1 : 0,
  7235. y: 0
  7236. };
  7237. borderPosX = +this.attr('x') - (bb.width * correction.x) - pad;
  7238. borderPosY = +this.attr('y') - (bb.height * correction.y) - pad;
  7239. if (isLabel && isRotated) {
  7240. var temp = borderWidth;
  7241. borderWidth = borderHeight;
  7242. borderHeight = temp;
  7243. borderPosX = +this.attr('x') - (bb.height * correction.x) - pad;
  7244. borderPosY = +this.attr('y') - (bb.width * correction.y) - pad;
  7245. }
  7246. }
  7247. this.focusBorder = this.renderer.rect(borderPosX, borderPosY, borderWidth, borderHeight, parseInt((style && style.borderRadius || 0).toString(), 10))
  7248. .addClass('highcharts-focus-border')
  7249. .attr({
  7250. zIndex: 99
  7251. })
  7252. .add(this.parentGroup);
  7253. if (!this.renderer.styledMode) {
  7254. this.focusBorder.attr({
  7255. stroke: style && style.stroke,
  7256. 'stroke-width': style && style.strokeWidth
  7257. });
  7258. }
  7259. addUpdateFocusBorderHooks(this, margin, style);
  7260. addDestroyFocusBorderHook(this);
  7261. },
  7262. /**
  7263. * @private
  7264. * @function Highcharts.SVGElement#removeFocusBorder
  7265. */
  7266. removeFocusBorder: function () {
  7267. removeUpdateFocusBorderHooks(this);
  7268. removeDestroyFocusBorderHook(this);
  7269. if (this.focusBorder) {
  7270. this.focusBorder.destroy();
  7271. delete this.focusBorder;
  7272. }
  7273. }
  7274. });
  7275. /**
  7276. * Redraws the focus border on the currently focused element.
  7277. *
  7278. * @private
  7279. * @function Highcharts.Chart#renderFocusBorder
  7280. */
  7281. H.Chart.prototype.renderFocusBorder = function () {
  7282. var focusElement = this.focusElement,
  7283. focusBorderOptions = this.options.accessibility.keyboardNavigation.focusBorder;
  7284. if (focusElement) {
  7285. focusElement.removeFocusBorder();
  7286. if (focusBorderOptions.enabled) {
  7287. focusElement.addFocusBorder(focusBorderOptions.margin, {
  7288. stroke: focusBorderOptions.style.color,
  7289. strokeWidth: focusBorderOptions.style.lineWidth,
  7290. borderRadius: focusBorderOptions.style.borderRadius
  7291. });
  7292. }
  7293. }
  7294. };
  7295. /**
  7296. * Set chart's focus to an SVGElement. Calls focus() on it, and draws the focus
  7297. * border. This is used by multiple components.
  7298. *
  7299. * @private
  7300. * @function Highcharts.Chart#setFocusToElement
  7301. *
  7302. * @param {Highcharts.SVGElement} svgElement
  7303. * Element to draw the border around.
  7304. *
  7305. * @param {SVGDOMElement|HTMLDOMElement} [focusElement]
  7306. * If supplied, it draws the border around svgElement and sets the focus
  7307. * to focusElement.
  7308. */
  7309. H.Chart.prototype.setFocusToElement = function (svgElement, focusElement) {
  7310. var focusBorderOptions = this.options.accessibility.keyboardNavigation.focusBorder,
  7311. browserFocusElement = focusElement || svgElement.element;
  7312. // Set browser focus if possible
  7313. if (browserFocusElement &&
  7314. browserFocusElement.focus) {
  7315. // If there is no focusin-listener, add one to work around Edge issue
  7316. // where Narrator is not reading out points despite calling focus().
  7317. if (!(browserFocusElement.hcEvents &&
  7318. browserFocusElement.hcEvents.focusin)) {
  7319. addEvent(browserFocusElement, 'focusin', function () { });
  7320. }
  7321. browserFocusElement.focus();
  7322. // Hide default focus ring
  7323. if (focusBorderOptions.hideBrowserFocusOutline) {
  7324. browserFocusElement.style.outline = 'none';
  7325. }
  7326. }
  7327. if (this.focusElement) {
  7328. this.focusElement.removeFocusBorder();
  7329. }
  7330. this.focusElement = svgElement;
  7331. this.renderFocusBorder();
  7332. };
  7333. });
  7334. _registerModule(_modules, 'Accessibility/Accessibility.js', [_modules['Accessibility/Utils/ChartUtilities.js'], _modules['Core/Globals.js'], _modules['Accessibility/KeyboardNavigationHandler.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js'], _modules['Accessibility/AccessibilityComponent.js'], _modules['Accessibility/KeyboardNavigation.js'], _modules['Accessibility/Components/LegendComponent.js'], _modules['Accessibility/Components/MenuComponent.js'], _modules['Accessibility/Components/SeriesComponent/SeriesComponent.js'], _modules['Accessibility/Components/ZoomComponent.js'], _modules['Accessibility/Components/RangeSelectorComponent.js'], _modules['Accessibility/Components/InfoRegionsComponent.js'], _modules['Accessibility/Components/ContainerComponent.js'], _modules['Accessibility/HighContrastMode.js'], _modules['Accessibility/HighContrastTheme.js'], _modules['Accessibility/Options/Options.js'], _modules['Accessibility/Options/LangOptions.js'], _modules['Accessibility/Options/DeprecatedOptions.js']], function (ChartUtilities, H, KeyboardNavigationHandler, O, Point, U, AccessibilityComponent, KeyboardNavigation, LegendComponent, MenuComponent, SeriesComponent, ZoomComponent, RangeSelectorComponent, InfoRegionsComponent, ContainerComponent, whcm, highContrastTheme, defaultOptionsA11Y, defaultLangOptions, copyDeprecatedOptions) {
  7335. /* *
  7336. *
  7337. * (c) 2009-2020 Øystein Moseng
  7338. *
  7339. * Accessibility module for Highcharts
  7340. *
  7341. * License: www.highcharts.com/license
  7342. *
  7343. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7344. *
  7345. * */
  7346. var defaultOptions = O.defaultOptions;
  7347. var addEvent = U.addEvent,
  7348. extend = U.extend,
  7349. fireEvent = U.fireEvent,
  7350. merge = U.merge;
  7351. var doc = H.win.document;
  7352. // Add default options
  7353. merge(true, defaultOptions, defaultOptionsA11Y, {
  7354. accessibility: {
  7355. highContrastTheme: highContrastTheme
  7356. },
  7357. lang: defaultLangOptions
  7358. });
  7359. // Expose functionality on Highcharts namespace
  7360. H.A11yChartUtilities = ChartUtilities;
  7361. H.KeyboardNavigationHandler = KeyboardNavigationHandler;
  7362. H.AccessibilityComponent = AccessibilityComponent;
  7363. /* eslint-disable no-invalid-this, valid-jsdoc */
  7364. /**
  7365. * The Accessibility class
  7366. *
  7367. * @private
  7368. * @requires module:modules/accessibility
  7369. *
  7370. * @class
  7371. * @name Highcharts.Accessibility
  7372. *
  7373. * @param {Highcharts.Chart} chart
  7374. * Chart object
  7375. */
  7376. function Accessibility(chart) {
  7377. this.init(chart);
  7378. }
  7379. Accessibility.prototype = {
  7380. /**
  7381. * Initialize the accessibility class
  7382. * @private
  7383. * @param {Highcharts.Chart} chart
  7384. * Chart object
  7385. */
  7386. init: function (chart) {
  7387. this.chart = chart;
  7388. // Abort on old browsers
  7389. if (!doc.addEventListener || !chart.renderer.isSVG) {
  7390. chart.renderTo.setAttribute('aria-hidden', true);
  7391. return;
  7392. }
  7393. // Copy over any deprecated options that are used. We could do this on
  7394. // every update, but it is probably not needed.
  7395. copyDeprecatedOptions(chart);
  7396. this.initComponents();
  7397. this.keyboardNavigation = new KeyboardNavigation(chart, this.components);
  7398. this.update();
  7399. },
  7400. /**
  7401. * @private
  7402. */
  7403. initComponents: function () {
  7404. var chart = this.chart,
  7405. a11yOptions = chart.options.accessibility;
  7406. this.components = {
  7407. container: new ContainerComponent(),
  7408. infoRegions: new InfoRegionsComponent(),
  7409. legend: new LegendComponent(),
  7410. chartMenu: new MenuComponent(),
  7411. rangeSelector: new RangeSelectorComponent(),
  7412. series: new SeriesComponent(),
  7413. zoom: new ZoomComponent()
  7414. };
  7415. if (a11yOptions.customComponents) {
  7416. extend(this.components, a11yOptions.customComponents);
  7417. }
  7418. var components = this.components;
  7419. this.getComponentOrder().forEach(function (componentName) {
  7420. components[componentName].initBase(chart);
  7421. components[componentName].init();
  7422. });
  7423. },
  7424. /**
  7425. * Get order to update components in.
  7426. * @private
  7427. */
  7428. getComponentOrder: function () {
  7429. if (!this.components) {
  7430. return []; // For zombie accessibility object on old browsers
  7431. }
  7432. if (!this.components.series) {
  7433. return Object.keys(this.components);
  7434. }
  7435. var componentsExceptSeries = Object.keys(this.components)
  7436. .filter(function (c) { return c !== 'series'; });
  7437. // Update series first, so that other components can read accessibility
  7438. // info on points.
  7439. return ['series'].concat(componentsExceptSeries);
  7440. },
  7441. /**
  7442. * Update all components.
  7443. */
  7444. update: function () {
  7445. var components = this.components,
  7446. chart = this.chart,
  7447. a11yOptions = chart.options.accessibility;
  7448. fireEvent(chart, 'beforeA11yUpdate');
  7449. // Update the chart type list as this is used by multiple modules
  7450. chart.types = this.getChartTypes();
  7451. // Update markup
  7452. this.getComponentOrder().forEach(function (componentName) {
  7453. components[componentName].onChartUpdate();
  7454. fireEvent(chart, 'afterA11yComponentUpdate', {
  7455. name: componentName,
  7456. component: components[componentName]
  7457. });
  7458. });
  7459. // Update keyboard navigation
  7460. this.keyboardNavigation.update(a11yOptions.keyboardNavigation.order);
  7461. // Handle high contrast mode
  7462. if (!chart.highContrastModeActive && // Only do this once
  7463. whcm.isHighContrastModeActive()) {
  7464. whcm.setHighContrastTheme(chart);
  7465. }
  7466. fireEvent(chart, 'afterA11yUpdate', {
  7467. accessibility: this
  7468. });
  7469. },
  7470. /**
  7471. * Destroy all elements.
  7472. */
  7473. destroy: function () {
  7474. var chart = this.chart || {};
  7475. // Destroy components
  7476. var components = this.components;
  7477. Object.keys(components).forEach(function (componentName) {
  7478. components[componentName].destroy();
  7479. components[componentName].destroyBase();
  7480. });
  7481. // Kill keyboard nav
  7482. if (this.keyboardNavigation) {
  7483. this.keyboardNavigation.destroy();
  7484. }
  7485. // Hide container from screen readers if it exists
  7486. if (chart.renderTo) {
  7487. chart.renderTo.setAttribute('aria-hidden', true);
  7488. }
  7489. // Remove focus border if it exists
  7490. if (chart.focusElement) {
  7491. chart.focusElement.removeFocusBorder();
  7492. }
  7493. },
  7494. /**
  7495. * Return a list of the types of series we have in the chart.
  7496. * @private
  7497. */
  7498. getChartTypes: function () {
  7499. var types = {};
  7500. this.chart.series.forEach(function (series) {
  7501. types[series.type] = 1;
  7502. });
  7503. return Object.keys(types);
  7504. }
  7505. };
  7506. /**
  7507. * @private
  7508. */
  7509. H.Chart.prototype.updateA11yEnabled = function () {
  7510. var a11y = this.accessibility,
  7511. accessibilityOptions = this.options.accessibility;
  7512. if (accessibilityOptions && accessibilityOptions.enabled) {
  7513. if (a11y) {
  7514. a11y.update();
  7515. }
  7516. else {
  7517. this.accessibility = a11y = new Accessibility(this);
  7518. }
  7519. }
  7520. else if (a11y) {
  7521. // Destroy if after update we have a11y and it is disabled
  7522. if (a11y.destroy) {
  7523. a11y.destroy();
  7524. }
  7525. delete this.accessibility;
  7526. }
  7527. else {
  7528. // Just hide container
  7529. this.renderTo.setAttribute('aria-hidden', true);
  7530. }
  7531. };
  7532. // Handle updates to the module and send render updates to components
  7533. addEvent(H.Chart, 'render', function (e) {
  7534. // Update/destroy
  7535. if (this.a11yDirty && this.renderTo) {
  7536. delete this.a11yDirty;
  7537. this.updateA11yEnabled();
  7538. }
  7539. var a11y = this.accessibility;
  7540. if (a11y) {
  7541. a11y.getComponentOrder().forEach(function (componentName) {
  7542. a11y.components[componentName].onChartRender();
  7543. });
  7544. }
  7545. });
  7546. // Update with chart/series/point updates
  7547. addEvent(H.Chart, 'update', function (e) {
  7548. // Merge new options
  7549. var newOptions = e.options.accessibility;
  7550. if (newOptions) {
  7551. // Handle custom component updating specifically
  7552. if (newOptions.customComponents) {
  7553. this.options.accessibility.customComponents =
  7554. newOptions.customComponents;
  7555. delete newOptions.customComponents;
  7556. }
  7557. merge(true, this.options.accessibility, newOptions);
  7558. // Recreate from scratch
  7559. if (this.accessibility && this.accessibility.destroy) {
  7560. this.accessibility.destroy();
  7561. delete this.accessibility;
  7562. }
  7563. }
  7564. // Mark dirty for update
  7565. this.a11yDirty = true;
  7566. });
  7567. // Mark dirty for update
  7568. addEvent(Point, 'update', function () {
  7569. if (this.series.chart.accessibility) {
  7570. this.series.chart.a11yDirty = true;
  7571. }
  7572. });
  7573. ['addSeries', 'init'].forEach(function (event) {
  7574. addEvent(H.Chart, event, function () {
  7575. this.a11yDirty = true;
  7576. });
  7577. });
  7578. ['update', 'updatedData', 'remove'].forEach(function (event) {
  7579. addEvent(H.Series, event, function () {
  7580. if (this.chart.accessibility) {
  7581. this.chart.a11yDirty = true;
  7582. }
  7583. });
  7584. });
  7585. // Direct updates (events happen after render)
  7586. [
  7587. 'afterDrilldown', 'drillupall'
  7588. ].forEach(function (event) {
  7589. addEvent(H.Chart, event, function () {
  7590. if (this.accessibility) {
  7591. this.accessibility.update();
  7592. }
  7593. });
  7594. });
  7595. // Destroy with chart
  7596. addEvent(H.Chart, 'destroy', function () {
  7597. if (this.accessibility) {
  7598. this.accessibility.destroy();
  7599. }
  7600. });
  7601. });
  7602. _registerModule(_modules, 'masters/modules/accessibility.src.js', [], function () {
  7603. });
  7604. }));