accessibility.src.js 288 KB

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