accessibility.src.js 335 KB

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