annotations-advanced.src.js 338 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983
  1. /**
  2. * @license Highcharts JS v9.0.1 (2021-02-16)
  3. *
  4. * Annotations module
  5. *
  6. * (c) 2009-2021 Torstein Honsi
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/modules/annotations-advanced', ['highcharts'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Extensions/Annotations/Mixins/EventEmitterMixin.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32. /* *
  33. *
  34. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  35. *
  36. * */
  37. var addEvent = U.addEvent,
  38. fireEvent = U.fireEvent,
  39. objectEach = U.objectEach,
  40. pick = U.pick,
  41. removeEvent = U.removeEvent;
  42. /* eslint-disable valid-jsdoc */
  43. /**
  44. * It provides methods for:
  45. * - adding and handling DOM events and a drag event,
  46. * - mapping a mouse move event to the distance between two following events.
  47. * The units of the distance are specific to a transformation,
  48. * e.g. for rotation they are radians, for scaling they are scale factors.
  49. *
  50. * @private
  51. * @mixin
  52. * @memberOf Annotation
  53. */
  54. var eventEmitterMixin = {
  55. /**
  56. * Add emitter events.
  57. */
  58. addEvents: function () {
  59. var emitter = this,
  60. addMouseDownEvent = function (element) {
  61. addEvent(element,
  62. H.isTouchDevice ? 'touchstart' : 'mousedown',
  63. function (e) {
  64. emitter.onMouseDown(e);
  65. }, { passive: false });
  66. };
  67. addMouseDownEvent(this.graphic.element);
  68. (emitter.labels || []).forEach(function (label) {
  69. if (label.options.useHTML && label.graphic.text) {
  70. // Mousedown event bound to HTML element (#13070).
  71. addMouseDownEvent(label.graphic.text.element);
  72. }
  73. });
  74. objectEach(emitter.options.events, function (event, type) {
  75. var eventHandler = function (e) {
  76. if (type !== 'click' || !emitter.cancelClick) {
  77. event.call(emitter,
  78. emitter.chart.pointer.normalize(e),
  79. emitter.target);
  80. }
  81. };
  82. if ((emitter.nonDOMEvents || []).indexOf(type) === -1) {
  83. emitter.graphic.on(type, eventHandler);
  84. }
  85. else {
  86. addEvent(emitter, type, eventHandler, { passive: false });
  87. }
  88. });
  89. if (emitter.options.draggable) {
  90. addEvent(emitter, 'drag', emitter.onDrag);
  91. if (!emitter.graphic.renderer.styledMode) {
  92. var cssPointer_1 = {
  93. cursor: {
  94. x: 'ew-resize',
  95. y: 'ns-resize',
  96. xy: 'move'
  97. }[emitter.options.draggable]
  98. };
  99. emitter.graphic.css(cssPointer_1);
  100. (emitter.labels || []).forEach(function (label) {
  101. if (label.options.useHTML && label.graphic.text) {
  102. label.graphic.text.css(cssPointer_1);
  103. }
  104. });
  105. }
  106. }
  107. if (!emitter.isUpdating) {
  108. fireEvent(emitter, 'add');
  109. }
  110. },
  111. /**
  112. * Remove emitter document events.
  113. */
  114. removeDocEvents: function () {
  115. if (this.removeDrag) {
  116. this.removeDrag = this.removeDrag();
  117. }
  118. if (this.removeMouseUp) {
  119. this.removeMouseUp = this.removeMouseUp();
  120. }
  121. },
  122. /**
  123. * Mouse down handler.
  124. */
  125. onMouseDown: function (e) {
  126. var emitter = this,
  127. pointer = emitter.chart.pointer,
  128. prevChartX,
  129. prevChartY;
  130. if (e.preventDefault) {
  131. e.preventDefault();
  132. }
  133. // On right click, do nothing:
  134. if (e.button === 2) {
  135. return;
  136. }
  137. e = pointer.normalize(e);
  138. prevChartX = e.chartX;
  139. prevChartY = e.chartY;
  140. emitter.cancelClick = false;
  141. emitter.chart.hasDraggedAnnotation = true;
  142. emitter.removeDrag = addEvent(H.doc, H.isTouchDevice ? 'touchmove' : 'mousemove', function (e) {
  143. emitter.hasDragged = true;
  144. e = pointer.normalize(e);
  145. e.prevChartX = prevChartX;
  146. e.prevChartY = prevChartY;
  147. fireEvent(emitter, 'drag', e);
  148. prevChartX = e.chartX;
  149. prevChartY = e.chartY;
  150. }, H.isTouchDevice ? { passive: false } : void 0);
  151. emitter.removeMouseUp = addEvent(H.doc, H.isTouchDevice ? 'touchend' : 'mouseup', function (e) {
  152. emitter.cancelClick = emitter.hasDragged;
  153. emitter.hasDragged = false;
  154. emitter.chart.hasDraggedAnnotation = false;
  155. // ControlPoints vs Annotation:
  156. fireEvent(pick(emitter.target, emitter), 'afterUpdate');
  157. emitter.onMouseUp(e);
  158. }, H.isTouchDevice ? { passive: false } : void 0);
  159. },
  160. /**
  161. * Mouse up handler.
  162. */
  163. onMouseUp: function (_e) {
  164. var chart = this.chart,
  165. annotation = this.target || this,
  166. annotationsOptions = chart.options.annotations,
  167. index = chart.annotations.indexOf(annotation);
  168. this.removeDocEvents();
  169. annotationsOptions[index] = annotation.options;
  170. },
  171. /**
  172. * Drag and drop event. All basic annotations should share this
  173. * capability as well as the extended ones.
  174. */
  175. onDrag: function (e) {
  176. if (this.chart.isInsidePlot(e.chartX - this.chart.plotLeft, e.chartY - this.chart.plotTop)) {
  177. var translation = this.mouseMoveToTranslation(e);
  178. if (this.options.draggable === 'x') {
  179. translation.y = 0;
  180. }
  181. if (this.options.draggable === 'y') {
  182. translation.x = 0;
  183. }
  184. if (this.points.length) {
  185. this.translate(translation.x, translation.y);
  186. }
  187. else {
  188. this.shapes.forEach(function (shape) {
  189. shape.translate(translation.x, translation.y);
  190. });
  191. this.labels.forEach(function (label) {
  192. label.translate(translation.x, translation.y);
  193. });
  194. }
  195. this.redraw(false);
  196. }
  197. },
  198. /**
  199. * Map mouse move event to the radians.
  200. */
  201. mouseMoveToRadians: function (e, cx, cy) {
  202. var prevDy = e.prevChartY - cy,
  203. prevDx = e.prevChartX - cx,
  204. dy = e.chartY - cy,
  205. dx = e.chartX - cx,
  206. temp;
  207. if (this.chart.inverted) {
  208. temp = prevDx;
  209. prevDx = prevDy;
  210. prevDy = temp;
  211. temp = dx;
  212. dx = dy;
  213. dy = temp;
  214. }
  215. return Math.atan2(dy, dx) - Math.atan2(prevDy, prevDx);
  216. },
  217. /**
  218. * Map mouse move event to the distance between two following events.
  219. */
  220. mouseMoveToTranslation: function (e) {
  221. var dx = e.chartX - e.prevChartX,
  222. dy = e.chartY - e.prevChartY,
  223. temp;
  224. if (this.chart.inverted) {
  225. temp = dy;
  226. dy = dx;
  227. dx = temp;
  228. }
  229. return {
  230. x: dx,
  231. y: dy
  232. };
  233. },
  234. /**
  235. * Map mouse move to the scale factors.
  236. *
  237. * @param {Object} e event
  238. * @param {number} cx center x
  239. * @param {number} cy center y
  240. **/
  241. mouseMoveToScale: function (e, cx, cy) {
  242. var prevDx = e.prevChartX - cx,
  243. prevDy = e.prevChartY - cy,
  244. dx = e.chartX - cx,
  245. dy = e.chartY - cy,
  246. sx = (dx || 1) / (prevDx || 1),
  247. sy = (dy || 1) / (prevDy || 1),
  248. temp;
  249. if (this.chart.inverted) {
  250. temp = sy;
  251. sy = sx;
  252. sx = temp;
  253. }
  254. return {
  255. x: sx,
  256. y: sy
  257. };
  258. },
  259. /**
  260. * Destroy the event emitter.
  261. */
  262. destroy: function () {
  263. this.removeDocEvents();
  264. removeEvent(this);
  265. this.hcEvents = null;
  266. }
  267. };
  268. return eventEmitterMixin;
  269. });
  270. _registerModule(_modules, 'Extensions/Annotations/ControlPoint.js', [_modules['Core/Utilities.js'], _modules['Extensions/Annotations/Mixins/EventEmitterMixin.js']], function (U, eventEmitterMixin) {
  271. /* *
  272. *
  273. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  274. *
  275. * */
  276. /**
  277. * Callback to modify annotation's possitioner controls.
  278. *
  279. * @callback Highcharts.AnnotationControlPointPositionerFunction
  280. * @param {Highcharts.AnnotationControlPoint} this
  281. * @param {Highcharts.AnnotationControllable} target
  282. * @return {Highcharts.PositionObject}
  283. */
  284. var extend = U.extend,
  285. merge = U.merge,
  286. pick = U.pick;
  287. /* eslint-disable no-invalid-this, valid-jsdoc */
  288. /**
  289. * A control point class which is a connection between controllable
  290. * transform methods and a user actions.
  291. *
  292. * @requires modules/annotations
  293. *
  294. * @class
  295. * @name Highcharts.AnnotationControlPoint
  296. *
  297. * @hideconstructor
  298. *
  299. * @param {Highcharts.Chart} chart
  300. * A chart instance.
  301. *
  302. * @param {Highcharts.AnnotationControllable} target
  303. * A controllable instance which is a target for a control point.
  304. *
  305. * @param {Highcharts.AnnotationControlPointOptionsObject} options
  306. * An options object.
  307. *
  308. * @param {number} [index]
  309. * Point index.
  310. */
  311. var ControlPoint = /** @class */ (function () {
  312. function ControlPoint(chart, target, options, index) {
  313. /**
  314. *
  315. * Properties
  316. *
  317. */
  318. this.addEvents = eventEmitterMixin.addEvents;
  319. this.graphic = void 0;
  320. this.mouseMoveToRadians = eventEmitterMixin.mouseMoveToRadians;
  321. this.mouseMoveToScale = eventEmitterMixin.mouseMoveToScale;
  322. this.mouseMoveToTranslation = eventEmitterMixin.mouseMoveToTranslation;
  323. this.onDrag = eventEmitterMixin.onDrag;
  324. this.onMouseDown = eventEmitterMixin.onMouseDown;
  325. this.onMouseUp = eventEmitterMixin.onMouseUp;
  326. this.removeDocEvents = eventEmitterMixin.removeDocEvents;
  327. /**
  328. *
  329. * Functions
  330. *
  331. */
  332. /**
  333. * List of events for `anntation.options.events` that should not be
  334. * added to `annotation.graphic` but to the `annotation`.
  335. * @private
  336. * @name Highcharts.AnnotationControlPoint#nonDOMEvents
  337. * @type {Array<string>}
  338. */
  339. this.nonDOMEvents = ['drag'];
  340. this.chart = chart;
  341. this.target = target;
  342. this.options = options;
  343. this.index = pick(options.index, index);
  344. }
  345. /**
  346. * Set the visibility of the control point.
  347. *
  348. * @function Highcharts.AnnotationControlPoint#setVisibility
  349. *
  350. * @param {boolean} visible
  351. * Visibility of the control point.
  352. *
  353. * @return {void}
  354. */
  355. ControlPoint.prototype.setVisibility = function (visible) {
  356. this.graphic.attr('visibility', visible ? 'visible' : 'hidden');
  357. this.options.visible = visible;
  358. };
  359. /**
  360. * Render the control point.
  361. * @private
  362. */
  363. ControlPoint.prototype.render = function () {
  364. var chart = this.chart,
  365. options = this.options;
  366. this.graphic = chart.renderer
  367. .symbol(options.symbol, 0, 0, options.width, options.height)
  368. .add(chart.controlPointsGroup)
  369. .css(options.style);
  370. this.setVisibility(options.visible);
  371. // npm test -- --tests "highcharts/annotations-advanced/*"
  372. this.addEvents();
  373. };
  374. /**
  375. * Redraw the control point.
  376. * @private
  377. * @param {boolean} [animation]
  378. */
  379. ControlPoint.prototype.redraw = function (animation) {
  380. this.graphic[animation ? 'animate' : 'attr'](this.options.positioner.call(this, this.target));
  381. };
  382. /**
  383. * Destroy the control point.
  384. * @private
  385. */
  386. ControlPoint.prototype.destroy = function () {
  387. eventEmitterMixin.destroy.call(this);
  388. if (this.graphic) {
  389. this.graphic = this.graphic.destroy();
  390. }
  391. this.chart = null;
  392. this.target = null;
  393. this.options = null;
  394. };
  395. /**
  396. * Update the control point.
  397. *
  398. * @function Highcharts.AnnotationControlPoint#update
  399. *
  400. * @param {Partial<Highcharts.AnnotationControlPointOptionsObject>} userOptions
  401. * New options for the control point.
  402. *
  403. * @return {void}
  404. */
  405. ControlPoint.prototype.update = function (userOptions) {
  406. var chart = this.chart,
  407. target = this.target,
  408. index = this.index,
  409. options = merge(true,
  410. this.options,
  411. userOptions);
  412. this.destroy();
  413. this.constructor(chart, target, options, index);
  414. this.render(chart.controlPointsGroup);
  415. this.redraw();
  416. };
  417. return ControlPoint;
  418. }());
  419. return ControlPoint;
  420. });
  421. _registerModule(_modules, 'Extensions/Annotations/MockPoint.js', [_modules['Core/Series/Series.js'], _modules['Core/Utilities.js'], _modules['Core/Axis/Axis.js']], function (Series, U, Axis) {
  422. /* *
  423. *
  424. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  425. *
  426. * */
  427. /**
  428. * @private
  429. * @interface Highcharts.AnnotationMockLabelOptionsObject
  430. */ /**
  431. * Point instance of the point.
  432. * @name Highcharts.AnnotationMockLabelOptionsObject#point
  433. * @type {Highcharts.AnnotationMockPoint}
  434. */ /**
  435. * X value translated to x axis scale.
  436. * @name Highcharts.AnnotationMockLabelOptionsObject#x
  437. * @type {number|null}
  438. */ /**
  439. * Y value translated to y axis scale.
  440. * @name Highcharts.AnnotationMockLabelOptionsObject#y
  441. * @type {number|null}
  442. */
  443. /**
  444. * A mock series instance imitating a real series from a real point.
  445. * @private
  446. * @interface Highcharts.AnnotationMockSeries
  447. */ /**
  448. * Whether a series is visible.
  449. * @name Highcharts.AnnotationMockSeries#visible
  450. * @type {boolean}
  451. */ /**
  452. * A chart instance.
  453. * @name Highcharts.AnnotationMockSeries#chart
  454. * @type {Highcharts.Chart}
  455. */ /**
  456. * @name Highcharts.AnnotationMockSeries#getPlotBox
  457. * @type {Function}
  458. */
  459. /**
  460. * Indicates if this is a mock point for an annotation.
  461. * @name Highcharts.Point#mock
  462. * @type {boolean|undefined}
  463. */
  464. var defined = U.defined,
  465. extend = U.extend,
  466. fireEvent = U.fireEvent;
  467. /* eslint-disable no-invalid-this, valid-jsdoc */
  468. /**
  469. * A trimmed point object which imitates {@link Highchart.Point} class. It is
  470. * created when there is a need of pointing to some chart's position using axis
  471. * values or pixel values
  472. *
  473. * @requires modules/annotations
  474. *
  475. * @private
  476. * @class
  477. * @name Highcharts.AnnotationMockPoint
  478. *
  479. * @hideconstructor
  480. *
  481. * @param {Highcharts.Chart} chart
  482. * The chart instance.
  483. *
  484. * @param {Highcharts.AnnotationControllable|null} target
  485. * The related controllable.
  486. *
  487. * @param {Highcharts.AnnotationMockPointOptionsObject|Function} options
  488. * The options object.
  489. */
  490. var MockPoint = /** @class */ (function () {
  491. function MockPoint(chart, target, options) {
  492. this.isInside = void 0;
  493. this.plotX = void 0;
  494. this.plotY = void 0;
  495. this.x = void 0;
  496. this.y = void 0;
  497. /* *
  498. *
  499. * Functions
  500. *
  501. * */
  502. /**
  503. * A flag indicating that a point is not the real one.
  504. *
  505. * @type {boolean}
  506. * @default true
  507. */
  508. this.mock = true;
  509. /**
  510. * A mock series instance imitating a real series from a real point.
  511. *
  512. * @name Annotation.AnnotationMockPoint#series
  513. * @type {Highcharts.AnnotationMockSeries}
  514. */
  515. this.series = {
  516. visible: true,
  517. chart: chart,
  518. getPlotBox: Series.prototype.getPlotBox
  519. };
  520. /**
  521. * @name Annotation.AnnotationMockPoint#target
  522. * @type {Highcharts.AnnotationControllable|null}
  523. */
  524. this.target = target || null;
  525. /**
  526. * Options for the mock point.
  527. *
  528. * @name Annotation.AnnotationMockPoint#options
  529. * @type {Highcharts.AnnotationsMockPointOptionsObject}
  530. */
  531. this.options = options;
  532. /**
  533. * If an xAxis is set it represents the point's value in terms of the
  534. * xAxis.
  535. *
  536. * @name Annotation.AnnotationMockPoint#x
  537. * @type {number|undefined}
  538. */
  539. /**
  540. * If an yAxis is set it represents the point's value in terms of the
  541. * yAxis.
  542. *
  543. * @name Annotation.AnnotationMockPoint#y
  544. * @type {number|undefined}
  545. */
  546. /**
  547. * It represents the point's pixel x coordinate relative to its plot
  548. * box.
  549. *
  550. * @name Annotation.AnnotationMockPoint#plotX
  551. * @type {number|undefined}
  552. */
  553. /**
  554. * It represents the point's pixel y position relative to its plot box.
  555. *
  556. * @name Annotation.AnnotationMockPoint#plotY
  557. * @type {number|undefined}
  558. */
  559. /**
  560. * Whether the point is inside the plot box.
  561. *
  562. * @name Annotation.AnnotationMockPoint#isInside
  563. * @type {boolean|undefined}
  564. */
  565. this.applyOptions(this.getOptions());
  566. }
  567. /**
  568. * Create a mock point from a real Highcharts point.
  569. *
  570. * @private
  571. * @static
  572. *
  573. * @param {Highcharts.Point} point
  574. *
  575. * @return {Highcharts.AnnotationMockPoint}
  576. * A mock point instance.
  577. */
  578. MockPoint.fromPoint = function (point) {
  579. return new MockPoint(point.series.chart, null, {
  580. x: point.x,
  581. y: point.y,
  582. xAxis: point.series.xAxis,
  583. yAxis: point.series.yAxis
  584. });
  585. };
  586. /**
  587. * Get the pixel position from the point like object.
  588. *
  589. * @private
  590. * @static
  591. *
  592. * @param {Highcharts.AnnotationPointType} point
  593. *
  594. * @param {boolean} [paneCoordinates]
  595. * whether the pixel position should be relative
  596. *
  597. * @return {Highcharts.PositionObject} pixel position
  598. */
  599. MockPoint.pointToPixels = function (point, paneCoordinates) {
  600. var series = point.series,
  601. chart = series.chart,
  602. x = point.plotX,
  603. y = point.plotY,
  604. plotBox;
  605. if (chart.inverted) {
  606. if (point.mock) {
  607. x = point.plotY;
  608. y = point.plotX;
  609. }
  610. else {
  611. x = chart.plotWidth - point.plotY;
  612. y = chart.plotHeight - point.plotX;
  613. }
  614. }
  615. if (series && !paneCoordinates) {
  616. plotBox = series.getPlotBox();
  617. x += plotBox.translateX;
  618. y += plotBox.translateY;
  619. }
  620. return {
  621. x: x,
  622. y: y
  623. };
  624. };
  625. /**
  626. * Get fresh mock point options from the point like object.
  627. *
  628. * @private
  629. * @static
  630. *
  631. * @param {Highcharts.AnnotationPointType} point
  632. *
  633. * @return {Highcharts.AnnotationMockPointOptionsObject}
  634. * A mock point's options.
  635. */
  636. MockPoint.pointToOptions = function (point) {
  637. return {
  638. x: point.x,
  639. y: point.y,
  640. xAxis: point.series.xAxis,
  641. yAxis: point.series.yAxis
  642. };
  643. };
  644. /**
  645. * Check if the point has dynamic options.
  646. * @private
  647. * @return {boolean}
  648. * A positive flag if the point has dynamic options.
  649. */
  650. MockPoint.prototype.hasDynamicOptions = function () {
  651. return typeof this.options === 'function';
  652. };
  653. /**
  654. * Get the point's options.
  655. * @private
  656. * @return {Highcharts.AnnotationMockPointOptionsObject}
  657. * The mock point's options.
  658. */
  659. MockPoint.prototype.getOptions = function () {
  660. return this.hasDynamicOptions() ?
  661. this.options(this.target) :
  662. this.options;
  663. };
  664. /**
  665. * Apply options for the point.
  666. * @private
  667. * @param {Highcharts.AnnotationMockPointOptionsObject} options
  668. */
  669. MockPoint.prototype.applyOptions = function (options) {
  670. this.command = options.command;
  671. this.setAxis(options, 'x');
  672. this.setAxis(options, 'y');
  673. this.refresh();
  674. };
  675. /**
  676. * Set x or y axis.
  677. * @private
  678. * @param {Highcharts.AnnotationMockPointOptionsObject} options
  679. * @param {string} xOrY
  680. * 'x' or 'y' string literal
  681. */
  682. MockPoint.prototype.setAxis = function (options, xOrY) {
  683. var axisName = (xOrY + 'Axis'),
  684. axisOptions = options[axisName],
  685. chart = this.series.chart;
  686. this.series[axisName] =
  687. axisOptions instanceof Axis ?
  688. axisOptions :
  689. defined(axisOptions) ?
  690. (chart[axisName][axisOptions] ||
  691. chart.get(axisOptions)) :
  692. null;
  693. };
  694. /**
  695. * Transform the mock point to an anchor (relative position on the chart).
  696. * @private
  697. * @return {Array<number>}
  698. * A quadruple of numbers which denotes x, y, width and height of the box
  699. **/
  700. MockPoint.prototype.toAnchor = function () {
  701. var anchor = [this.plotX,
  702. this.plotY, 0, 0];
  703. if (this.series.chart.inverted) {
  704. anchor[0] = this.plotY;
  705. anchor[1] = this.plotX;
  706. }
  707. return anchor;
  708. };
  709. /**
  710. * Returns a label config object - the same as
  711. * Highcharts.Point.prototype.getLabelConfig
  712. * @private
  713. * @return {Highcharts.AnnotationMockLabelOptionsObject} the point's label config
  714. */
  715. MockPoint.prototype.getLabelConfig = function () {
  716. return {
  717. x: this.x,
  718. y: this.y,
  719. point: this
  720. };
  721. };
  722. /**
  723. * Check if the point is inside its pane.
  724. * @private
  725. * @return {boolean} A flag indicating whether the point is inside the pane.
  726. */
  727. MockPoint.prototype.isInsidePlot = function () {
  728. var plotX = this.plotX,
  729. plotY = this.plotY,
  730. xAxis = this.series.xAxis,
  731. yAxis = this.series.yAxis,
  732. e = {
  733. x: plotX,
  734. y: plotY,
  735. isInsidePlot: true
  736. };
  737. if (xAxis) {
  738. e.isInsidePlot = defined(plotX) && plotX >= 0 && plotX <= xAxis.len;
  739. }
  740. if (yAxis) {
  741. e.isInsidePlot =
  742. e.isInsidePlot &&
  743. defined(plotY) &&
  744. plotY >= 0 && plotY <= yAxis.len;
  745. }
  746. fireEvent(this.series.chart, 'afterIsInsidePlot', e);
  747. return e.isInsidePlot;
  748. };
  749. /**
  750. * Refresh point values and coordinates based on its options.
  751. * @private
  752. */
  753. MockPoint.prototype.refresh = function () {
  754. var series = this.series,
  755. xAxis = series.xAxis,
  756. yAxis = series.yAxis,
  757. options = this.getOptions();
  758. if (xAxis) {
  759. this.x = options.x;
  760. this.plotX = xAxis.toPixels(options.x, true);
  761. }
  762. else {
  763. this.x = null;
  764. this.plotX = options.x;
  765. }
  766. if (yAxis) {
  767. this.y = options.y;
  768. this.plotY = yAxis.toPixels(options.y, true);
  769. }
  770. else {
  771. this.y = null;
  772. this.plotY = options.y;
  773. }
  774. this.isInside = this.isInsidePlot();
  775. };
  776. /**
  777. * Translate the point.
  778. *
  779. * @private
  780. *
  781. * @param {number|undefined} cx
  782. * Origin x transformation.
  783. *
  784. * @param {number|undefined} cy
  785. * Origin y transformation.
  786. *
  787. * @param {number} dx
  788. * Translation for x coordinate.
  789. *
  790. * @param {number} dy
  791. * Translation for y coordinate.
  792. **/
  793. MockPoint.prototype.translate = function (_cx, _cy, dx, dy) {
  794. if (!this.hasDynamicOptions()) {
  795. this.plotX += dx;
  796. this.plotY += dy;
  797. this.refreshOptions();
  798. }
  799. };
  800. /**
  801. * Scale the point.
  802. *
  803. * @private
  804. *
  805. * @param {number} cx
  806. * Origin x transformation.
  807. *
  808. * @param {number} cy
  809. * Origin y transformation.
  810. *
  811. * @param {number} sx
  812. * Scale factor x.
  813. *
  814. * @param {number} sy
  815. * Scale factor y.
  816. */
  817. MockPoint.prototype.scale = function (cx, cy, sx, sy) {
  818. if (!this.hasDynamicOptions()) {
  819. var x = this.plotX * sx,
  820. y = this.plotY * sy,
  821. tx = (1 - sx) * cx,
  822. ty = (1 - sy) * cy;
  823. this.plotX = tx + x;
  824. this.plotY = ty + y;
  825. this.refreshOptions();
  826. }
  827. };
  828. /**
  829. * Rotate the point.
  830. * @private
  831. * @param {number} cx origin x rotation
  832. * @param {number} cy origin y rotation
  833. * @param {number} radians
  834. */
  835. MockPoint.prototype.rotate = function (cx, cy, radians) {
  836. if (!this.hasDynamicOptions()) {
  837. var cos = Math.cos(radians),
  838. sin = Math.sin(radians),
  839. x = this.plotX,
  840. y = this.plotY,
  841. tx,
  842. ty;
  843. x -= cx;
  844. y -= cy;
  845. tx = x * cos - y * sin;
  846. ty = x * sin + y * cos;
  847. this.plotX = tx + cx;
  848. this.plotY = ty + cy;
  849. this.refreshOptions();
  850. }
  851. };
  852. /**
  853. * Refresh point options based on its plot coordinates.
  854. * @private
  855. */
  856. MockPoint.prototype.refreshOptions = function () {
  857. var series = this.series,
  858. xAxis = series.xAxis,
  859. yAxis = series.yAxis;
  860. this.x = this.options.x = xAxis ?
  861. this.options.x = xAxis.toValue(this.plotX, true) :
  862. this.plotX;
  863. this.y = this.options.y = yAxis ?
  864. yAxis.toValue(this.plotY, true) :
  865. this.plotY;
  866. };
  867. return MockPoint;
  868. }());
  869. return MockPoint;
  870. });
  871. _registerModule(_modules, 'Extensions/Annotations/Mixins/ControllableMixin.js', [_modules['Extensions/Annotations/ControlPoint.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (ControlPoint, MockPoint, Tooltip, U) {
  872. /* *
  873. *
  874. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  875. *
  876. * */
  877. var isObject = U.isObject,
  878. isString = U.isString,
  879. merge = U.merge,
  880. splat = U.splat;
  881. /**
  882. * An object which denots a controllable's anchor positions - relative and
  883. * absolute.
  884. *
  885. * @private
  886. * @interface Highcharts.AnnotationAnchorObject
  887. */ /**
  888. * Relative to the plot area position
  889. * @name Highcharts.AnnotationAnchorObject#relativePosition
  890. * @type {Highcharts.BBoxObject}
  891. */ /**
  892. * Absolute position
  893. * @name Highcharts.AnnotationAnchorObject#absolutePosition
  894. * @type {Highcharts.BBoxObject}
  895. */
  896. /**
  897. * @interface Highcharts.AnnotationControllable
  898. */ /**
  899. * @name Highcharts.AnnotationControllable#annotation
  900. * @type {Highcharts.Annotation}
  901. */ /**
  902. * @name Highcharts.AnnotationControllable#chart
  903. * @type {Highcharts.Chart}
  904. */ /**
  905. * @name Highcharts.AnnotationControllable#collection
  906. * @type {string}
  907. */ /**
  908. * @private
  909. * @name Highcharts.AnnotationControllable#controlPoints
  910. * @type {Array<Highcharts.AnnotationControlPoint>}
  911. */ /**
  912. * @name Highcharts.AnnotationControllable#points
  913. * @type {Array<Highcharts.Point>}
  914. */
  915. /* eslint-disable no-invalid-this, valid-jsdoc */
  916. /**
  917. * It provides methods for handling points, control points
  918. * and points transformations.
  919. *
  920. * @private
  921. * @mixin
  922. * @name Highcharts.AnnotationControllableMixin
  923. */
  924. var controllableMixin = {
  925. /**
  926. * Init the controllable
  927. */
  928. init: function (annotation,
  929. options,
  930. index) {
  931. this.annotation = annotation;
  932. this.chart = annotation.chart;
  933. this.options = options;
  934. this.points = [];
  935. this.controlPoints = [];
  936. this.index = index;
  937. this.linkPoints();
  938. this.addControlPoints();
  939. },
  940. /**
  941. * Redirect attr usage on the controllable graphic element.
  942. */
  943. attr: function () {
  944. this.graphic.attr.apply(this.graphic, arguments);
  945. },
  946. /**
  947. * Get the controllable's points options.
  948. *
  949. * @return {Array<Highcharts.PointOptionsObject>}
  950. * An array of points' options.
  951. */
  952. getPointsOptions: function () {
  953. var options = this.options;
  954. return (options.points || (options.point && splat(options.point)));
  955. },
  956. /**
  957. * Utility function for mapping item's options
  958. * to element's attribute
  959. *
  960. * @param {Highcharts.AnnotationsLabelsOptions|Highcharts.AnnotationsShapesOptions} options
  961. *
  962. * @return {Highcharts.SVGAttributes}
  963. * Mapped options.
  964. */
  965. attrsFromOptions: function (options) {
  966. var map = this.constructor.attrsMap,
  967. attrs = {},
  968. key,
  969. mappedKey,
  970. styledMode = this.chart.styledMode;
  971. for (key in options) { // eslint-disable-line guard-for-in
  972. mappedKey = map[key];
  973. if (mappedKey &&
  974. (!styledMode ||
  975. ['fill', 'stroke', 'stroke-width']
  976. .indexOf(mappedKey) === -1)) {
  977. attrs[mappedKey] = options[key];
  978. }
  979. }
  980. return attrs;
  981. },
  982. /**
  983. * Returns object which denotes anchor position - relative and absolute.
  984. *
  985. * @param {Highcharts.AnnotationPointType} point
  986. * A point like object.
  987. *
  988. * @return {Highcharts.AnnotationAnchorObject} a controllable anchor
  989. */
  990. anchor: function (point) {
  991. var plotBox = point.series.getPlotBox(),
  992. chart = point.series.chart,
  993. box = point.mock ?
  994. point.toAnchor() :
  995. Tooltip.prototype.getAnchor.call({
  996. chart: point.series.chart
  997. },
  998. point),
  999. anchor = {
  1000. x: box[0] + (this.options.x || 0),
  1001. y: box[1] + (this.options.y || 0),
  1002. height: box[2] || 0,
  1003. width: box[3] || 0
  1004. };
  1005. return {
  1006. relativePosition: anchor,
  1007. absolutePosition: merge(anchor, {
  1008. x: anchor.x + (point.mock ? plotBox.translateX : chart.plotLeft),
  1009. y: anchor.y + (point.mock ? plotBox.translateY : chart.plotTop)
  1010. })
  1011. };
  1012. },
  1013. /**
  1014. * Map point's options to a point-like object.
  1015. *
  1016. * @param {string|Function|Highcharts.AnnotationMockPointOptionsObject|Highcharts.AnnotationPointType} pointOptions
  1017. * Point's options.
  1018. *
  1019. * @param {Highcharts.AnnotationPointType} point
  1020. * A point-like instance.
  1021. *
  1022. * @return {Highcharts.AnnotationPointType|null}
  1023. * if the point is found/set returns this point, otherwise null
  1024. */
  1025. point: function (pointOptions, point) {
  1026. if (pointOptions && pointOptions.series) {
  1027. return pointOptions;
  1028. }
  1029. if (!point || point.series === null) {
  1030. if (isObject(pointOptions)) {
  1031. point = new MockPoint(this.chart, this, pointOptions);
  1032. }
  1033. else if (isString(pointOptions)) {
  1034. point = this.chart.get(pointOptions) || null;
  1035. }
  1036. else if (typeof pointOptions === 'function') {
  1037. var pointConfig = pointOptions.call(point,
  1038. this);
  1039. point = pointConfig.series ?
  1040. pointConfig :
  1041. new MockPoint(this.chart, this, pointOptions);
  1042. }
  1043. }
  1044. return point;
  1045. },
  1046. /**
  1047. * Find point-like objects based on points options.
  1048. *
  1049. * @return {Array<Annotation.PointLike>} an array of point-like objects
  1050. */
  1051. linkPoints: function () {
  1052. var pointsOptions = this.getPointsOptions(),
  1053. points = this.points,
  1054. len = (pointsOptions && pointsOptions.length) || 0,
  1055. i,
  1056. point;
  1057. for (i = 0; i < len; i++) {
  1058. point = this.point(pointsOptions[i], points[i]);
  1059. if (!point) {
  1060. points.length = 0;
  1061. return;
  1062. }
  1063. if (point.mock) {
  1064. point.refresh();
  1065. }
  1066. points[i] = point;
  1067. }
  1068. return points;
  1069. },
  1070. /**
  1071. * Add control points to a controllable.
  1072. */
  1073. addControlPoints: function () {
  1074. var controlPointsOptions = this.options.controlPoints;
  1075. (controlPointsOptions || []).forEach(function (controlPointOptions, i) {
  1076. var options = merge(this.options.controlPointOptions,
  1077. controlPointOptions);
  1078. if (!options.index) {
  1079. options.index = i;
  1080. }
  1081. controlPointsOptions[i] = options;
  1082. this.controlPoints.push(new ControlPoint(this.chart, this, options));
  1083. }, this);
  1084. },
  1085. /**
  1086. * Check if a controllable should be rendered/redrawn.
  1087. *
  1088. * @return {boolean}
  1089. * Whether a controllable should be drawn.
  1090. */
  1091. shouldBeDrawn: function () {
  1092. return Boolean(this.points.length);
  1093. },
  1094. /**
  1095. * Render a controllable.
  1096. */
  1097. render: function (_parentGroup) {
  1098. this.controlPoints.forEach(function (controlPoint) {
  1099. controlPoint.render();
  1100. });
  1101. },
  1102. /**
  1103. * Redraw a controllable.
  1104. *
  1105. * @param {boolean} [animation]
  1106. */
  1107. redraw: function (animation) {
  1108. this.controlPoints.forEach(function (controlPoint) {
  1109. controlPoint.redraw(animation);
  1110. });
  1111. },
  1112. /**
  1113. * Transform a controllable with a specific transformation.
  1114. *
  1115. * @param {string} transformation a transformation name
  1116. * @param {number|null} cx origin x transformation
  1117. * @param {number|null} cy origin y transformation
  1118. * @param {number} p1 param for the transformation
  1119. * @param {number} [p2] param for the transformation
  1120. */
  1121. transform: function (transformation, cx, cy, p1, p2) {
  1122. if (this.chart.inverted) {
  1123. var temp = cx;
  1124. cx = cy;
  1125. cy = temp;
  1126. }
  1127. this.points.forEach(function (point, i) {
  1128. this.transformPoint(transformation, cx, cy, p1, p2, i);
  1129. }, this);
  1130. },
  1131. /**
  1132. * Transform a point with a specific transformation
  1133. * If a transformed point is a real point it is replaced with
  1134. * the mock point.
  1135. *
  1136. * @param {string} transformation a transformation name
  1137. * @param {number|null} cx origin x transformation
  1138. * @param {number|null} cy origin y transformation
  1139. * @param {number} p1 param for the transformation
  1140. * @param {number|undefined} p2 param for the transformation
  1141. * @param {number} i index of the point
  1142. */
  1143. transformPoint: function (transformation, cx, cy, p1, p2, i) {
  1144. var point = this.points[i];
  1145. if (!point.mock) {
  1146. point = this.points[i] = MockPoint.fromPoint(point);
  1147. }
  1148. point[transformation](cx, cy, p1, p2);
  1149. },
  1150. /**
  1151. * Translate a controllable.
  1152. *
  1153. * @param {number} dx translation for x coordinate
  1154. * @param {number} dy translation for y coordinate
  1155. **/
  1156. translate: function (dx, dy) {
  1157. this.transform('translate', null, null, dx, dy);
  1158. },
  1159. /**
  1160. * Translate a specific point within a controllable.
  1161. *
  1162. * @param {number} dx translation for x coordinate
  1163. * @param {number} dy translation for y coordinate
  1164. * @param {number} i index of the point
  1165. **/
  1166. translatePoint: function (dx, dy, i) {
  1167. this.transformPoint('translate', null, null, dx, dy, i);
  1168. },
  1169. /**
  1170. * Translate shape within controllable item.
  1171. * Replaces `controllable.translate` method.
  1172. *
  1173. * @param {number} dx translation for x coordinate
  1174. * @param {number} dy translation for y coordinate
  1175. */
  1176. translateShape: function (dx, dy) {
  1177. var chart = this.annotation.chart,
  1178. // Annotation.options
  1179. shapeOptions = this.annotation.userOptions,
  1180. // Chart.options.annotations
  1181. annotationIndex = chart.annotations.indexOf(this.annotation),
  1182. chartOptions = chart.options.annotations[annotationIndex];
  1183. this.translatePoint(dx, dy, 0);
  1184. // Options stored in:
  1185. // - chart (for exporting)
  1186. // - current config (for redraws)
  1187. chartOptions[this.collection][this.index].point = this.options.point;
  1188. shapeOptions[this.collection][this.index].point = this.options.point;
  1189. },
  1190. /**
  1191. * Rotate a controllable.
  1192. *
  1193. * @param {number} cx origin x rotation
  1194. * @param {number} cy origin y rotation
  1195. * @param {number} radians
  1196. **/
  1197. rotate: function (cx, cy, radians) {
  1198. this.transform('rotate', cx, cy, radians);
  1199. },
  1200. /**
  1201. * Scale a controllable.
  1202. *
  1203. * @param {number} cx origin x rotation
  1204. * @param {number} cy origin y rotation
  1205. * @param {number} sx scale factor x
  1206. * @param {number} sy scale factor y
  1207. */
  1208. scale: function (cx, cy, sx, sy) {
  1209. this.transform('scale', cx, cy, sx, sy);
  1210. },
  1211. /**
  1212. * Set control points' visibility.
  1213. *
  1214. * @param {boolean} visible
  1215. */
  1216. setControlPointsVisibility: function (visible) {
  1217. this.controlPoints.forEach(function (controlPoint) {
  1218. controlPoint.setVisibility(visible);
  1219. });
  1220. },
  1221. /**
  1222. * Destroy a controllable.
  1223. */
  1224. destroy: function () {
  1225. if (this.graphic) {
  1226. this.graphic = this.graphic.destroy();
  1227. }
  1228. if (this.tracker) {
  1229. this.tracker = this.tracker.destroy();
  1230. }
  1231. this.controlPoints.forEach(function (controlPoint) {
  1232. controlPoint.destroy();
  1233. });
  1234. this.chart = null;
  1235. this.points = null;
  1236. this.controlPoints = null;
  1237. this.options = null;
  1238. if (this.annotation) {
  1239. this.annotation = null;
  1240. }
  1241. },
  1242. /**
  1243. * Update a controllable.
  1244. *
  1245. * @param {Object} newOptions
  1246. */
  1247. update: function (newOptions) {
  1248. var annotation = this.annotation,
  1249. options = merge(true,
  1250. this.options,
  1251. newOptions),
  1252. parentGroup = this.graphic.parentGroup;
  1253. this.destroy();
  1254. this.constructor(annotation, options);
  1255. this.render(parentGroup);
  1256. this.redraw();
  1257. }
  1258. };
  1259. return controllableMixin;
  1260. });
  1261. _registerModule(_modules, 'Extensions/Annotations/Mixins/MarkerMixin.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (Chart, SVGRenderer, U) {
  1262. /* *
  1263. *
  1264. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1265. *
  1266. * */
  1267. var addEvent = U.addEvent,
  1268. defined = U.defined,
  1269. merge = U.merge,
  1270. objectEach = U.objectEach,
  1271. uniqueKey = U.uniqueKey;
  1272. /**
  1273. * Options for configuring markers for annotations.
  1274. *
  1275. * An example of the arrow marker:
  1276. * <pre>
  1277. * {
  1278. * arrow: {
  1279. * id: 'arrow',
  1280. * tagName: 'marker',
  1281. * refY: 5,
  1282. * refX: 5,
  1283. * markerWidth: 10,
  1284. * markerHeight: 10,
  1285. * children: [{
  1286. * tagName: 'path',
  1287. * attrs: {
  1288. * d: 'M 0 0 L 10 5 L 0 10 Z',
  1289. * 'stroke-width': 0
  1290. * }
  1291. * }]
  1292. * }
  1293. * }
  1294. * </pre>
  1295. *
  1296. * @sample highcharts/annotations/custom-markers/
  1297. * Define a custom marker for annotations
  1298. *
  1299. * @sample highcharts/css/annotations-markers/
  1300. * Define markers in a styled mode
  1301. *
  1302. * @type {Highcharts.Dictionary<Highcharts.ASTNode>}
  1303. * @since 6.0.0
  1304. * @optionparent defs
  1305. */
  1306. var defaultMarkers = {
  1307. /**
  1308. * @type {Highcharts.ASTNode}
  1309. */
  1310. arrow: {
  1311. tagName: 'marker',
  1312. attributes: {
  1313. display: 'none',
  1314. id: 'arrow',
  1315. refY: 5,
  1316. refX: 9,
  1317. markerWidth: 10,
  1318. markerHeight: 10
  1319. },
  1320. /**
  1321. * @type {Array<Highcharts.DefsOptions>}
  1322. */
  1323. children: [{
  1324. tagName: 'path',
  1325. attributes: {
  1326. d: 'M 0 0 L 10 5 L 0 10 Z',
  1327. 'stroke-width': 0
  1328. }
  1329. }]
  1330. },
  1331. /**
  1332. * @type {Highcharts.ASTNode}
  1333. */
  1334. 'reverse-arrow': {
  1335. tagName: 'marker',
  1336. attributes: {
  1337. display: 'none',
  1338. id: 'reverse-arrow',
  1339. refY: 5,
  1340. refX: 1,
  1341. markerWidth: 10,
  1342. markerHeight: 10
  1343. },
  1344. children: [{
  1345. tagName: 'path',
  1346. attributes: {
  1347. // reverse triangle (used as an arrow)
  1348. d: 'M 0 5 L 10 0 L 10 10 Z',
  1349. 'stroke-width': 0
  1350. }
  1351. }]
  1352. }
  1353. };
  1354. SVGRenderer.prototype.addMarker = function (id, markerOptions) {
  1355. var options = { attributes: { id: id } };
  1356. var attrs = {
  1357. stroke: markerOptions.color || 'none',
  1358. fill: markerOptions.color || 'rgba(0, 0, 0, 0.75)'
  1359. };
  1360. options.children = markerOptions.children.map(function (child) {
  1361. return merge(attrs, child);
  1362. });
  1363. var ast = merge(true, {
  1364. attributes: {
  1365. markerWidth: 20,
  1366. markerHeight: 20,
  1367. refX: 0,
  1368. refY: 0,
  1369. orient: 'auto'
  1370. }
  1371. },
  1372. markerOptions,
  1373. options);
  1374. var marker = this.definition(ast);
  1375. marker.id = id;
  1376. return marker;
  1377. };
  1378. /* eslint-disable no-invalid-this, valid-jsdoc */
  1379. /**
  1380. * @private
  1381. */
  1382. function createMarkerSetter(markerType) {
  1383. return function (value) {
  1384. this.attr(markerType, 'url(#' + value + ')');
  1385. };
  1386. }
  1387. /**
  1388. * @private
  1389. * @mixin
  1390. * @name Highcharts.AnnotaitonMarkerMixin
  1391. */
  1392. var markerMixin = {
  1393. markerEndSetter: createMarkerSetter('marker-end'),
  1394. markerStartSetter: createMarkerSetter('marker-start'),
  1395. /**
  1396. * Set markers.
  1397. * @private
  1398. * @param {Highcharts.AnnotationControllablePath} item
  1399. */
  1400. setItemMarkers: function (item) {
  1401. var itemOptions = item.options,
  1402. chart = item.chart,
  1403. defs = chart.options.defs,
  1404. fill = itemOptions.fill,
  1405. color = defined(fill) && fill !== 'none' ?
  1406. fill :
  1407. itemOptions.stroke,
  1408. setMarker = function (markerType) {
  1409. var _a;
  1410. var markerId = itemOptions[markerType],
  1411. def,
  1412. predefinedMarker,
  1413. key,
  1414. marker;
  1415. if (markerId) {
  1416. for (key in defs) { // eslint-disable-line guard-for-in
  1417. def = defs[key];
  1418. if ((markerId === ((_a = def.attributes) === null || _a === void 0 ? void 0 : _a.id) ||
  1419. // Legacy, for
  1420. // unit-tests/annotations/annotations-shapes
  1421. markerId === def.id) &&
  1422. def.tagName === 'marker') {
  1423. predefinedMarker = def;
  1424. break;
  1425. }
  1426. }
  1427. if (predefinedMarker) {
  1428. marker = item[markerType] = chart.renderer
  1429. .addMarker((itemOptions.id || uniqueKey()) + '-' +
  1430. markerId, merge(predefinedMarker, { color: color }));
  1431. item.attr(markerType, marker.getAttribute('id'));
  1432. }
  1433. }
  1434. };
  1435. ['markerStart', 'markerEnd'].forEach(setMarker);
  1436. }
  1437. };
  1438. addEvent(Chart, 'afterGetContainer', function () {
  1439. this.options.defs = merge(defaultMarkers, this.options.defs || {});
  1440. objectEach(this.options.defs, function (def) {
  1441. var attributes = def.attributes;
  1442. if (def.tagName === 'marker' &&
  1443. attributes &&
  1444. attributes.display !== 'none') {
  1445. this.renderer.addMarker(attributes.id, def);
  1446. }
  1447. }, this);
  1448. });
  1449. return markerMixin;
  1450. });
  1451. _registerModule(_modules, 'Extensions/Annotations/Controllables/ControllablePath.js', [_modules['Extensions/Annotations/Mixins/ControllableMixin.js'], _modules['Core/Globals.js'], _modules['Extensions/Annotations/Mixins/MarkerMixin.js'], _modules['Core/Utilities.js']], function (ControllableMixin, H, MarkerMixin, U) {
  1452. /* *
  1453. *
  1454. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1455. *
  1456. * */
  1457. var extend = U.extend;
  1458. // See TRACKER_FILL in highcharts.src.js
  1459. var TRACKER_FILL = 'rgba(192,192,192,' + (H.svg ? 0.0001 : 0.002) + ')';
  1460. /* eslint-disable no-invalid-this, valid-jsdoc */
  1461. /**
  1462. * A controllable path class.
  1463. *
  1464. * @requires modules/annotations
  1465. *
  1466. * @private
  1467. * @class
  1468. * @name Highcharts.AnnotationControllablePath
  1469. *
  1470. * @param {Highcharts.Annotation}
  1471. * Related annotation.
  1472. *
  1473. * @param {Highcharts.AnnotationsShapeOptions} options
  1474. * A path's options object.
  1475. *
  1476. * @param {number} index
  1477. * Index of the path.
  1478. */
  1479. var ControllablePath = /** @class */ (function () {
  1480. /* *
  1481. *
  1482. * Constructors
  1483. *
  1484. * */
  1485. function ControllablePath(annotation, options, index) {
  1486. /* *
  1487. *
  1488. * Properties
  1489. *
  1490. * */
  1491. this.addControlPoints = ControllableMixin.addControlPoints;
  1492. this.anchor = ControllableMixin.anchor;
  1493. this.attr = ControllableMixin.attr;
  1494. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  1495. this.destroy = ControllableMixin.destroy;
  1496. this.getPointsOptions = ControllableMixin.getPointsOptions;
  1497. this.init = ControllableMixin.init;
  1498. this.linkPoints = ControllableMixin.linkPoints;
  1499. this.point = ControllableMixin.point;
  1500. this.rotate = ControllableMixin.rotate;
  1501. this.scale = ControllableMixin.scale;
  1502. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  1503. this.setMarkers = MarkerMixin.setItemMarkers;
  1504. this.transform = ControllableMixin.transform;
  1505. this.transformPoint = ControllableMixin.transformPoint;
  1506. this.translate = ControllableMixin.translate;
  1507. this.translatePoint = ControllableMixin.translatePoint;
  1508. this.translateShape = ControllableMixin.translateShape;
  1509. this.update = ControllableMixin.update;
  1510. /**
  1511. * @type 'path'
  1512. */
  1513. this.type = 'path';
  1514. this.init(annotation, options, index);
  1515. this.collection = 'shapes';
  1516. }
  1517. /* *
  1518. *
  1519. * Functions
  1520. *
  1521. * */
  1522. /**
  1523. * Map the controllable path to 'd' path attribute.
  1524. *
  1525. * @return {Highcharts.SVGPathArray|null}
  1526. * A path's d attribute.
  1527. */
  1528. ControllablePath.prototype.toD = function () {
  1529. var dOption = this.options.d;
  1530. if (dOption) {
  1531. return typeof dOption === 'function' ?
  1532. dOption.call(this) :
  1533. dOption;
  1534. }
  1535. var points = this.points,
  1536. len = points.length,
  1537. showPath = len,
  1538. point = points[0],
  1539. position = showPath && this.anchor(point).absolutePosition,
  1540. pointIndex = 0,
  1541. command,
  1542. d = [];
  1543. if (position) {
  1544. d.push(['M', position.x, position.y]);
  1545. while (++pointIndex < len && showPath) {
  1546. point = points[pointIndex];
  1547. command = point.command || 'L';
  1548. position = this.anchor(point).absolutePosition;
  1549. if (command === 'M') {
  1550. d.push([command, position.x, position.y]);
  1551. }
  1552. else if (command === 'L') {
  1553. d.push([command, position.x, position.y]);
  1554. }
  1555. else if (command === 'Z') {
  1556. d.push([command]);
  1557. }
  1558. showPath = point.series.visible;
  1559. }
  1560. }
  1561. return showPath ?
  1562. this.chart.renderer.crispLine(d, this.graphic.strokeWidth()) :
  1563. null;
  1564. };
  1565. ControllablePath.prototype.shouldBeDrawn = function () {
  1566. return (ControllableMixin.shouldBeDrawn.call(this) || Boolean(this.options.d));
  1567. };
  1568. ControllablePath.prototype.render = function (parent) {
  1569. var options = this.options,
  1570. attrs = this.attrsFromOptions(options);
  1571. this.graphic = this.annotation.chart.renderer
  1572. .path([['M', 0, 0]])
  1573. .attr(attrs)
  1574. .add(parent);
  1575. if (options.className) {
  1576. this.graphic.addClass(options.className);
  1577. }
  1578. this.tracker = this.annotation.chart.renderer
  1579. .path([['M', 0, 0]])
  1580. .addClass('highcharts-tracker-line')
  1581. .attr({
  1582. zIndex: 2
  1583. })
  1584. .add(parent);
  1585. if (!this.annotation.chart.styledMode) {
  1586. this.tracker.attr({
  1587. 'stroke-linejoin': 'round',
  1588. stroke: TRACKER_FILL,
  1589. fill: TRACKER_FILL,
  1590. 'stroke-width': this.graphic.strokeWidth() +
  1591. options.snap * 2
  1592. });
  1593. }
  1594. ControllableMixin.render.call(this);
  1595. extend(this.graphic, {
  1596. markerStartSetter: MarkerMixin.markerStartSetter,
  1597. markerEndSetter: MarkerMixin.markerEndSetter
  1598. });
  1599. this.setMarkers(this);
  1600. };
  1601. ControllablePath.prototype.redraw = function (animation) {
  1602. var d = this.toD(),
  1603. action = animation ? 'animate' : 'attr';
  1604. if (d) {
  1605. this.graphic[action]({ d: d });
  1606. this.tracker[action]({ d: d });
  1607. }
  1608. else {
  1609. this.graphic.attr({ d: 'M 0 ' + -9e9 });
  1610. this.tracker.attr({ d: 'M 0 ' + -9e9 });
  1611. }
  1612. this.graphic.placed = this.tracker.placed = Boolean(d);
  1613. ControllableMixin.redraw.call(this, animation);
  1614. };
  1615. /* *
  1616. *
  1617. * Static Properties
  1618. *
  1619. * */
  1620. /**
  1621. * A map object which allows to map options attributes to element attributes
  1622. *
  1623. * @name Highcharts.AnnotationControllablePath.attrsMap
  1624. * @type {Highcharts.Dictionary<string>}
  1625. */
  1626. ControllablePath.attrsMap = {
  1627. dashStyle: 'dashstyle',
  1628. strokeWidth: 'stroke-width',
  1629. stroke: 'stroke',
  1630. fill: 'fill',
  1631. zIndex: 'zIndex'
  1632. };
  1633. return ControllablePath;
  1634. }());
  1635. return ControllablePath;
  1636. });
  1637. _registerModule(_modules, 'Extensions/Annotations/Controllables/ControllableRect.js', [_modules['Extensions/Annotations/Mixins/ControllableMixin.js'], _modules['Extensions/Annotations/Controllables/ControllablePath.js'], _modules['Core/Utilities.js']], function (ControllableMixin, ControllablePath, U) {
  1638. /* *
  1639. *
  1640. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1641. *
  1642. * */
  1643. var merge = U.merge;
  1644. /**
  1645. * @typedef {Annotation.ControllablePath.AttrsMap}
  1646. * Annotation.ControllableRect.AttrsMap
  1647. * @property {string} width=width
  1648. * @property {string} height=height
  1649. */
  1650. /* eslint-disable no-invalid-this, valid-jsdoc */
  1651. /**
  1652. * A controllable rect class.
  1653. *
  1654. * @requires modules/annotations
  1655. *
  1656. * @private
  1657. * @class
  1658. * @name Highcharts.AnnotationControllableRect
  1659. *
  1660. * @param {Highcharts.Annotation} annotation
  1661. * An annotation instance.
  1662. *
  1663. * @param {Highcharts.AnnotationsShapeOptions} options
  1664. * A rect's options.
  1665. *
  1666. * @param {number} index
  1667. * Index of the rectangle
  1668. */
  1669. var ControllableRect = /** @class */ (function () {
  1670. /* *
  1671. *
  1672. * Constructors
  1673. *
  1674. * */
  1675. function ControllableRect(annotation, options, index) {
  1676. /* *
  1677. *
  1678. * Properties
  1679. *
  1680. * */
  1681. this.addControlPoints = ControllableMixin.addControlPoints;
  1682. this.anchor = ControllableMixin.anchor;
  1683. this.attr = ControllableMixin.attr;
  1684. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  1685. this.destroy = ControllableMixin.destroy;
  1686. this.getPointsOptions = ControllableMixin.getPointsOptions;
  1687. this.init = ControllableMixin.init;
  1688. this.linkPoints = ControllableMixin.linkPoints;
  1689. this.point = ControllableMixin.point;
  1690. this.rotate = ControllableMixin.rotate;
  1691. this.scale = ControllableMixin.scale;
  1692. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  1693. this.shouldBeDrawn = ControllableMixin.shouldBeDrawn;
  1694. this.transform = ControllableMixin.transform;
  1695. this.transformPoint = ControllableMixin.transformPoint;
  1696. this.translatePoint = ControllableMixin.translatePoint;
  1697. this.translateShape = ControllableMixin.translateShape;
  1698. this.update = ControllableMixin.update;
  1699. /**
  1700. * @type 'rect'
  1701. */
  1702. this.type = 'rect';
  1703. this.translate = ControllableMixin.translateShape;
  1704. this.init(annotation, options, index);
  1705. this.collection = 'shapes';
  1706. }
  1707. /* *
  1708. *
  1709. * Functions
  1710. *
  1711. * */
  1712. ControllableRect.prototype.render = function (parent) {
  1713. var attrs = this.attrsFromOptions(this.options);
  1714. this.graphic = this.annotation.chart.renderer
  1715. .rect(0, -9e9, 0, 0)
  1716. .attr(attrs)
  1717. .add(parent);
  1718. ControllableMixin.render.call(this);
  1719. };
  1720. ControllableRect.prototype.redraw = function (animation) {
  1721. var position = this.anchor(this.points[0]).absolutePosition;
  1722. if (position) {
  1723. this.graphic[animation ? 'animate' : 'attr']({
  1724. x: position.x,
  1725. y: position.y,
  1726. width: this.options.width,
  1727. height: this.options.height
  1728. });
  1729. }
  1730. else {
  1731. this.attr({
  1732. x: 0,
  1733. y: -9e9
  1734. });
  1735. }
  1736. this.graphic.placed = Boolean(position);
  1737. ControllableMixin.redraw.call(this, animation);
  1738. };
  1739. /* *
  1740. *
  1741. * Static Properties
  1742. *
  1743. * */
  1744. /**
  1745. * A map object which allows to map options attributes to element attributes
  1746. *
  1747. * @type {Annotation.ControllableRect.AttrsMap}
  1748. */
  1749. ControllableRect.attrsMap = merge(ControllablePath.attrsMap, {
  1750. width: 'width',
  1751. height: 'height'
  1752. });
  1753. return ControllableRect;
  1754. }());
  1755. return ControllableRect;
  1756. });
  1757. _registerModule(_modules, 'Extensions/Annotations/Controllables/ControllableCircle.js', [_modules['Extensions/Annotations/Mixins/ControllableMixin.js'], _modules['Extensions/Annotations/Controllables/ControllablePath.js'], _modules['Core/Utilities.js']], function (ControllableMixin, ControllablePath, U) {
  1758. /* *
  1759. *
  1760. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1761. *
  1762. * */
  1763. var merge = U.merge;
  1764. /* eslint-disable no-invalid-this, valid-jsdoc */
  1765. /**
  1766. * A controllable circle class.
  1767. *
  1768. * @requires modules/annotations
  1769. *
  1770. * @private
  1771. * @class
  1772. * @name Highcharts.AnnotationControllableCircle
  1773. *
  1774. * @param {Highcharts.Annotation} annotation an annotation instance
  1775. * @param {Highcharts.AnnotationsShapeOptions} options a shape's options
  1776. * @param {number} index of the circle
  1777. */
  1778. var ControllableCircle = /** @class */ (function () {
  1779. /* *
  1780. *
  1781. * Constructors
  1782. *
  1783. * */
  1784. function ControllableCircle(annotation, options, index) {
  1785. /* *
  1786. *
  1787. * Properties
  1788. *
  1789. * */
  1790. this.addControlPoints = ControllableMixin.addControlPoints;
  1791. this.anchor = ControllableMixin.anchor;
  1792. this.attr = ControllableMixin.attr;
  1793. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  1794. this.destroy = ControllableMixin.destroy;
  1795. this.getPointsOptions = ControllableMixin.getPointsOptions;
  1796. this.init = ControllableMixin.init;
  1797. this.linkPoints = ControllableMixin.linkPoints;
  1798. this.point = ControllableMixin.point;
  1799. this.rotate = ControllableMixin.rotate;
  1800. this.scale = ControllableMixin.scale;
  1801. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  1802. this.shouldBeDrawn = ControllableMixin.shouldBeDrawn;
  1803. this.transform = ControllableMixin.transform;
  1804. this.transformPoint = ControllableMixin.transformPoint;
  1805. this.translatePoint = ControllableMixin.translatePoint;
  1806. this.translateShape = ControllableMixin.translateShape;
  1807. this.update = ControllableMixin.update;
  1808. /**
  1809. * @type 'circle'
  1810. */
  1811. this.type = 'circle';
  1812. this.translate = ControllableMixin.translateShape;
  1813. this.init(annotation, options, index);
  1814. this.collection = 'shapes';
  1815. }
  1816. /* *
  1817. *
  1818. * Functions
  1819. *
  1820. * */
  1821. ControllableCircle.prototype.render = function (parent) {
  1822. var attrs = this.attrsFromOptions(this.options);
  1823. this.graphic = this.annotation.chart.renderer
  1824. .circle(0, -9e9, 0)
  1825. .attr(attrs)
  1826. .add(parent);
  1827. ControllableMixin.render.call(this);
  1828. };
  1829. ControllableCircle.prototype.redraw = function (animation) {
  1830. var position = this.anchor(this.points[0]).absolutePosition;
  1831. if (position) {
  1832. this.graphic[animation ? 'animate' : 'attr']({
  1833. x: position.x,
  1834. y: position.y,
  1835. r: this.options.r
  1836. });
  1837. }
  1838. else {
  1839. this.graphic.attr({
  1840. x: 0,
  1841. y: -9e9
  1842. });
  1843. }
  1844. this.graphic.placed = Boolean(position);
  1845. ControllableMixin.redraw.call(this, animation);
  1846. };
  1847. /**
  1848. * Set the radius.
  1849. *
  1850. * @param {number} r a radius to be set
  1851. */
  1852. ControllableCircle.prototype.setRadius = function (r) {
  1853. this.options.r = r;
  1854. };
  1855. /* *
  1856. *
  1857. * Static Properties
  1858. *
  1859. * */
  1860. /**
  1861. * A map object which allows to map options attributes to element
  1862. * attributes.
  1863. *
  1864. * @name Highcharts.AnnotationControllableCircle.attrsMap
  1865. * @type {Highcharts.Dictionary<string>}
  1866. */
  1867. ControllableCircle.attrsMap = merge(ControllablePath.attrsMap, { r: 'r' });
  1868. return ControllableCircle;
  1869. }());
  1870. return ControllableCircle;
  1871. });
  1872. _registerModule(_modules, 'Extensions/Annotations/Controllables/ControllableLabel.js', [_modules['Extensions/Annotations/Mixins/ControllableMixin.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (ControllableMixin, MockPoint, SVGRenderer, Tooltip, U) {
  1873. /* *
  1874. *
  1875. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1876. *
  1877. * */
  1878. var extend = U.extend,
  1879. format = U.format,
  1880. isNumber = U.isNumber,
  1881. pick = U.pick;
  1882. /* eslint-disable no-invalid-this, valid-jsdoc */
  1883. /**
  1884. * A controllable label class.
  1885. *
  1886. * @requires modules/annotations
  1887. *
  1888. * @private
  1889. * @class
  1890. * @name Highcharts.AnnotationControllableLabel
  1891. *
  1892. * @param {Highcharts.Annotation} annotation
  1893. * An annotation instance.
  1894. * @param {Highcharts.AnnotationsLabelOptions} options
  1895. * A label's options.
  1896. * @param {number} index
  1897. * Index of the label.
  1898. */
  1899. var ControllableLabel = /** @class */ (function () {
  1900. /* *
  1901. *
  1902. * Constructors
  1903. *
  1904. * */
  1905. function ControllableLabel(annotation, options, index) {
  1906. /* *
  1907. *
  1908. * Properties
  1909. *
  1910. * */
  1911. this.addControlPoints = ControllableMixin.addControlPoints;
  1912. this.attr = ControllableMixin.attr;
  1913. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  1914. this.destroy = ControllableMixin.destroy;
  1915. this.getPointsOptions = ControllableMixin.getPointsOptions;
  1916. this.init = ControllableMixin.init;
  1917. this.linkPoints = ControllableMixin.linkPoints;
  1918. this.point = ControllableMixin.point;
  1919. this.rotate = ControllableMixin.rotate;
  1920. this.scale = ControllableMixin.scale;
  1921. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  1922. this.shouldBeDrawn = ControllableMixin.shouldBeDrawn;
  1923. this.transform = ControllableMixin.transform;
  1924. this.transformPoint = ControllableMixin.transformPoint;
  1925. this.translateShape = ControllableMixin.translateShape;
  1926. this.update = ControllableMixin.update;
  1927. this.init(annotation, options, index);
  1928. this.collection = 'labels';
  1929. }
  1930. /* *
  1931. *
  1932. * Static Functions
  1933. *
  1934. * */
  1935. /**
  1936. * Returns new aligned position based alignment options and box to align to.
  1937. * It is almost a one-to-one copy from SVGElement.prototype.align
  1938. * except it does not use and mutate an element
  1939. *
  1940. * @param {Highcharts.AnnotationAlignObject} alignOptions
  1941. *
  1942. * @param {Highcharts.BBoxObject} box
  1943. *
  1944. * @return {Highcharts.PositionObject}
  1945. * Aligned position.
  1946. */
  1947. ControllableLabel.alignedPosition = function (alignOptions, box) {
  1948. var align = alignOptions.align,
  1949. vAlign = alignOptions.verticalAlign,
  1950. x = (box.x || 0) + (alignOptions.x || 0),
  1951. y = (box.y || 0) + (alignOptions.y || 0),
  1952. alignFactor,
  1953. vAlignFactor;
  1954. if (align === 'right') {
  1955. alignFactor = 1;
  1956. }
  1957. else if (align === 'center') {
  1958. alignFactor = 2;
  1959. }
  1960. if (alignFactor) {
  1961. x += (box.width - (alignOptions.width || 0)) / alignFactor;
  1962. }
  1963. if (vAlign === 'bottom') {
  1964. vAlignFactor = 1;
  1965. }
  1966. else if (vAlign === 'middle') {
  1967. vAlignFactor = 2;
  1968. }
  1969. if (vAlignFactor) {
  1970. y += (box.height - (alignOptions.height || 0)) / vAlignFactor;
  1971. }
  1972. return {
  1973. x: Math.round(x),
  1974. y: Math.round(y)
  1975. };
  1976. };
  1977. /**
  1978. * Returns new alignment options for a label if the label is outside the
  1979. * plot area. It is almost a one-to-one copy from
  1980. * Series.prototype.justifyDataLabel except it does not mutate the label and
  1981. * it works with absolute instead of relative position.
  1982. */
  1983. ControllableLabel.justifiedOptions = function (chart, label, alignOptions, alignAttr) {
  1984. var align = alignOptions.align,
  1985. verticalAlign = alignOptions.verticalAlign,
  1986. padding = label.box ? 0 : (label.padding || 0),
  1987. bBox = label.getBBox(),
  1988. off,
  1989. //
  1990. options = {
  1991. align: align,
  1992. verticalAlign: verticalAlign,
  1993. x: alignOptions.x,
  1994. y: alignOptions.y,
  1995. width: label.width,
  1996. height: label.height
  1997. },
  1998. //
  1999. x = alignAttr.x - chart.plotLeft,
  2000. y = alignAttr.y - chart.plotTop;
  2001. // Off left
  2002. off = x + padding;
  2003. if (off < 0) {
  2004. if (align === 'right') {
  2005. options.align = 'left';
  2006. }
  2007. else {
  2008. options.x = -off;
  2009. }
  2010. }
  2011. // Off right
  2012. off = x + bBox.width - padding;
  2013. if (off > chart.plotWidth) {
  2014. if (align === 'left') {
  2015. options.align = 'right';
  2016. }
  2017. else {
  2018. options.x = chart.plotWidth - off;
  2019. }
  2020. }
  2021. // Off top
  2022. off = y + padding;
  2023. if (off < 0) {
  2024. if (verticalAlign === 'bottom') {
  2025. options.verticalAlign = 'top';
  2026. }
  2027. else {
  2028. options.y = -off;
  2029. }
  2030. }
  2031. // Off bottom
  2032. off = y + bBox.height - padding;
  2033. if (off > chart.plotHeight) {
  2034. if (verticalAlign === 'top') {
  2035. options.verticalAlign = 'bottom';
  2036. }
  2037. else {
  2038. options.y = chart.plotHeight - off;
  2039. }
  2040. }
  2041. return options;
  2042. };
  2043. /* *
  2044. *
  2045. * Functions
  2046. *
  2047. * */
  2048. /**
  2049. * Translate the point of the label by deltaX and deltaY translations.
  2050. * The point is the label's anchor.
  2051. *
  2052. * @param {number} dx translation for x coordinate
  2053. * @param {number} dy translation for y coordinate
  2054. */
  2055. ControllableLabel.prototype.translatePoint = function (dx, dy) {
  2056. ControllableMixin.translatePoint.call(this, dx, dy, 0);
  2057. };
  2058. /**
  2059. * Translate x and y position relative to the label's anchor.
  2060. *
  2061. * @param {number} dx translation for x coordinate
  2062. * @param {number} dy translation for y coordinate
  2063. */
  2064. ControllableLabel.prototype.translate = function (dx, dy) {
  2065. var chart = this.annotation.chart,
  2066. // Annotation.options
  2067. labelOptions = this.annotation.userOptions,
  2068. // Chart.options.annotations
  2069. annotationIndex = chart.annotations.indexOf(this.annotation),
  2070. chartAnnotations = chart.options.annotations,
  2071. chartOptions = chartAnnotations[annotationIndex],
  2072. temp;
  2073. if (chart.inverted) {
  2074. temp = dx;
  2075. dx = dy;
  2076. dy = temp;
  2077. }
  2078. // Local options:
  2079. this.options.x += dx;
  2080. this.options.y += dy;
  2081. // Options stored in chart:
  2082. chartOptions[this.collection][this.index].x = this.options.x;
  2083. chartOptions[this.collection][this.index].y = this.options.y;
  2084. labelOptions[this.collection][this.index].x = this.options.x;
  2085. labelOptions[this.collection][this.index].y = this.options.y;
  2086. };
  2087. ControllableLabel.prototype.render = function (parent) {
  2088. var options = this.options,
  2089. attrs = this.attrsFromOptions(options),
  2090. style = options.style;
  2091. this.graphic = this.annotation.chart.renderer
  2092. .label('', 0, -9999, // #10055
  2093. options.shape, null, null, options.useHTML, null, 'annotation-label')
  2094. .attr(attrs)
  2095. .add(parent);
  2096. if (!this.annotation.chart.styledMode) {
  2097. if (style.color === 'contrast') {
  2098. style.color = this.annotation.chart.renderer.getContrast(ControllableLabel.shapesWithoutBackground.indexOf(options.shape) > -1 ? '#FFFFFF' : options.backgroundColor);
  2099. }
  2100. this.graphic
  2101. .css(options.style)
  2102. .shadow(options.shadow);
  2103. }
  2104. if (options.className) {
  2105. this.graphic.addClass(options.className);
  2106. }
  2107. this.graphic.labelrank = options.labelrank;
  2108. ControllableMixin.render.call(this);
  2109. };
  2110. ControllableLabel.prototype.redraw = function (animation) {
  2111. var options = this.options,
  2112. text = this.text || options.format || options.text,
  2113. label = this.graphic,
  2114. point = this.points[0],
  2115. anchor,
  2116. attrs;
  2117. label.attr({
  2118. text: text ?
  2119. format(text, point.getLabelConfig(), this.annotation.chart) :
  2120. options.formatter.call(point, this)
  2121. });
  2122. anchor = this.anchor(point);
  2123. attrs = this.position(anchor);
  2124. if (attrs) {
  2125. label.alignAttr = attrs;
  2126. attrs.anchorX = anchor.absolutePosition.x;
  2127. attrs.anchorY = anchor.absolutePosition.y;
  2128. label[animation ? 'animate' : 'attr'](attrs);
  2129. }
  2130. else {
  2131. label.attr({
  2132. x: 0,
  2133. y: -9999 // #10055
  2134. });
  2135. }
  2136. label.placed = !!attrs;
  2137. ControllableMixin.redraw.call(this, animation);
  2138. };
  2139. /**
  2140. * All basic shapes don't support alignTo() method except label.
  2141. * For a controllable label, we need to subtract translation from
  2142. * options.
  2143. */
  2144. ControllableLabel.prototype.anchor = function (_point) {
  2145. var anchor = ControllableMixin.anchor.apply(this,
  2146. arguments),
  2147. x = this.options.x || 0,
  2148. y = this.options.y || 0;
  2149. anchor.absolutePosition.x -= x;
  2150. anchor.absolutePosition.y -= y;
  2151. anchor.relativePosition.x -= x;
  2152. anchor.relativePosition.y -= y;
  2153. return anchor;
  2154. };
  2155. /**
  2156. * Returns the label position relative to its anchor.
  2157. *
  2158. * @param {Highcharts.AnnotationAnchorObject} anchor
  2159. *
  2160. * @return {Highcharts.PositionObject|null}
  2161. */
  2162. ControllableLabel.prototype.position = function (anchor) {
  2163. var item = this.graphic,
  2164. chart = this.annotation.chart,
  2165. point = this.points[0],
  2166. itemOptions = this.options,
  2167. anchorAbsolutePosition = anchor.absolutePosition,
  2168. anchorRelativePosition = anchor.relativePosition,
  2169. itemPosition,
  2170. alignTo,
  2171. itemPosRelativeX,
  2172. itemPosRelativeY,
  2173. showItem = point.series.visible &&
  2174. MockPoint.prototype.isInsidePlot.call(point);
  2175. if (showItem) {
  2176. if (itemOptions.distance) {
  2177. itemPosition = Tooltip.prototype.getPosition.call({
  2178. chart: chart,
  2179. distance: pick(itemOptions.distance, 16)
  2180. }, item.width, item.height, {
  2181. plotX: anchorRelativePosition.x,
  2182. plotY: anchorRelativePosition.y,
  2183. negative: point.negative,
  2184. ttBelow: point.ttBelow,
  2185. h: (anchorRelativePosition.height || anchorRelativePosition.width)
  2186. });
  2187. }
  2188. else if (itemOptions.positioner) {
  2189. itemPosition = itemOptions.positioner.call(this);
  2190. }
  2191. else {
  2192. alignTo = {
  2193. x: anchorAbsolutePosition.x,
  2194. y: anchorAbsolutePosition.y,
  2195. width: 0,
  2196. height: 0
  2197. };
  2198. itemPosition = ControllableLabel.alignedPosition(extend(itemOptions, {
  2199. width: item.width,
  2200. height: item.height
  2201. }), alignTo);
  2202. if (this.options.overflow === 'justify') {
  2203. itemPosition = ControllableLabel.alignedPosition(ControllableLabel.justifiedOptions(chart, item, itemOptions, itemPosition), alignTo);
  2204. }
  2205. }
  2206. if (itemOptions.crop) {
  2207. itemPosRelativeX = itemPosition.x - chart.plotLeft;
  2208. itemPosRelativeY = itemPosition.y - chart.plotTop;
  2209. showItem =
  2210. chart.isInsidePlot(itemPosRelativeX, itemPosRelativeY) &&
  2211. chart.isInsidePlot(itemPosRelativeX + item.width, itemPosRelativeY + item.height);
  2212. }
  2213. }
  2214. return showItem ? itemPosition : null;
  2215. };
  2216. /* *
  2217. *
  2218. * Static Properties
  2219. *
  2220. * */
  2221. /**
  2222. * A map object which allows to map options attributes to element attributes
  2223. *
  2224. * @type {Highcharts.Dictionary<string>}
  2225. */
  2226. ControllableLabel.attrsMap = {
  2227. backgroundColor: 'fill',
  2228. borderColor: 'stroke',
  2229. borderWidth: 'stroke-width',
  2230. zIndex: 'zIndex',
  2231. borderRadius: 'r',
  2232. padding: 'padding'
  2233. };
  2234. /**
  2235. * Shapes which do not have background - the object is used for proper
  2236. * setting of the contrast color.
  2237. *
  2238. * @type {Array<string>}
  2239. */
  2240. ControllableLabel.shapesWithoutBackground = ['connector'];
  2241. return ControllableLabel;
  2242. }());
  2243. /* ********************************************************************** */
  2244. /**
  2245. * General symbol definition for labels with connector
  2246. * @private
  2247. */
  2248. SVGRenderer.prototype.symbols.connector = function (x, y, w, h, options) {
  2249. var anchorX = options && options.anchorX,
  2250. anchorY = options && options.anchorY,
  2251. path,
  2252. yOffset,
  2253. lateral = w / 2;
  2254. if (isNumber(anchorX) && isNumber(anchorY)) {
  2255. path = [['M', anchorX, anchorY]];
  2256. // Prefer 45 deg connectors
  2257. yOffset = y - anchorY;
  2258. if (yOffset < 0) {
  2259. yOffset = -h - yOffset;
  2260. }
  2261. if (yOffset < w) {
  2262. lateral = anchorX < x + (w / 2) ? yOffset : w - yOffset;
  2263. }
  2264. // Anchor below label
  2265. if (anchorY > y + h) {
  2266. path.push(['L', x + lateral, y + h]);
  2267. // Anchor above label
  2268. }
  2269. else if (anchorY < y) {
  2270. path.push(['L', x + lateral, y]);
  2271. // Anchor left of label
  2272. }
  2273. else if (anchorX < x) {
  2274. path.push(['L', x, y + h / 2]);
  2275. // Anchor right of label
  2276. }
  2277. else if (anchorX > x + w) {
  2278. path.push(['L', x + w, y + h / 2]);
  2279. }
  2280. }
  2281. return path || [];
  2282. };
  2283. return ControllableLabel;
  2284. });
  2285. _registerModule(_modules, 'Extensions/Annotations/Controllables/ControllableImage.js', [_modules['Extensions/Annotations/Controllables/ControllableLabel.js'], _modules['Extensions/Annotations/Mixins/ControllableMixin.js']], function (ControllableLabel, ControllableMixin) {
  2286. /* *
  2287. *
  2288. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2289. *
  2290. * */
  2291. /* eslint-disable no-invalid-this, valid-jsdoc */
  2292. /**
  2293. * A controllable image class.
  2294. *
  2295. * @requires modules/annotations
  2296. *
  2297. * @private
  2298. * @class
  2299. * @name Highcharts.AnnotationControllableImage
  2300. *
  2301. * @param {Highcharts.Annotation} annotation
  2302. * An annotation instance.
  2303. *
  2304. * @param {Highcharts.AnnotationsShapeOptions} options
  2305. * A controllable's options.
  2306. *
  2307. * @param {number} index
  2308. * Index of the image.
  2309. */
  2310. var ControllableImage = /** @class */ (function () {
  2311. /* *
  2312. *
  2313. * Constructors
  2314. *
  2315. * */
  2316. function ControllableImage(annotation, options, index) {
  2317. /* *
  2318. *
  2319. * Properties
  2320. *
  2321. * */
  2322. this.addControlPoints = ControllableMixin.addControlPoints;
  2323. this.anchor = ControllableMixin.anchor;
  2324. this.attr = ControllableMixin.attr;
  2325. this.attrsFromOptions = ControllableMixin.attrsFromOptions;
  2326. this.destroy = ControllableMixin.destroy;
  2327. this.getPointsOptions = ControllableMixin.getPointsOptions;
  2328. this.init = ControllableMixin.init;
  2329. this.linkPoints = ControllableMixin.linkPoints;
  2330. this.point = ControllableMixin.point;
  2331. this.rotate = ControllableMixin.rotate;
  2332. this.scale = ControllableMixin.scale;
  2333. this.setControlPointsVisibility = ControllableMixin.setControlPointsVisibility;
  2334. this.shouldBeDrawn = ControllableMixin.shouldBeDrawn;
  2335. this.transform = ControllableMixin.transform;
  2336. this.transformPoint = ControllableMixin.transformPoint;
  2337. this.translatePoint = ControllableMixin.translatePoint;
  2338. this.translateShape = ControllableMixin.translateShape;
  2339. this.update = ControllableMixin.update;
  2340. /**
  2341. * @type 'image'
  2342. */
  2343. this.type = 'image';
  2344. this.translate = ControllableMixin.translateShape;
  2345. this.init(annotation, options, index);
  2346. this.collection = 'shapes';
  2347. }
  2348. ControllableImage.prototype.render = function (parent) {
  2349. var attrs = this.attrsFromOptions(this.options),
  2350. options = this.options;
  2351. this.graphic = this.annotation.chart.renderer
  2352. .image(options.src, 0, -9e9, options.width, options.height)
  2353. .attr(attrs)
  2354. .add(parent);
  2355. this.graphic.width = options.width;
  2356. this.graphic.height = options.height;
  2357. ControllableMixin.render.call(this);
  2358. };
  2359. ControllableImage.prototype.redraw = function (animation) {
  2360. var anchor = this.anchor(this.points[0]),
  2361. position = ControllableLabel.prototype.position.call(this,
  2362. anchor);
  2363. if (position) {
  2364. this.graphic[animation ? 'animate' : 'attr']({
  2365. x: position.x,
  2366. y: position.y
  2367. });
  2368. }
  2369. else {
  2370. this.graphic.attr({
  2371. x: 0,
  2372. y: -9e9
  2373. });
  2374. }
  2375. this.graphic.placed = Boolean(position);
  2376. ControllableMixin.redraw.call(this, animation);
  2377. };
  2378. /* *
  2379. *
  2380. * Static Properties
  2381. *
  2382. * */
  2383. /**
  2384. * A map object which allows to map options attributes to element attributes
  2385. *
  2386. * @name Highcharts.AnnotationControllableImage.attrsMap
  2387. * @type {Highcharts.Dictionary<string>}
  2388. */
  2389. ControllableImage.attrsMap = {
  2390. width: 'width',
  2391. height: 'height',
  2392. zIndex: 'zIndex'
  2393. };
  2394. return ControllableImage;
  2395. }());
  2396. return ControllableImage;
  2397. });
  2398. _registerModule(_modules, 'Extensions/Annotations/Annotations.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Chart/Chart.js'], _modules['Extensions/Annotations/Mixins/ControllableMixin.js'], _modules['Extensions/Annotations/Controllables/ControllableRect.js'], _modules['Extensions/Annotations/Controllables/ControllableCircle.js'], _modules['Extensions/Annotations/Controllables/ControllablePath.js'], _modules['Extensions/Annotations/Controllables/ControllableImage.js'], _modules['Extensions/Annotations/Controllables/ControllableLabel.js'], _modules['Extensions/Annotations/ControlPoint.js'], _modules['Extensions/Annotations/Mixins/EventEmitterMixin.js'], _modules['Core/Globals.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (A, Chart, ControllableMixin, ControllableRect, ControllableCircle, ControllablePath, ControllableImage, ControllableLabel, ControlPoint, EventEmitterMixin, H, MockPoint, Pointer, U) {
  2399. /* *
  2400. *
  2401. * (c) 2009-2021 Highsoft, Black Label
  2402. *
  2403. * License: www.highcharts.com/license
  2404. *
  2405. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2406. *
  2407. * */
  2408. var getDeferredAnimation = A.getDeferredAnimation;
  2409. var chartProto = Chart.prototype;
  2410. var addEvent = U.addEvent,
  2411. defined = U.defined,
  2412. destroyObjectProperties = U.destroyObjectProperties,
  2413. erase = U.erase,
  2414. extend = U.extend,
  2415. find = U.find,
  2416. fireEvent = U.fireEvent,
  2417. merge = U.merge,
  2418. pick = U.pick,
  2419. splat = U.splat,
  2420. wrap = U.wrap;
  2421. /* *********************************************************************
  2422. *
  2423. * ANNOTATION
  2424. *
  2425. ******************************************************************** */
  2426. /**
  2427. * Possible directions for draggable annotations. An empty string (`''`)
  2428. * makes the annotation undraggable.
  2429. *
  2430. * @typedef {''|'x'|'xy'|'y'} Highcharts.AnnotationDraggableValue
  2431. */
  2432. /**
  2433. * @private
  2434. * @typedef {
  2435. * Highcharts.AnnotationControllableCircle|
  2436. * Highcharts.AnnotationControllableImage|
  2437. * Highcharts.AnnotationControllablePath|
  2438. * Highcharts.AnnotationControllableRect
  2439. * }
  2440. * Highcharts.AnnotationShapeType
  2441. * @requires modules/annotations
  2442. */
  2443. /**
  2444. * @private
  2445. * @typedef {
  2446. * Highcharts.AnnotationControllableLabel
  2447. * }
  2448. * Highcharts.AnnotationLabelType
  2449. * @requires modules/annotations
  2450. */
  2451. /**
  2452. * A point-like object, a mock point or a point used in series.
  2453. * @private
  2454. * @typedef {Highcharts.AnnotationMockPoint|Highcharts.Point} Highcharts.AnnotationPointType
  2455. * @requires modules/annotations
  2456. */
  2457. /* eslint-disable no-invalid-this, valid-jsdoc */
  2458. /**
  2459. * An annotation class which serves as a container for items like labels or
  2460. * shapes. Created items are positioned on the chart either by linking them to
  2461. * existing points or created mock points
  2462. *
  2463. * @class
  2464. * @name Highcharts.Annotation
  2465. *
  2466. * @param {Highcharts.Chart} chart a chart instance
  2467. * @param {Highcharts.AnnotationsOptions} userOptions the options object
  2468. */
  2469. var Annotation = /** @class */ (function () {
  2470. /* *
  2471. *
  2472. * Constructors
  2473. *
  2474. * */
  2475. function Annotation(chart, userOptions) {
  2476. /* *
  2477. *
  2478. * Properties
  2479. *
  2480. * */
  2481. this.annotation = void 0;
  2482. this.coll = 'annotations';
  2483. this.collection = void 0;
  2484. this.animationConfig = void 0;
  2485. this.graphic = void 0;
  2486. this.group = void 0;
  2487. this.labelCollector = void 0;
  2488. this.labelsGroup = void 0;
  2489. this.shapesGroup = void 0;
  2490. var labelsAndShapes;
  2491. /**
  2492. * The chart that the annotation belongs to.
  2493. *
  2494. * @type {Highcharts.Chart}
  2495. */
  2496. this.chart = chart;
  2497. /**
  2498. * The array of points which defines the annotation.
  2499. *
  2500. * @type {Array<Highcharts.Point>}
  2501. */
  2502. this.points = [];
  2503. /**
  2504. * The array of control points.
  2505. *
  2506. * @private
  2507. * @name Highcharts.Annotation#controlPoints
  2508. * @type {Array<Annotation.ControlPoint>}
  2509. */
  2510. this.controlPoints = [];
  2511. this.coll = 'annotations';
  2512. /**
  2513. * The array of labels which belong to the annotation.
  2514. *
  2515. * @private
  2516. * @name Highcharts.Annotation#labels
  2517. * @type {Array<Highcharts.AnnotationLabelType>}
  2518. */
  2519. this.labels = [];
  2520. /**
  2521. * The array of shapes which belong to the annotation.
  2522. *
  2523. * @private
  2524. * @name Highcharts.Annotation#shapes
  2525. * @type {Array<Highcharts.AnnotationShapeType>}
  2526. */
  2527. this.shapes = [];
  2528. /**
  2529. * The options for the annotations.
  2530. *
  2531. * @name Highcharts.Annotation#options
  2532. * @type {Highcharts.AnnotationsOptions}
  2533. */
  2534. this.options = merge(this.defaultOptions, userOptions);
  2535. /**
  2536. * The user options for the annotations.
  2537. *
  2538. * @name Highcharts.Annotation#userOptions
  2539. * @type {Highcharts.AnnotationsOptions}
  2540. */
  2541. this.userOptions = userOptions;
  2542. // Handle labels and shapes - those are arrays
  2543. // Merging does not work with arrays (stores reference)
  2544. labelsAndShapes = this.getLabelsAndShapesOptions(this.options, userOptions);
  2545. this.options.labels = labelsAndShapes.labels;
  2546. this.options.shapes = labelsAndShapes.shapes;
  2547. /**
  2548. * The callback that reports to the overlapping-labels module which
  2549. * labels it should account for.
  2550. * @private
  2551. * @name Highcharts.Annotation#labelCollector
  2552. * @type {Function}
  2553. */
  2554. /**
  2555. * The group svg element.
  2556. *
  2557. * @name Highcharts.Annotation#group
  2558. * @type {Highcharts.SVGElement}
  2559. */
  2560. /**
  2561. * The group svg element of the annotation's shapes.
  2562. *
  2563. * @name Highcharts.Annotation#shapesGroup
  2564. * @type {Highcharts.SVGElement}
  2565. */
  2566. /**
  2567. * The group svg element of the annotation's labels.
  2568. *
  2569. * @name Highcharts.Annotation#labelsGroup
  2570. * @type {Highcharts.SVGElement}
  2571. */
  2572. this.init(chart, this.options);
  2573. }
  2574. /**
  2575. * Initialize the annotation.
  2576. * @private
  2577. */
  2578. Annotation.prototype.init = function () {
  2579. var chart = this.chart,
  2580. animOptions = this.options.animation;
  2581. this.linkPoints();
  2582. this.addControlPoints();
  2583. this.addShapes();
  2584. this.addLabels();
  2585. this.setLabelCollector();
  2586. this.animationConfig = getDeferredAnimation(chart, animOptions);
  2587. };
  2588. Annotation.prototype.getLabelsAndShapesOptions = function (baseOptions, newOptions) {
  2589. var mergedOptions = {};
  2590. ['labels', 'shapes'].forEach(function (name) {
  2591. if (baseOptions[name]) {
  2592. mergedOptions[name] = splat(newOptions[name]).map(function (basicOptions, i) {
  2593. return merge(baseOptions[name][i], basicOptions);
  2594. });
  2595. }
  2596. });
  2597. return mergedOptions;
  2598. };
  2599. Annotation.prototype.addShapes = function () {
  2600. (this.options.shapes || []).forEach(function (shapeOptions, i) {
  2601. var shape = this.initShape(shapeOptions,
  2602. i);
  2603. merge(true, this.options.shapes[i], shape.options);
  2604. }, this);
  2605. };
  2606. Annotation.prototype.addLabels = function () {
  2607. (this.options.labels || []).forEach(function (labelsOptions, i) {
  2608. var labels = this.initLabel(labelsOptions,
  2609. i);
  2610. merge(true, this.options.labels[i], labels.options);
  2611. }, this);
  2612. };
  2613. Annotation.prototype.addClipPaths = function () {
  2614. this.setClipAxes();
  2615. if (this.clipXAxis && this.clipYAxis) {
  2616. this.clipRect = this.chart.renderer.clipRect(this.getClipBox());
  2617. }
  2618. };
  2619. Annotation.prototype.setClipAxes = function () {
  2620. var xAxes = this.chart.xAxis,
  2621. yAxes = this.chart.yAxis,
  2622. linkedAxes = (this.options.labels || [])
  2623. .concat(this.options.shapes || [])
  2624. .reduce(function (axes,
  2625. labelOrShape) {
  2626. return [
  2627. xAxes[labelOrShape &&
  2628. labelOrShape.point &&
  2629. labelOrShape.point.xAxis] || axes[0],
  2630. yAxes[labelOrShape &&
  2631. labelOrShape.point &&
  2632. labelOrShape.point.yAxis] || axes[1]
  2633. ];
  2634. }, []);
  2635. this.clipXAxis = linkedAxes[0];
  2636. this.clipYAxis = linkedAxes[1];
  2637. };
  2638. Annotation.prototype.getClipBox = function () {
  2639. if (this.clipXAxis && this.clipYAxis) {
  2640. return {
  2641. x: this.clipXAxis.left,
  2642. y: this.clipYAxis.top,
  2643. width: this.clipXAxis.width,
  2644. height: this.clipYAxis.height
  2645. };
  2646. }
  2647. };
  2648. Annotation.prototype.setLabelCollector = function () {
  2649. var annotation = this;
  2650. annotation.labelCollector = function () {
  2651. return annotation.labels.reduce(function (labels, label) {
  2652. if (!label.options.allowOverlap) {
  2653. labels.push(label.graphic);
  2654. }
  2655. return labels;
  2656. }, []);
  2657. };
  2658. annotation.chart.labelCollectors.push(annotation.labelCollector);
  2659. };
  2660. /**
  2661. * Set an annotation options.
  2662. * @private
  2663. * @param {Highcharts.AnnotationsOptions} - user options for an annotation
  2664. */
  2665. Annotation.prototype.setOptions = function (userOptions) {
  2666. this.options = merge(this.defaultOptions, userOptions);
  2667. };
  2668. Annotation.prototype.redraw = function (animation) {
  2669. this.linkPoints();
  2670. if (!this.graphic) {
  2671. this.render();
  2672. }
  2673. if (this.clipRect) {
  2674. this.clipRect.animate(this.getClipBox());
  2675. }
  2676. this.redrawItems(this.shapes, animation);
  2677. this.redrawItems(this.labels, animation);
  2678. ControllableMixin.redraw.call(this, animation);
  2679. };
  2680. /**
  2681. * @private
  2682. * @param {Array<Highcharts.AnnotationControllable>} items
  2683. * @param {boolean} [animation]
  2684. */
  2685. Annotation.prototype.redrawItems = function (items, animation) {
  2686. var i = items.length;
  2687. // needs a backward loop
  2688. // labels/shapes array might be modified
  2689. // due to destruction of the item
  2690. while (i--) {
  2691. this.redrawItem(items[i], animation);
  2692. }
  2693. };
  2694. /**
  2695. * @private
  2696. * @param {Array<Highcharts.AnnotationControllable>} items
  2697. */
  2698. Annotation.prototype.renderItems = function (items) {
  2699. var i = items.length;
  2700. while (i--) {
  2701. this.renderItem(items[i]);
  2702. }
  2703. };
  2704. Annotation.prototype.render = function () {
  2705. var renderer = this.chart.renderer;
  2706. this.graphic = renderer
  2707. .g('annotation')
  2708. .attr({
  2709. opacity: 0,
  2710. zIndex: this.options.zIndex,
  2711. visibility: this.options.visible ?
  2712. 'visible' :
  2713. 'hidden'
  2714. })
  2715. .add();
  2716. this.shapesGroup = renderer
  2717. .g('annotation-shapes')
  2718. .add(this.graphic)
  2719. .clip(this.chart.plotBoxClip);
  2720. this.labelsGroup = renderer
  2721. .g('annotation-labels')
  2722. .attr({
  2723. // hideOverlappingLabels requires translation
  2724. translateX: 0,
  2725. translateY: 0
  2726. })
  2727. .add(this.graphic);
  2728. this.addClipPaths();
  2729. if (this.clipRect) {
  2730. this.graphic.clip(this.clipRect);
  2731. }
  2732. // Render shapes and labels before adding events (#13070).
  2733. this.renderItems(this.shapes);
  2734. this.renderItems(this.labels);
  2735. this.addEvents();
  2736. ControllableMixin.render.call(this);
  2737. };
  2738. /**
  2739. * Set the annotation's visibility.
  2740. * @private
  2741. * @param {boolean} [visible]
  2742. * Whether to show or hide an annotation. If the param is omitted, the
  2743. * annotation's visibility is toggled.
  2744. */
  2745. Annotation.prototype.setVisibility = function (visible) {
  2746. var options = this.options,
  2747. visibility = pick(visible, !options.visible);
  2748. this.graphic.attr('visibility', visibility ? 'visible' : 'hidden');
  2749. if (!visibility) {
  2750. this.setControlPointsVisibility(false);
  2751. }
  2752. options.visible = visibility;
  2753. };
  2754. Annotation.prototype.setControlPointsVisibility = function (visible) {
  2755. var setItemControlPointsVisibility = function (item) {
  2756. item.setControlPointsVisibility(visible);
  2757. };
  2758. ControllableMixin.setControlPointsVisibility.call(this, visible);
  2759. this.shapes.forEach(setItemControlPointsVisibility);
  2760. this.labels.forEach(setItemControlPointsVisibility);
  2761. };
  2762. /**
  2763. * Destroy the annotation. This function does not touch the chart
  2764. * that the annotation belongs to (all annotations are kept in
  2765. * the chart.annotations array) - it is recommended to use
  2766. * {@link Highcharts.Chart#removeAnnotation} instead.
  2767. * @private
  2768. */
  2769. Annotation.prototype.destroy = function () {
  2770. var chart = this.chart,
  2771. destroyItem = function (item) {
  2772. item.destroy();
  2773. };
  2774. this.labels.forEach(destroyItem);
  2775. this.shapes.forEach(destroyItem);
  2776. this.clipXAxis = null;
  2777. this.clipYAxis = null;
  2778. erase(chart.labelCollectors, this.labelCollector);
  2779. EventEmitterMixin.destroy.call(this);
  2780. ControllableMixin.destroy.call(this);
  2781. destroyObjectProperties(this, chart);
  2782. };
  2783. /**
  2784. * See {@link Highcharts.Chart#removeAnnotation}.
  2785. * @private
  2786. */
  2787. Annotation.prototype.remove = function () {
  2788. // Let chart.update() remove annoations on demand
  2789. return this.chart.removeAnnotation(this);
  2790. };
  2791. /**
  2792. * Updates an annotation.
  2793. *
  2794. * @function Highcharts.Annotation#update
  2795. *
  2796. * @param {Partial<Highcharts.AnnotationsOptions>} userOptions
  2797. * New user options for the annotation.
  2798. *
  2799. * @return {void}
  2800. */
  2801. Annotation.prototype.update = function (userOptions, redraw) {
  2802. var chart = this.chart,
  2803. labelsAndShapes = this.getLabelsAndShapesOptions(this.userOptions,
  2804. userOptions),
  2805. userOptionsIndex = chart.annotations.indexOf(this),
  2806. options = merge(true,
  2807. this.userOptions,
  2808. userOptions);
  2809. options.labels = labelsAndShapes.labels;
  2810. options.shapes = labelsAndShapes.shapes;
  2811. this.destroy();
  2812. this.constructor(chart, options);
  2813. // Update options in chart options, used in exporting (#9767):
  2814. chart.options.annotations[userOptionsIndex] = options;
  2815. this.isUpdating = true;
  2816. if (pick(redraw, true)) {
  2817. chart.redraw();
  2818. }
  2819. fireEvent(this, 'afterUpdate');
  2820. this.isUpdating = false;
  2821. };
  2822. /* *************************************************************
  2823. * ITEM SECTION
  2824. * Contains methods for handling a single item in an annotation
  2825. **************************************************************** */
  2826. /**
  2827. * Initialisation of a single shape
  2828. * @private
  2829. * @param {Object} shapeOptions - a confg object for a single shape
  2830. */
  2831. Annotation.prototype.initShape = function (shapeOptions, index) {
  2832. var options = merge(this.options.shapeOptions, {
  2833. controlPointOptions: this.options.controlPointOptions
  2834. },
  2835. shapeOptions),
  2836. shape = new Annotation.shapesMap[options.type](this,
  2837. options,
  2838. index);
  2839. shape.itemType = 'shape';
  2840. this.shapes.push(shape);
  2841. return shape;
  2842. };
  2843. /**
  2844. * Initialisation of a single label
  2845. * @private
  2846. */
  2847. Annotation.prototype.initLabel = function (labelOptions, index) {
  2848. var options = merge(this.options.labelOptions, {
  2849. controlPointOptions: this.options.controlPointOptions
  2850. },
  2851. labelOptions),
  2852. label = new ControllableLabel(this,
  2853. options,
  2854. index);
  2855. label.itemType = 'label';
  2856. this.labels.push(label);
  2857. return label;
  2858. };
  2859. /**
  2860. * Redraw a single item.
  2861. * @private
  2862. * @param {Annotation.Label|Annotation.Shape} item
  2863. * @param {boolean} [animation]
  2864. */
  2865. Annotation.prototype.redrawItem = function (item, animation) {
  2866. item.linkPoints();
  2867. if (!item.shouldBeDrawn()) {
  2868. this.destroyItem(item);
  2869. }
  2870. else {
  2871. if (!item.graphic) {
  2872. this.renderItem(item);
  2873. }
  2874. item.redraw(pick(animation, true) && item.graphic.placed);
  2875. if (item.points.length) {
  2876. this.adjustVisibility(item);
  2877. }
  2878. }
  2879. };
  2880. /**
  2881. * Hide or show annotaiton attached to points.
  2882. * @private
  2883. * @param {Annotation.Label|Annotation.Shape} item
  2884. */
  2885. Annotation.prototype.adjustVisibility = function (item) {
  2886. var hasVisiblePoints = false,
  2887. label = item.graphic;
  2888. item.points.forEach(function (point) {
  2889. if (point.series.visible !== false &&
  2890. point.visible !== false) {
  2891. hasVisiblePoints = true;
  2892. }
  2893. });
  2894. if (!hasVisiblePoints) {
  2895. label.hide();
  2896. }
  2897. else if (label.visibility === 'hidden') {
  2898. label.show();
  2899. }
  2900. };
  2901. /**
  2902. * Destroy a single item.
  2903. * @private
  2904. * @param {Annotation.Label|Annotation.Shape} item
  2905. */
  2906. Annotation.prototype.destroyItem = function (item) {
  2907. // erase from shapes or labels array
  2908. erase(this[item.itemType + 's'], item);
  2909. item.destroy();
  2910. };
  2911. /**
  2912. * @private
  2913. */
  2914. Annotation.prototype.renderItem = function (item) {
  2915. item.render(item.itemType === 'label' ?
  2916. this.labelsGroup :
  2917. this.shapesGroup);
  2918. };
  2919. /**
  2920. * @private
  2921. */
  2922. Annotation.ControlPoint = ControlPoint;
  2923. /**
  2924. * @private
  2925. */
  2926. Annotation.MockPoint = MockPoint;
  2927. /**
  2928. * An object uses for mapping between a shape type and a constructor.
  2929. * To add a new shape type extend this object with type name as a key
  2930. * and a constructor as its value.
  2931. */
  2932. Annotation.shapesMap = {
  2933. 'rect': ControllableRect,
  2934. 'circle': ControllableCircle,
  2935. 'path': ControllablePath,
  2936. 'image': ControllableImage
  2937. };
  2938. /**
  2939. * @private
  2940. */
  2941. Annotation.types = {};
  2942. return Annotation;
  2943. }());
  2944. merge(true, Annotation.prototype, ControllableMixin, EventEmitterMixin,
  2945. // restore original Annotation implementation after mixin overwrite
  2946. merge(Annotation.prototype,
  2947. /** @lends Highcharts.Annotation# */
  2948. {
  2949. /**
  2950. * List of events for `annotation.options.events` that should not be
  2951. * added to `annotation.graphic` but to the `annotation`.
  2952. *
  2953. * @private
  2954. * @type {Array<string>}
  2955. */
  2956. nonDOMEvents: ['add', 'afterUpdate', 'drag', 'remove'],
  2957. /**
  2958. * A basic type of an annotation. It allows to add custom labels
  2959. * or shapes. The items can be tied to points, axis coordinates
  2960. * or chart pixel coordinates.
  2961. *
  2962. * @sample highcharts/annotations/basic/
  2963. * Basic annotations
  2964. * @sample highcharts/demo/annotations/
  2965. * Advanced annotations
  2966. * @sample highcharts/css/annotations
  2967. * Styled mode
  2968. * @sample highcharts/annotations-advanced/controllable
  2969. * Controllable items
  2970. * @sample {highstock} stock/annotations/fibonacci-retracements
  2971. * Custom annotation, Fibonacci retracement
  2972. *
  2973. * @type {Array<*>}
  2974. * @since 6.0.0
  2975. * @requires modules/annotations
  2976. * @optionparent annotations
  2977. *
  2978. * @private
  2979. */
  2980. defaultOptions: {
  2981. /**
  2982. * Sets an ID for an annotation. Can be user later when
  2983. * removing an annotation in [Chart#removeAnnotation(id)](
  2984. * /class-reference/Highcharts.Chart#removeAnnotation) method.
  2985. *
  2986. * @type {number|string}
  2987. * @apioption annotations.id
  2988. */
  2989. /**
  2990. * Whether the annotation is visible.
  2991. *
  2992. * @sample highcharts/annotations/visible/
  2993. * Set annotation visibility
  2994. */
  2995. visible: true,
  2996. /**
  2997. * Enable or disable the initial animation when a series is
  2998. * displayed for the `annotation`. The animation can also be set
  2999. * as a configuration object. Please note that this option only
  3000. * applies to the initial animation.
  3001. * For other animations, see [chart.animation](#chart.animation)
  3002. * and the animation parameter under the API methods.
  3003. * The following properties are supported:
  3004. *
  3005. * - `defer`: The animation delay time in milliseconds.
  3006. *
  3007. * @sample {highcharts} highcharts/annotations/defer/
  3008. * Animation defer settings
  3009. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  3010. * @since 8.2.0
  3011. * @apioption annotations.animation
  3012. */
  3013. animation: {},
  3014. /**
  3015. * The animation delay time in milliseconds.
  3016. * Set to `0` renders annotation immediately.
  3017. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  3018. *
  3019. * @type {number}
  3020. * @since 8.2.0
  3021. * @apioption annotations.animation.defer
  3022. */
  3023. /**
  3024. * Allow an annotation to be draggable by a user. Possible
  3025. * values are `'x'`, `'xy'`, `'y'` and `''` (disabled).
  3026. *
  3027. * @sample highcharts/annotations/draggable/
  3028. * Annotations draggable: 'xy'
  3029. *
  3030. * @type {Highcharts.AnnotationDraggableValue}
  3031. */
  3032. draggable: 'xy',
  3033. /**
  3034. * Options for annotation's labels. Each label inherits options
  3035. * from the labelOptions object. An option from the labelOptions
  3036. * can be overwritten by config for a specific label.
  3037. *
  3038. * @requires modules/annotations
  3039. */
  3040. labelOptions: {
  3041. /**
  3042. * The alignment of the annotation's label. If right,
  3043. * the right side of the label should be touching the point.
  3044. *
  3045. * @sample highcharts/annotations/label-position/
  3046. * Set labels position
  3047. *
  3048. * @type {Highcharts.AlignValue}
  3049. */
  3050. align: 'center',
  3051. /**
  3052. * Whether to allow the annotation's labels to overlap.
  3053. * To make the labels less sensitive for overlapping,
  3054. * the can be set to 0.
  3055. *
  3056. * @sample highcharts/annotations/tooltip-like/
  3057. * Hide overlapping labels
  3058. */
  3059. allowOverlap: false,
  3060. /**
  3061. * The background color or gradient for the annotation's
  3062. * label.
  3063. *
  3064. * @sample highcharts/annotations/label-presentation/
  3065. * Set labels graphic options
  3066. *
  3067. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3068. */
  3069. backgroundColor: 'rgba(0, 0, 0, 0.75)',
  3070. /**
  3071. * The border color for the annotation's label.
  3072. *
  3073. * @sample highcharts/annotations/label-presentation/
  3074. * Set labels graphic options
  3075. *
  3076. * @type {Highcharts.ColorString}
  3077. */
  3078. borderColor: 'black',
  3079. /**
  3080. * The border radius in pixels for the annotaiton's label.
  3081. *
  3082. * @sample highcharts/annotations/label-presentation/
  3083. * Set labels graphic options
  3084. */
  3085. borderRadius: 3,
  3086. /**
  3087. * The border width in pixels for the annotation's label
  3088. *
  3089. * @sample highcharts/annotations/label-presentation/
  3090. * Set labels graphic options
  3091. */
  3092. borderWidth: 1,
  3093. /**
  3094. * A class name for styling by CSS.
  3095. *
  3096. * @sample highcharts/css/annotations
  3097. * Styled mode annotations
  3098. *
  3099. * @since 6.0.5
  3100. */
  3101. className: '',
  3102. /**
  3103. * Whether to hide the annotation's label
  3104. * that is outside the plot area.
  3105. *
  3106. * @sample highcharts/annotations/label-crop-overflow/
  3107. * Crop or justify labels
  3108. */
  3109. crop: false,
  3110. /**
  3111. * The label's pixel distance from the point.
  3112. *
  3113. * @sample highcharts/annotations/label-position/
  3114. * Set labels position
  3115. *
  3116. * @type {number}
  3117. * @apioption annotations.labelOptions.distance
  3118. */
  3119. /**
  3120. * A
  3121. * [format](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  3122. * string for the data label.
  3123. *
  3124. * @see [plotOptions.series.dataLabels.format](plotOptions.series.dataLabels.format.html)
  3125. *
  3126. * @sample highcharts/annotations/label-text/
  3127. * Set labels text
  3128. *
  3129. * @type {string}
  3130. * @apioption annotations.labelOptions.format
  3131. */
  3132. /**
  3133. * Alias for the format option.
  3134. *
  3135. * @see [format](annotations.labelOptions.format.html)
  3136. *
  3137. * @sample highcharts/annotations/label-text/
  3138. * Set labels text
  3139. *
  3140. * @type {string}
  3141. * @apioption annotations.labelOptions.text
  3142. */
  3143. /**
  3144. * Callback JavaScript function to format the annotation's
  3145. * label. Note that if a `format` or `text` are defined,
  3146. * the format or text take precedence and the formatter is
  3147. * ignored. `This` refers to a point object.
  3148. *
  3149. * @sample highcharts/annotations/label-text/
  3150. * Set labels text
  3151. *
  3152. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  3153. * @default function () { return defined(this.y) ? this.y : 'Annotation label'; }
  3154. */
  3155. formatter: function () {
  3156. return defined(this.y) ? this.y : 'Annotation label';
  3157. },
  3158. /**
  3159. * Whether the annotation is visible in the exported data
  3160. * table.
  3161. *
  3162. * @sample highcharts/annotations/include-in-data-export/
  3163. * Do not include in the data export
  3164. *
  3165. * @since 8.2.0
  3166. * @requires modules/export-data
  3167. */
  3168. includeInDataExport: true,
  3169. /**
  3170. * How to handle the annotation's label that flow outside
  3171. * the plot area. The justify option aligns the label inside
  3172. * the plot area.
  3173. *
  3174. * @sample highcharts/annotations/label-crop-overflow/
  3175. * Crop or justify labels
  3176. *
  3177. * @validvalue ["allow", "justify"]
  3178. */
  3179. overflow: 'justify',
  3180. /**
  3181. * When either the borderWidth or the backgroundColor is
  3182. * set, this is the padding within the box.
  3183. *
  3184. * @sample highcharts/annotations/label-presentation/
  3185. * Set labels graphic options
  3186. */
  3187. padding: 5,
  3188. /**
  3189. * The shadow of the box. The shadow can be an object
  3190. * configuration containing `color`, `offsetX`, `offsetY`,
  3191. * `opacity` and `width`.
  3192. *
  3193. * @sample highcharts/annotations/label-presentation/
  3194. * Set labels graphic options
  3195. *
  3196. * @type {boolean|Highcharts.ShadowOptionsObject}
  3197. */
  3198. shadow: false,
  3199. /**
  3200. * The name of a symbol to use for the border around the
  3201. * label. Symbols are predefined functions on the Renderer
  3202. * object.
  3203. *
  3204. * @sample highcharts/annotations/shapes/
  3205. * Available shapes for labels
  3206. */
  3207. shape: 'callout',
  3208. /**
  3209. * Styles for the annotation's label.
  3210. *
  3211. * @see [plotOptions.series.dataLabels.style](plotOptions.series.dataLabels.style.html)
  3212. *
  3213. * @sample highcharts/annotations/label-presentation/
  3214. * Set labels graphic options
  3215. *
  3216. * @type {Highcharts.CSSObject}
  3217. */
  3218. style: {
  3219. /** @ignore */
  3220. fontSize: '11px',
  3221. /** @ignore */
  3222. fontWeight: 'normal',
  3223. /** @ignore */
  3224. color: 'contrast'
  3225. },
  3226. /**
  3227. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  3228. * to render the annotation's label.
  3229. */
  3230. useHTML: false,
  3231. /**
  3232. * The vertical alignment of the annotation's label.
  3233. *
  3234. * @sample highcharts/annotations/label-position/
  3235. * Set labels position
  3236. *
  3237. * @type {Highcharts.VerticalAlignValue}
  3238. */
  3239. verticalAlign: 'bottom',
  3240. /**
  3241. * The x position offset of the label relative to the point.
  3242. * Note that if a `distance` is defined, the distance takes
  3243. * precedence over `x` and `y` options.
  3244. *
  3245. * @sample highcharts/annotations/label-position/
  3246. * Set labels position
  3247. */
  3248. x: 0,
  3249. /**
  3250. * The y position offset of the label relative to the point.
  3251. * Note that if a `distance` is defined, the distance takes
  3252. * precedence over `x` and `y` options.
  3253. *
  3254. * @sample highcharts/annotations/label-position/
  3255. * Set labels position
  3256. */
  3257. y: -16
  3258. },
  3259. /**
  3260. * An array of labels for the annotation. For options that apply
  3261. * to multiple labels, they can be added to the
  3262. * [labelOptions](annotations.labelOptions.html).
  3263. *
  3264. * @type {Array<*>}
  3265. * @extends annotations.labelOptions
  3266. * @apioption annotations.labels
  3267. */
  3268. /**
  3269. * This option defines the point to which the label will be
  3270. * connected. It can be either the point which exists in the
  3271. * series - it is referenced by the point's id - or a new point
  3272. * with defined x, y properties and optionally axes.
  3273. *
  3274. * @sample highcharts/annotations/mock-point/
  3275. * Attach annotation to a mock point
  3276. *
  3277. * @declare Highcharts.AnnotationMockPointOptionsObject
  3278. * @type {string|*}
  3279. * @requires modules/annotations
  3280. * @apioption annotations.labels.point
  3281. */
  3282. /**
  3283. * The x position of the point. Units can be either in axis
  3284. * or chart pixel coordinates.
  3285. *
  3286. * @type {number}
  3287. * @apioption annotations.labels.point.x
  3288. */
  3289. /**
  3290. * The y position of the point. Units can be either in axis
  3291. * or chart pixel coordinates.
  3292. *
  3293. * @type {number}
  3294. * @apioption annotations.labels.point.y
  3295. */
  3296. /**
  3297. * This number defines which xAxis the point is connected to.
  3298. * It refers to either the axis id or the index of the axis in
  3299. * the xAxis array. If the option is not configured or the axis
  3300. * is not found the point's x coordinate refers to the chart
  3301. * pixels.
  3302. *
  3303. * @type {number|string|null}
  3304. * @apioption annotations.labels.point.xAxis
  3305. */
  3306. /**
  3307. * This number defines which yAxis the point is connected to.
  3308. * It refers to either the axis id or the index of the axis in
  3309. * the yAxis array. If the option is not configured or the axis
  3310. * is not found the point's y coordinate refers to the chart
  3311. * pixels.
  3312. *
  3313. * @type {number|string|null}
  3314. * @apioption annotations.labels.point.yAxis
  3315. */
  3316. /**
  3317. * An array of shapes for the annotation. For options that apply
  3318. * to multiple shapes, then can be added to the
  3319. * [shapeOptions](annotations.shapeOptions.html).
  3320. *
  3321. * @type {Array<*>}
  3322. * @extends annotations.shapeOptions
  3323. * @apioption annotations.shapes
  3324. */
  3325. /**
  3326. * This option defines the point to which the shape will be
  3327. * connected. It can be either the point which exists in the
  3328. * series - it is referenced by the point's id - or a new point
  3329. * with defined x, y properties and optionally axes.
  3330. *
  3331. * @declare Highcharts.AnnotationMockPointOptionsObject
  3332. * @type {string|Highcharts.AnnotationMockPointOptionsObject}
  3333. * @extends annotations.labels.point
  3334. * @apioption annotations.shapes.point
  3335. */
  3336. /**
  3337. * An array of points for the shape. This option is available
  3338. * for shapes which can use multiple points such as path. A
  3339. * point can be either a point object or a point's id.
  3340. *
  3341. * @see [annotations.shapes.point](annotations.shapes.point.html)
  3342. *
  3343. * @declare Highcharts.AnnotationMockPointOptionsObject
  3344. * @type {Array<string|*>}
  3345. * @extends annotations.labels.point
  3346. * @apioption annotations.shapes.points
  3347. */
  3348. /**
  3349. * The URL for an image to use as the annotation shape. Note,
  3350. * type has to be set to `'image'`.
  3351. *
  3352. * @see [annotations.shapes.type](annotations.shapes.type)
  3353. * @sample highcharts/annotations/shape-src/
  3354. * Define a marker image url for annotations
  3355. *
  3356. * @type {string}
  3357. * @apioption annotations.shapes.src
  3358. */
  3359. /**
  3360. * Id of the marker which will be drawn at the final vertex of
  3361. * the path. Custom markers can be defined in defs property.
  3362. *
  3363. * @see [defs.markers](defs.markers.html)
  3364. *
  3365. * @sample highcharts/annotations/custom-markers/
  3366. * Define a custom marker for annotations
  3367. *
  3368. * @type {string}
  3369. * @apioption annotations.shapes.markerEnd
  3370. */
  3371. /**
  3372. * Id of the marker which will be drawn at the first vertex of
  3373. * the path. Custom markers can be defined in defs property.
  3374. *
  3375. * @see [defs.markers](defs.markers.html)
  3376. *
  3377. * @sample {highcharts} highcharts/annotations/custom-markers/
  3378. * Define a custom marker for annotations
  3379. *
  3380. * @type {string}
  3381. * @apioption annotations.shapes.markerStart
  3382. */
  3383. /**
  3384. * Options for annotation's shapes. Each shape inherits options
  3385. * from the shapeOptions object. An option from the shapeOptions
  3386. * can be overwritten by config for a specific shape.
  3387. *
  3388. * @requires modules/annotations
  3389. */
  3390. shapeOptions: {
  3391. /**
  3392. * The width of the shape.
  3393. *
  3394. * @sample highcharts/annotations/shape/
  3395. * Basic shape annotation
  3396. *
  3397. * @type {number}
  3398. * @apioption annotations.shapeOptions.width
  3399. **/
  3400. /**
  3401. * The height of the shape.
  3402. *
  3403. * @sample highcharts/annotations/shape/
  3404. * Basic shape annotation
  3405. *
  3406. * @type {number}
  3407. * @apioption annotations.shapeOptions.height
  3408. */
  3409. /**
  3410. * The type of the shape, e.g. circle or rectangle.
  3411. *
  3412. * @sample highcharts/annotations/shape/
  3413. * Basic shape annotation
  3414. *
  3415. * @type {string}
  3416. * @default rect
  3417. * @apioption annotations.shapeOptions.type
  3418. */
  3419. /**
  3420. * The URL for an image to use as the annotation shape.
  3421. * Note, type has to be set to `'image'`.
  3422. *
  3423. * @see [annotations.shapeOptions.type](annotations.shapeOptions.type)
  3424. * @sample highcharts/annotations/shape-src/
  3425. * Define a marker image url for annotations
  3426. *
  3427. * @type {string}
  3428. * @apioption annotations.shapeOptions.src
  3429. */
  3430. /**
  3431. * Name of the dash style to use for the shape's stroke.
  3432. *
  3433. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  3434. * Possible values demonstrated
  3435. *
  3436. * @type {Highcharts.DashStyleValue}
  3437. * @apioption annotations.shapeOptions.dashStyle
  3438. */
  3439. /**
  3440. * The color of the shape's stroke.
  3441. *
  3442. * @sample highcharts/annotations/shape/
  3443. * Basic shape annotation
  3444. *
  3445. * @type {Highcharts.ColorString}
  3446. */
  3447. stroke: 'rgba(0, 0, 0, 0.75)',
  3448. /**
  3449. * The pixel stroke width of the shape.
  3450. *
  3451. * @sample highcharts/annotations/shape/
  3452. * Basic shape annotation
  3453. */
  3454. strokeWidth: 1,
  3455. /**
  3456. * The color of the shape's fill.
  3457. *
  3458. * @sample highcharts/annotations/shape/
  3459. * Basic shape annotation
  3460. *
  3461. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3462. */
  3463. fill: 'rgba(0, 0, 0, 0.75)',
  3464. /**
  3465. * The radius of the shape.
  3466. *
  3467. * @sample highcharts/annotations/shape/
  3468. * Basic shape annotation
  3469. */
  3470. r: 0,
  3471. /**
  3472. * Defines additional snapping area around an annotation
  3473. * making this annotation to focus. Defined in pixels.
  3474. */
  3475. snap: 2
  3476. },
  3477. /**
  3478. * Options for annotation's control points. Each control point
  3479. * inherits options from controlPointOptions object.
  3480. * Options from the controlPointOptions can be overwritten
  3481. * by options in a specific control point.
  3482. *
  3483. * @declare Highcharts.AnnotationControlPointOptionsObject
  3484. * @requires modules/annotations
  3485. * @apioption annotations.controlPointOptions
  3486. */
  3487. controlPointOptions: {
  3488. /**
  3489. * @type {Highcharts.AnnotationControlPointPositionerFunction}
  3490. * @apioption annotations.controlPointOptions.positioner
  3491. */
  3492. symbol: 'circle',
  3493. width: 10,
  3494. height: 10,
  3495. style: {
  3496. stroke: 'black',
  3497. 'stroke-width': 2,
  3498. fill: 'white'
  3499. },
  3500. visible: false,
  3501. events: {}
  3502. },
  3503. /**
  3504. * Event callback when annotation is added to the chart.
  3505. *
  3506. * @type {Highcharts.EventCallbackFunction<Highcharts.Annotation>}
  3507. * @since 7.1.0
  3508. * @apioption annotations.events.add
  3509. */
  3510. /**
  3511. * Event callback when annotation is updated (e.g. drag and
  3512. * droppped or resized by control points).
  3513. *
  3514. * @type {Highcharts.EventCallbackFunction<Highcharts.Annotation>}
  3515. * @since 7.1.0
  3516. * @apioption annotations.events.afterUpdate
  3517. */
  3518. /**
  3519. * Event callback when annotation is removed from the chart.
  3520. *
  3521. * @type {Highcharts.EventCallbackFunction<Highcharts.Annotation>}
  3522. * @since 7.1.0
  3523. * @apioption annotations.events.remove
  3524. */
  3525. /**
  3526. * Events available in annotations.
  3527. *
  3528. * @requires modules/annotations
  3529. */
  3530. events: {},
  3531. /**
  3532. * The Z index of the annotation.
  3533. */
  3534. zIndex: 6
  3535. }
  3536. }));
  3537. H.extendAnnotation = function (Constructor, BaseConstructor, prototype, defaultOptions) {
  3538. BaseConstructor = BaseConstructor || Annotation;
  3539. merge(true, Constructor.prototype, BaseConstructor.prototype, prototype);
  3540. Constructor.prototype.defaultOptions = merge(Constructor.prototype.defaultOptions, defaultOptions || {});
  3541. };
  3542. /* *********************************************************************
  3543. *
  3544. * EXTENDING CHART PROTOTYPE
  3545. *
  3546. ******************************************************************** */
  3547. extend(chartProto, /** @lends Highcharts.Chart# */ {
  3548. initAnnotation: function (userOptions) {
  3549. var Constructor = Annotation.types[userOptions.type] || Annotation,
  3550. annotation = new Constructor(this,
  3551. userOptions);
  3552. this.annotations.push(annotation);
  3553. return annotation;
  3554. },
  3555. /**
  3556. * Add an annotation to the chart after render time.
  3557. *
  3558. * @param {Highcharts.AnnotationsOptions} options
  3559. * The annotation options for the new, detailed annotation.
  3560. * @param {boolean} [redraw]
  3561. *
  3562. * @return {Highcharts.Annotation} - The newly generated annotation.
  3563. */
  3564. addAnnotation: function (userOptions, redraw) {
  3565. var annotation = this.initAnnotation(userOptions);
  3566. this.options.annotations.push(annotation.options);
  3567. if (pick(redraw, true)) {
  3568. annotation.redraw();
  3569. annotation.graphic.attr({
  3570. opacity: 1
  3571. });
  3572. }
  3573. return annotation;
  3574. },
  3575. /**
  3576. * Remove an annotation from the chart.
  3577. *
  3578. * @param {number|string|Highcharts.Annotation} idOrAnnotation
  3579. * The annotation's id or direct annotation object.
  3580. */
  3581. removeAnnotation: function (idOrAnnotation) {
  3582. var annotations = this.annotations,
  3583. annotation = idOrAnnotation.coll === 'annotations' ?
  3584. idOrAnnotation :
  3585. find(annotations,
  3586. function (annotation) {
  3587. return annotation.options.id === idOrAnnotation;
  3588. });
  3589. if (annotation) {
  3590. fireEvent(annotation, 'remove');
  3591. erase(this.options.annotations, annotation.options);
  3592. erase(annotations, annotation);
  3593. annotation.destroy();
  3594. }
  3595. },
  3596. drawAnnotations: function () {
  3597. this.plotBoxClip.attr(this.plotBox);
  3598. this.annotations.forEach(function (annotation) {
  3599. annotation.redraw();
  3600. annotation.graphic.animate({
  3601. opacity: 1
  3602. }, annotation.animationConfig);
  3603. });
  3604. }
  3605. });
  3606. // Let chart.update() update annotations
  3607. chartProto.collectionsWithUpdate.push('annotations');
  3608. // Let chart.update() create annoations on demand
  3609. chartProto.collectionsWithInit.annotations = [chartProto.addAnnotation];
  3610. // Create lookups initially
  3611. addEvent(Chart, 'afterInit', function () {
  3612. this.annotations = [];
  3613. if (!this.options.annotations) {
  3614. this.options.annotations = [];
  3615. }
  3616. });
  3617. chartProto.callbacks.push(function (chart) {
  3618. chart.plotBoxClip = this.renderer.clipRect(this.plotBox);
  3619. chart.controlPointsGroup = chart.renderer
  3620. .g('control-points')
  3621. .attr({ zIndex: 99 })
  3622. .clip(chart.plotBoxClip)
  3623. .add();
  3624. chart.options.annotations.forEach(function (annotationOptions, i) {
  3625. if (
  3626. // Verify that it has not been previously added in a responsive rule
  3627. !chart.annotations.some(function (annotation) {
  3628. return annotation.options === annotationOptions;
  3629. })) {
  3630. var annotation = chart.initAnnotation(annotationOptions);
  3631. chart.options.annotations[i] = annotation.options;
  3632. }
  3633. });
  3634. chart.drawAnnotations();
  3635. addEvent(chart, 'redraw', chart.drawAnnotations);
  3636. addEvent(chart, 'destroy', function () {
  3637. chart.plotBoxClip.destroy();
  3638. chart.controlPointsGroup.destroy();
  3639. });
  3640. addEvent(chart, 'exportData', function (event) {
  3641. var _a,
  3642. _b,
  3643. _c,
  3644. _d,
  3645. _e,
  3646. _f,
  3647. _g,
  3648. _h;
  3649. var annotations = chart.annotations,
  3650. csvColumnHeaderFormatter = ((this.options.exporting &&
  3651. this.options.exporting.csv) ||
  3652. {}).columnHeaderFormatter,
  3653. // If second row doesn't have xValues
  3654. // then it is a title row thus multiple level header is in use.
  3655. multiLevelHeaders = !event.dataRows[1].xValues,
  3656. annotationHeader = (_b = (_a = chart.options.lang) === null || _a === void 0 ? void 0 : _a.exportData) === null || _b === void 0 ? void 0 : _b.annotationHeader,
  3657. columnHeaderFormatter = function (index) {
  3658. var s;
  3659. if (csvColumnHeaderFormatter) {
  3660. s = csvColumnHeaderFormatter(index);
  3661. if (s !== false) {
  3662. return s;
  3663. }
  3664. }
  3665. s = annotationHeader + ' ' + index;
  3666. if (multiLevelHeaders) {
  3667. return {
  3668. columnTitle: s,
  3669. topLevelColumnTitle: s
  3670. };
  3671. }
  3672. return s;
  3673. }, startRowLength = event.dataRows[0].length, annotationSeparator = (_e = (_d = (_c = chart.options.exporting) === null || _c === void 0 ? void 0 : _c.csv) === null || _d === void 0 ? void 0 : _d.annotations) === null || _e === void 0 ? void 0 : _e.itemDelimiter, joinAnnotations = (_h = (_g = (_f = chart.options.exporting) === null || _f === void 0 ? void 0 : _f.csv) === null || _g === void 0 ? void 0 : _g.annotations) === null || _h === void 0 ? void 0 : _h.join;
  3674. annotations.forEach(function (annotation) {
  3675. if (annotation.options.labelOptions.includeInDataExport) {
  3676. annotation.labels.forEach(function (label) {
  3677. if (label.options.text) {
  3678. var annotationText_1 = label.options.text;
  3679. label.points.forEach(function (points) {
  3680. var annotationX = points.x,
  3681. xAxisIndex = points.series.xAxis ?
  3682. points.series.xAxis.options.index :
  3683. -1;
  3684. var wasAdded = false;
  3685. // Annotation not connected to any xAxis -
  3686. // add new row.
  3687. if (xAxisIndex === -1) {
  3688. var n = event.dataRows[0].length,
  3689. newRow = new Array(n);
  3690. for (var i = 0; i < n; ++i) {
  3691. newRow[i] = '';
  3692. }
  3693. newRow.push(annotationText_1);
  3694. newRow.xValues = [];
  3695. newRow.xValues[xAxisIndex] = annotationX;
  3696. event.dataRows.push(newRow);
  3697. wasAdded = true;
  3698. }
  3699. // Annotation placed on a exported data point
  3700. // - add new column
  3701. if (!wasAdded) {
  3702. event.dataRows.forEach(function (row, rowIndex) {
  3703. if (!wasAdded &&
  3704. row.xValues &&
  3705. xAxisIndex !== void 0 &&
  3706. annotationX === row.xValues[xAxisIndex]) {
  3707. if (joinAnnotations &&
  3708. row.length > startRowLength) {
  3709. row[row.length - 1] +=
  3710. annotationSeparator + annotationText_1;
  3711. }
  3712. else {
  3713. row.push(annotationText_1);
  3714. }
  3715. wasAdded = true;
  3716. }
  3717. });
  3718. }
  3719. // Annotation not placed on any exported data point,
  3720. // but connected to the xAxis - add new row
  3721. if (!wasAdded) {
  3722. var n = event.dataRows[0].length,
  3723. newRow = new Array(n);
  3724. for (var i = 0; i < n; ++i) {
  3725. newRow[i] = '';
  3726. }
  3727. newRow[0] = annotationX;
  3728. newRow.push(annotationText_1);
  3729. newRow.xValues = [];
  3730. if (xAxisIndex !== void 0) {
  3731. newRow.xValues[xAxisIndex] = annotationX;
  3732. }
  3733. event.dataRows.push(newRow);
  3734. }
  3735. });
  3736. }
  3737. });
  3738. }
  3739. });
  3740. var maxRowLen = 0;
  3741. event.dataRows.forEach(function (row) {
  3742. maxRowLen = Math.max(maxRowLen, row.length);
  3743. });
  3744. var newRows = maxRowLen - event.dataRows[0].length;
  3745. for (var i = 0; i < newRows; i++) {
  3746. var header = columnHeaderFormatter(i + 1);
  3747. if (multiLevelHeaders) {
  3748. event.dataRows[0].push(header.topLevelColumnTitle);
  3749. event.dataRows[1].push(header.columnTitle);
  3750. }
  3751. else {
  3752. event.dataRows[0].push(header);
  3753. }
  3754. }
  3755. });
  3756. });
  3757. wrap(Pointer.prototype, 'onContainerMouseDown', function (proceed) {
  3758. if (!this.chart.hasDraggedAnnotation) {
  3759. proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  3760. }
  3761. });
  3762. H.Annotation = Annotation;
  3763. return Annotation;
  3764. });
  3765. _registerModule(_modules, 'Extensions/Annotations/Types/BasicAnnotation.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, MockPoint, U) {
  3766. /* *
  3767. *
  3768. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3769. *
  3770. * */
  3771. var __extends = (this && this.__extends) || (function () {
  3772. var extendStatics = function (d,
  3773. b) {
  3774. extendStatics = Object.setPrototypeOf ||
  3775. ({ __proto__: [] } instanceof Array && function (d,
  3776. b) { d.__proto__ = b; }) ||
  3777. function (d,
  3778. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3779. return extendStatics(d, b);
  3780. };
  3781. return function (d, b) {
  3782. extendStatics(d, b);
  3783. function __() { this.constructor = d; }
  3784. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3785. };
  3786. })();
  3787. var merge = U.merge;
  3788. /* eslint-disable no-invalid-this */
  3789. var BasicAnnotation = /** @class */ (function (_super) {
  3790. __extends(BasicAnnotation, _super);
  3791. /* *
  3792. *
  3793. * Constructors
  3794. *
  3795. * */
  3796. function BasicAnnotation(chart, options) {
  3797. return _super.call(this, chart, options) || this;
  3798. }
  3799. /* *
  3800. *
  3801. * Functions
  3802. *
  3803. * */
  3804. BasicAnnotation.prototype.addControlPoints = function () {
  3805. var options = this.options,
  3806. controlPoints = BasicAnnotation.basicControlPoints,
  3807. annotationType = this.basicType,
  3808. optionsGroup = options.labels || options.shapes;
  3809. optionsGroup.forEach(function (group) {
  3810. group.controlPoints = controlPoints[annotationType];
  3811. });
  3812. };
  3813. BasicAnnotation.prototype.init = function () {
  3814. var options = this.options;
  3815. if (options.shapes) {
  3816. delete options.labelOptions;
  3817. if (options.shapes[0].type === 'circle') {
  3818. this.basicType = 'circle';
  3819. }
  3820. else {
  3821. this.basicType = 'rectangle';
  3822. }
  3823. }
  3824. else {
  3825. delete options.shapes;
  3826. this.basicType = 'label';
  3827. }
  3828. Annotation.prototype.init.apply(this, arguments);
  3829. };
  3830. /* *
  3831. *
  3832. * Static Properties
  3833. *
  3834. * */
  3835. BasicAnnotation.basicControlPoints = {
  3836. label: [{
  3837. symbol: 'triangle-down',
  3838. positioner: function (target) {
  3839. if (!target.graphic.placed) {
  3840. return {
  3841. x: 0,
  3842. y: -9e7
  3843. };
  3844. }
  3845. var xy = MockPoint
  3846. .pointToPixels(target.points[0]);
  3847. return {
  3848. x: xy.x - this.graphic.width / 2,
  3849. y: xy.y - this.graphic.height / 2
  3850. };
  3851. },
  3852. // TRANSLATE POINT/ANCHOR
  3853. events: {
  3854. drag: function (e, target) {
  3855. var xy = this.mouseMoveToTranslation(e);
  3856. target.translatePoint(xy.x, xy.y);
  3857. target.annotation.userOptions.labels[0].point =
  3858. target.options.point;
  3859. target.redraw(false);
  3860. }
  3861. }
  3862. }, {
  3863. symbol: 'square',
  3864. positioner: function (target) {
  3865. if (!target.graphic.placed) {
  3866. return {
  3867. x: 0,
  3868. y: -9e7
  3869. };
  3870. }
  3871. return {
  3872. x: target.graphic.alignAttr.x -
  3873. this.graphic.width / 2,
  3874. y: target.graphic.alignAttr.y -
  3875. this.graphic.height / 2
  3876. };
  3877. },
  3878. // TRANSLATE POSITION WITHOUT CHANGING THE
  3879. // ANCHOR
  3880. events: {
  3881. drag: function (e, target) {
  3882. var xy = this.mouseMoveToTranslation(e);
  3883. target.translate(xy.x, xy.y);
  3884. target.annotation.userOptions.labels[0].point =
  3885. target.options.point;
  3886. target.redraw(false);
  3887. }
  3888. }
  3889. }],
  3890. rectangle: [{
  3891. positioner: function (annotation) {
  3892. var xy = MockPoint
  3893. .pointToPixels(annotation.points[2]);
  3894. return {
  3895. x: xy.x - 4,
  3896. y: xy.y - 4
  3897. };
  3898. },
  3899. events: {
  3900. drag: function (e, target) {
  3901. var annotation = target.annotation,
  3902. coords = this.chart.pointer.getCoordinates(e),
  3903. x = coords.xAxis[0].value,
  3904. y = coords.yAxis[0].value,
  3905. points = target.options.points;
  3906. // Top right point
  3907. points[1].x = x;
  3908. // Bottom right point (cursor position)
  3909. points[2].x = x;
  3910. points[2].y = y;
  3911. // Bottom left
  3912. points[3].y = y;
  3913. annotation.userOptions.shapes[0].points =
  3914. target.options.points;
  3915. annotation.redraw(false);
  3916. }
  3917. }
  3918. }],
  3919. circle: [{
  3920. positioner: function (target) {
  3921. var xy = MockPoint.pointToPixels(target.points[0]),
  3922. r = target.options.r;
  3923. return {
  3924. x: xy.x + r * Math.cos(Math.PI / 4) -
  3925. this.graphic.width / 2,
  3926. y: xy.y + r * Math.sin(Math.PI / 4) -
  3927. this.graphic.height / 2
  3928. };
  3929. },
  3930. events: {
  3931. // TRANSFORM RADIUS ACCORDING TO Y
  3932. // TRANSLATION
  3933. drag: function (e, target) {
  3934. var annotation = target.annotation,
  3935. position = this.mouseMoveToTranslation(e);
  3936. target.setRadius(Math.max(target.options.r +
  3937. position.y /
  3938. Math.sin(Math.PI / 4), 5));
  3939. annotation.userOptions.shapes[0].r = target.options.r;
  3940. annotation.userOptions.shapes[0].point =
  3941. target.options.point;
  3942. target.redraw(false);
  3943. }
  3944. }
  3945. }]
  3946. };
  3947. return BasicAnnotation;
  3948. }(Annotation));
  3949. BasicAnnotation.prototype.defaultOptions = merge(Annotation.prototype.defaultOptions, {});
  3950. Annotation.types.basicAnnotation = BasicAnnotation;
  3951. return BasicAnnotation;
  3952. });
  3953. _registerModule(_modules, 'Extensions/Annotations/Types/CrookedLine.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/ControlPoint.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, ControlPoint, MockPoint, U) {
  3954. /* *
  3955. *
  3956. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3957. *
  3958. * */
  3959. var __extends = (this && this.__extends) || (function () {
  3960. var extendStatics = function (d,
  3961. b) {
  3962. extendStatics = Object.setPrototypeOf ||
  3963. ({ __proto__: [] } instanceof Array && function (d,
  3964. b) { d.__proto__ = b; }) ||
  3965. function (d,
  3966. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3967. return extendStatics(d, b);
  3968. };
  3969. return function (d, b) {
  3970. extendStatics(d, b);
  3971. function __() { this.constructor = d; }
  3972. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3973. };
  3974. })();
  3975. var merge = U.merge;
  3976. /* eslint-disable no-invalid-this, valid-jsdoc */
  3977. var CrookedLine = /** @class */ (function (_super) {
  3978. __extends(CrookedLine, _super);
  3979. /* *
  3980. *
  3981. * Constructors
  3982. *
  3983. * */
  3984. function CrookedLine(chart, options) {
  3985. return _super.call(this, chart, options) || this;
  3986. }
  3987. /* *
  3988. *
  3989. * Functions
  3990. *
  3991. * */
  3992. /**
  3993. * Overrides default setter to get axes from typeOptions.
  3994. * @private
  3995. */
  3996. CrookedLine.prototype.setClipAxes = function () {
  3997. this.clipXAxis = this.chart.xAxis[this.options.typeOptions.xAxis];
  3998. this.clipYAxis = this.chart.yAxis[this.options.typeOptions.yAxis];
  3999. };
  4000. CrookedLine.prototype.getPointsOptions = function () {
  4001. var typeOptions = this.options.typeOptions;
  4002. return (typeOptions.points || []).map(function (pointOptions) {
  4003. pointOptions.xAxis = typeOptions.xAxis;
  4004. pointOptions.yAxis = typeOptions.yAxis;
  4005. return pointOptions;
  4006. });
  4007. };
  4008. CrookedLine.prototype.getControlPointsOptions = function () {
  4009. return this.getPointsOptions();
  4010. };
  4011. CrookedLine.prototype.addControlPoints = function () {
  4012. this.getControlPointsOptions().forEach(function (pointOptions, i) {
  4013. var controlPoint = new ControlPoint(this.chart,
  4014. this,
  4015. merge(this.options.controlPointOptions,
  4016. pointOptions.controlPoint),
  4017. i);
  4018. this.controlPoints.push(controlPoint);
  4019. pointOptions.controlPoint = controlPoint.options;
  4020. }, this);
  4021. };
  4022. CrookedLine.prototype.addShapes = function () {
  4023. var typeOptions = this.options.typeOptions,
  4024. shape = this.initShape(merge(typeOptions.line, {
  4025. type: 'path',
  4026. points: this.points.map(function (_point,
  4027. i) {
  4028. return function (target) {
  4029. return target.annotation.points[i];
  4030. };
  4031. })
  4032. }), false);
  4033. typeOptions.line = shape.options;
  4034. };
  4035. return CrookedLine;
  4036. }(Annotation));
  4037. CrookedLine.prototype.defaultOptions = merge(Annotation.prototype.defaultOptions,
  4038. /**
  4039. * A crooked line annotation.
  4040. *
  4041. * @sample highcharts/annotations-advanced/crooked-line/
  4042. * Crooked line
  4043. *
  4044. * @product highstock
  4045. * @optionparent annotations.crookedLine
  4046. */
  4047. {
  4048. /**
  4049. * @extends annotations.labelOptions
  4050. * @apioption annotations.crookedLine.labelOptions
  4051. */
  4052. /**
  4053. * @extends annotations.shapeOptions
  4054. * @apioption annotations.crookedLine.shapeOptions
  4055. */
  4056. /**
  4057. * Additional options for an annotation with the type.
  4058. */
  4059. typeOptions: {
  4060. /**
  4061. * This number defines which xAxis the point is connected to.
  4062. * It refers to either the axis id or the index of the axis
  4063. * in the xAxis array.
  4064. */
  4065. xAxis: 0,
  4066. /**
  4067. * This number defines which yAxis the point is connected to.
  4068. * It refers to either the axis id or the index of the axis
  4069. * in the xAxis array.
  4070. */
  4071. yAxis: 0,
  4072. /**
  4073. * @type {Array<*>}
  4074. * @apioption annotations.crookedLine.typeOptions.points
  4075. */
  4076. /**
  4077. * The x position of the point.
  4078. *
  4079. * @type {number}
  4080. * @apioption annotations.crookedLine.typeOptions.points.x
  4081. */
  4082. /**
  4083. * The y position of the point.
  4084. *
  4085. * @type {number}
  4086. * @apioption annotations.crookedLine.typeOptions.points.y
  4087. */
  4088. /**
  4089. * @type {number}
  4090. * @excluding positioner, events
  4091. * @apioption annotations.crookedLine.typeOptions.points.controlPoint
  4092. */
  4093. /**
  4094. * Line options.
  4095. *
  4096. * @excluding height, point, points, r, type, width
  4097. */
  4098. line: {
  4099. fill: 'none'
  4100. }
  4101. },
  4102. /**
  4103. * @excluding positioner, events
  4104. */
  4105. controlPointOptions: {
  4106. positioner: function (target) {
  4107. var graphic = this.graphic,
  4108. xy = MockPoint.pointToPixels(target.points[this.index]);
  4109. return {
  4110. x: xy.x - graphic.width / 2,
  4111. y: xy.y - graphic.height / 2
  4112. };
  4113. },
  4114. events: {
  4115. drag: function (e, target) {
  4116. if (target.chart.isInsidePlot(e.chartX - target.chart.plotLeft, e.chartY - target.chart.plotTop)) {
  4117. var translation = this.mouseMoveToTranslation(e);
  4118. target.translatePoint(translation.x, translation.y, this.index);
  4119. // Update options:
  4120. target.options.typeOptions.points[this.index].x = target.points[this.index].x;
  4121. target.options.typeOptions.points[this.index].y = target.points[this.index].y;
  4122. target.redraw(false);
  4123. }
  4124. }
  4125. }
  4126. }
  4127. });
  4128. Annotation.types.crookedLine = CrookedLine;
  4129. return CrookedLine;
  4130. });
  4131. _registerModule(_modules, 'Extensions/Annotations/Types/ElliottWave.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/Types/CrookedLine.js'], _modules['Core/Utilities.js']], function (Annotation, CrookedLine, U) {
  4132. /* *
  4133. *
  4134. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4135. *
  4136. * */
  4137. var __extends = (this && this.__extends) || (function () {
  4138. var extendStatics = function (d,
  4139. b) {
  4140. extendStatics = Object.setPrototypeOf ||
  4141. ({ __proto__: [] } instanceof Array && function (d,
  4142. b) { d.__proto__ = b; }) ||
  4143. function (d,
  4144. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4145. return extendStatics(d, b);
  4146. };
  4147. return function (d, b) {
  4148. extendStatics(d, b);
  4149. function __() { this.constructor = d; }
  4150. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4151. };
  4152. })();
  4153. var merge = U.merge;
  4154. /* eslint-disable no-invalid-this, valid-jsdoc */
  4155. var ElliottWave = /** @class */ (function (_super) {
  4156. __extends(ElliottWave, _super);
  4157. function ElliottWave(chart, options) {
  4158. return _super.call(this, chart, options) || this;
  4159. }
  4160. /* *
  4161. *
  4162. * Functions
  4163. *
  4164. * */
  4165. ElliottWave.prototype.addLabels = function () {
  4166. this.getPointsOptions().forEach(function (point, i) {
  4167. var typeOptions = this.options.typeOptions,
  4168. label = this.initLabel(merge(point.label, {
  4169. text: typeOptions.labels[i],
  4170. point: function (target) {
  4171. return target.annotation.points[i];
  4172. }
  4173. }), false);
  4174. point.label = label.options;
  4175. }, this);
  4176. };
  4177. return ElliottWave;
  4178. }(CrookedLine));
  4179. ElliottWave.prototype.defaultOptions = merge(CrookedLine.prototype.defaultOptions,
  4180. /**
  4181. * An elliott wave annotation.
  4182. *
  4183. * @sample highcharts/annotations-advanced/elliott-wave/
  4184. * Elliott wave
  4185. *
  4186. * @extends annotations.crookedLine
  4187. * @product highstock
  4188. * @optionparent annotations.elliottWave
  4189. */
  4190. {
  4191. typeOptions: {
  4192. /**
  4193. * @extends annotations.crookedLine.labelOptions
  4194. * @apioption annotations.elliottWave.typeOptions.points.label
  4195. */
  4196. /**
  4197. * @ignore-options
  4198. */
  4199. labels: ['(0)', '(A)', '(B)', '(C)', '(D)', '(E)'],
  4200. line: {
  4201. strokeWidth: 1
  4202. }
  4203. },
  4204. labelOptions: {
  4205. align: 'center',
  4206. allowOverlap: true,
  4207. crop: true,
  4208. overflow: 'none',
  4209. type: 'rect',
  4210. backgroundColor: 'none',
  4211. borderWidth: 0,
  4212. y: -5
  4213. }
  4214. });
  4215. Annotation.types.elliottWave = ElliottWave;
  4216. return ElliottWave;
  4217. });
  4218. _registerModule(_modules, 'Extensions/Annotations/Types/Tunnel.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/ControlPoint.js'], _modules['Extensions/Annotations/Types/CrookedLine.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, ControlPoint, CrookedLine, MockPoint, U) {
  4219. /* *
  4220. *
  4221. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4222. *
  4223. * */
  4224. var __extends = (this && this.__extends) || (function () {
  4225. var extendStatics = function (d,
  4226. b) {
  4227. extendStatics = Object.setPrototypeOf ||
  4228. ({ __proto__: [] } instanceof Array && function (d,
  4229. b) { d.__proto__ = b; }) ||
  4230. function (d,
  4231. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4232. return extendStatics(d, b);
  4233. };
  4234. return function (d, b) {
  4235. extendStatics(d, b);
  4236. function __() { this.constructor = d; }
  4237. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4238. };
  4239. })();
  4240. var merge = U.merge;
  4241. /* eslint-disable no-invalid-this, valid-jsdoc */
  4242. /**
  4243. * @private
  4244. */
  4245. function getSecondCoordinate(p1, p2, x) {
  4246. return (p2.y - p1.y) / (p2.x - p1.x) * (x - p1.x) + p1.y;
  4247. }
  4248. var Tunnel = /** @class */ (function (_super) {
  4249. __extends(Tunnel, _super);
  4250. /* *
  4251. *
  4252. * Constructors
  4253. *
  4254. * */
  4255. function Tunnel(chart, options) {
  4256. return _super.call(this, chart, options) || this;
  4257. }
  4258. /* *
  4259. *
  4260. * Functions
  4261. *
  4262. * */
  4263. Tunnel.prototype.getPointsOptions = function () {
  4264. var pointsOptions = CrookedLine.prototype.getPointsOptions.call(this);
  4265. pointsOptions[2] = this.heightPointOptions(pointsOptions[1]);
  4266. pointsOptions[3] = this.heightPointOptions(pointsOptions[0]);
  4267. return pointsOptions;
  4268. };
  4269. Tunnel.prototype.getControlPointsOptions = function () {
  4270. return this.getPointsOptions().slice(0, 2);
  4271. };
  4272. Tunnel.prototype.heightPointOptions = function (pointOptions) {
  4273. var heightPointOptions = merge(pointOptions),
  4274. typeOptions = this.options.typeOptions;
  4275. heightPointOptions.y += typeOptions.height;
  4276. return heightPointOptions;
  4277. };
  4278. Tunnel.prototype.addControlPoints = function () {
  4279. CrookedLine.prototype.addControlPoints.call(this);
  4280. var options = this.options,
  4281. typeOptions = options.typeOptions,
  4282. controlPoint = new ControlPoint(this.chart,
  4283. this,
  4284. merge(options.controlPointOptions,
  4285. typeOptions.heightControlPoint), 2);
  4286. this.controlPoints.push(controlPoint);
  4287. typeOptions.heightControlPoint = controlPoint.options;
  4288. };
  4289. Tunnel.prototype.addShapes = function () {
  4290. this.addLine();
  4291. this.addBackground();
  4292. };
  4293. Tunnel.prototype.addLine = function () {
  4294. var line = this.initShape(merge(this.options.typeOptions.line, {
  4295. type: 'path',
  4296. points: [
  4297. this.points[0],
  4298. this.points[1],
  4299. function (target) {
  4300. var pointOptions = MockPoint.pointToOptions(target.annotation.points[2]);
  4301. pointOptions.command = 'M';
  4302. return pointOptions;
  4303. },
  4304. this.points[3]
  4305. ]
  4306. }), false);
  4307. this.options.typeOptions.line = line.options;
  4308. };
  4309. Tunnel.prototype.addBackground = function () {
  4310. var background = this.initShape(merge(this.options.typeOptions.background, {
  4311. type: 'path',
  4312. points: this.points.slice()
  4313. }));
  4314. this.options.typeOptions.background = background.options;
  4315. };
  4316. /**
  4317. * Translate start or end ("left" or "right") side of the tunnel.
  4318. * @private
  4319. * @param {number} dx - the amount of x translation
  4320. * @param {number} dy - the amount of y translation
  4321. * @param {boolean} [end] - whether to translate start or end side
  4322. */
  4323. Tunnel.prototype.translateSide = function (dx, dy, end) {
  4324. var topIndex = Number(end),
  4325. bottomIndex = topIndex === 0 ? 3 : 2;
  4326. this.translatePoint(dx, dy, topIndex);
  4327. this.translatePoint(dx, dy, bottomIndex);
  4328. };
  4329. /**
  4330. * Translate height of the tunnel.
  4331. * @private
  4332. * @param {number} dh - the amount of height translation
  4333. */
  4334. Tunnel.prototype.translateHeight = function (dh) {
  4335. this.translatePoint(0, dh, 2);
  4336. this.translatePoint(0, dh, 3);
  4337. this.options.typeOptions.height = this.points[3].y - this.points[0].y;
  4338. };
  4339. return Tunnel;
  4340. }(CrookedLine));
  4341. Tunnel.prototype.defaultOptions = merge(CrookedLine.prototype.defaultOptions,
  4342. /**
  4343. * A tunnel annotation.
  4344. *
  4345. * @extends annotations.crookedLine
  4346. * @sample highcharts/annotations-advanced/tunnel/
  4347. * Tunnel
  4348. * @product highstock
  4349. * @optionparent annotations.tunnel
  4350. */
  4351. {
  4352. typeOptions: {
  4353. xAxis: 0,
  4354. yAxis: 0,
  4355. /**
  4356. * Background options.
  4357. *
  4358. * @type {Object}
  4359. * @excluding height, point, points, r, type, width, markerEnd,
  4360. * markerStart
  4361. */
  4362. background: {
  4363. fill: 'rgba(130, 170, 255, 0.4)',
  4364. strokeWidth: 0
  4365. },
  4366. line: {
  4367. strokeWidth: 1
  4368. },
  4369. /**
  4370. * The height of the annotation in terms of yAxis.
  4371. */
  4372. height: -2,
  4373. /**
  4374. * Options for the control point which controls
  4375. * the annotation's height.
  4376. *
  4377. * @extends annotations.crookedLine.controlPointOptions
  4378. * @excluding positioner, events
  4379. */
  4380. heightControlPoint: {
  4381. positioner: function (target) {
  4382. var startXY = MockPoint.pointToPixels(target.points[2]),
  4383. endXY = MockPoint.pointToPixels(target.points[3]),
  4384. x = (startXY.x + endXY.x) / 2;
  4385. return {
  4386. x: x - this.graphic.width / 2,
  4387. y: getSecondCoordinate(startXY, endXY, x) -
  4388. this.graphic.height / 2
  4389. };
  4390. },
  4391. events: {
  4392. drag: function (e, target) {
  4393. if (target.chart.isInsidePlot(e.chartX - target.chart.plotLeft, e.chartY - target.chart.plotTop)) {
  4394. target.translateHeight(this.mouseMoveToTranslation(e).y);
  4395. target.redraw(false);
  4396. }
  4397. }
  4398. }
  4399. }
  4400. },
  4401. /**
  4402. * @extends annotations.crookedLine.controlPointOptions
  4403. * @excluding positioner, events
  4404. */
  4405. controlPointOptions: {
  4406. events: {
  4407. drag: function (e, target) {
  4408. if (target.chart.isInsidePlot(e.chartX - target.chart.plotLeft, e.chartY - target.chart.plotTop)) {
  4409. var translation = this.mouseMoveToTranslation(e);
  4410. target.translateSide(translation.x, translation.y, this.index);
  4411. target.redraw(false);
  4412. }
  4413. }
  4414. }
  4415. }
  4416. });
  4417. Annotation.types.tunnel = Tunnel;
  4418. return Tunnel;
  4419. });
  4420. _registerModule(_modules, 'Extensions/Annotations/Types/InfinityLine.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/Types/CrookedLine.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, CrookedLine, MockPoint, U) {
  4421. /* *
  4422. *
  4423. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4424. *
  4425. * */
  4426. var __extends = (this && this.__extends) || (function () {
  4427. var extendStatics = function (d,
  4428. b) {
  4429. extendStatics = Object.setPrototypeOf ||
  4430. ({ __proto__: [] } instanceof Array && function (d,
  4431. b) { d.__proto__ = b; }) ||
  4432. function (d,
  4433. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4434. return extendStatics(d, b);
  4435. };
  4436. return function (d, b) {
  4437. extendStatics(d, b);
  4438. function __() { this.constructor = d; }
  4439. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4440. };
  4441. })();
  4442. var merge = U.merge;
  4443. /* eslint-disable no-invalid-this, valid-jsdoc */
  4444. var InfinityLine = /** @class */ (function (_super) {
  4445. __extends(InfinityLine, _super);
  4446. /* *
  4447. *
  4448. * Constructors
  4449. *
  4450. * */
  4451. function InfinityLine(chart, options) {
  4452. return _super.call(this, chart, options) || this;
  4453. }
  4454. /* *
  4455. *
  4456. * Static Functions
  4457. *
  4458. * */
  4459. InfinityLine.edgePoint = function (startIndex, endIndex) {
  4460. return function (target) {
  4461. var annotation = target.annotation,
  4462. points = annotation.points,
  4463. type = annotation.options.typeOptions.type;
  4464. if (type === 'horizontalLine') {
  4465. // Horizontal line has only one point,
  4466. // make a copy of it:
  4467. points = [
  4468. points[0],
  4469. new MockPoint(annotation.chart, points[0].target, {
  4470. x: points[0].x + 1,
  4471. y: points[0].y,
  4472. xAxis: points[0].options.xAxis,
  4473. yAxis: points[0].options.yAxis
  4474. })
  4475. ];
  4476. }
  4477. else if (type === 'verticalLine') {
  4478. // The same for verticalLine type:
  4479. points = [
  4480. points[0],
  4481. new MockPoint(annotation.chart, points[0].target, {
  4482. x: points[0].x,
  4483. y: points[0].y + 1,
  4484. xAxis: points[0].options.xAxis,
  4485. yAxis: points[0].options.yAxis
  4486. })
  4487. ];
  4488. }
  4489. return InfinityLine.findEdgePoint(points[startIndex], points[endIndex]);
  4490. };
  4491. };
  4492. InfinityLine.findEdgeCoordinate = function (firstPoint, secondPoint, xOrY, edgePointFirstCoordinate) {
  4493. var xOrYOpposite = xOrY === 'x' ? 'y' : 'x';
  4494. // solves equation for x or y
  4495. // y - y1 = (y2 - y1) / (x2 - x1) * (x - x1)
  4496. return ((secondPoint[xOrY] - firstPoint[xOrY]) *
  4497. (edgePointFirstCoordinate - firstPoint[xOrYOpposite]) /
  4498. (secondPoint[xOrYOpposite] - firstPoint[xOrYOpposite]) +
  4499. firstPoint[xOrY]);
  4500. };
  4501. InfinityLine.findEdgePoint = function (firstPoint, secondPoint) {
  4502. var xAxis = firstPoint.series.xAxis,
  4503. yAxis = secondPoint.series.yAxis,
  4504. firstPointPixels = MockPoint.pointToPixels(firstPoint),
  4505. secondPointPixels = MockPoint.pointToPixels(secondPoint),
  4506. deltaX = secondPointPixels.x - firstPointPixels.x,
  4507. deltaY = secondPointPixels.y - firstPointPixels.y,
  4508. xAxisMin = xAxis.left,
  4509. xAxisMax = xAxisMin + xAxis.width,
  4510. yAxisMin = yAxis.top,
  4511. yAxisMax = yAxisMin + yAxis.height,
  4512. xLimit = deltaX < 0 ? xAxisMin : xAxisMax,
  4513. yLimit = deltaY < 0 ? yAxisMin : yAxisMax,
  4514. edgePoint = {
  4515. x: deltaX === 0 ? firstPointPixels.x : xLimit,
  4516. y: deltaY === 0 ? firstPointPixels.y : yLimit
  4517. },
  4518. edgePointX,
  4519. edgePointY,
  4520. swap;
  4521. if (deltaX !== 0 && deltaY !== 0) {
  4522. edgePointY = InfinityLine.findEdgeCoordinate(firstPointPixels, secondPointPixels, 'y', xLimit);
  4523. edgePointX = InfinityLine.findEdgeCoordinate(firstPointPixels, secondPointPixels, 'x', yLimit);
  4524. if (edgePointY >= yAxisMin && edgePointY <= yAxisMax) {
  4525. edgePoint.x = xLimit;
  4526. edgePoint.y = edgePointY;
  4527. }
  4528. else {
  4529. edgePoint.x = edgePointX;
  4530. edgePoint.y = yLimit;
  4531. }
  4532. }
  4533. edgePoint.x -= xAxisMin;
  4534. edgePoint.y -= yAxisMin;
  4535. if (firstPoint.series.chart.inverted) {
  4536. swap = edgePoint.x;
  4537. edgePoint.x = edgePoint.y;
  4538. edgePoint.y = swap;
  4539. }
  4540. return edgePoint;
  4541. };
  4542. /* *
  4543. *
  4544. * Functions
  4545. *
  4546. * */
  4547. InfinityLine.prototype.addShapes = function () {
  4548. var typeOptions = this.options.typeOptions,
  4549. points = [
  4550. this.points[0],
  4551. InfinityLine.endEdgePoint
  4552. ];
  4553. if (typeOptions.type.match(/Line/g)) {
  4554. points[0] = InfinityLine.startEdgePoint;
  4555. }
  4556. var line = this.initShape(merge(typeOptions.line, {
  4557. type: 'path',
  4558. points: points
  4559. }),
  4560. false);
  4561. typeOptions.line = line.options;
  4562. };
  4563. /**
  4564. *
  4565. * Static Properties
  4566. *
  4567. */
  4568. InfinityLine.endEdgePoint = InfinityLine.edgePoint(0, 1);
  4569. InfinityLine.startEdgePoint = InfinityLine.edgePoint(1, 0);
  4570. return InfinityLine;
  4571. }(CrookedLine));
  4572. InfinityLine.prototype.defaultOptions = merge(CrookedLine.prototype.defaultOptions, {});
  4573. /**
  4574. * An infinity line annotation.
  4575. *
  4576. * @sample highcharts/annotations-advanced/infinity-line/
  4577. * Infinity Line
  4578. *
  4579. * @extends annotations.crookedLine
  4580. * @product highstock
  4581. * @apioption annotations.infinityLine
  4582. */
  4583. Annotation.types.infinityLine = InfinityLine;
  4584. return InfinityLine;
  4585. });
  4586. _registerModule(_modules, 'Extensions/Annotations/Types/Fibonacci.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Extensions/Annotations/Types/Tunnel.js'], _modules['Core/Utilities.js']], function (Annotation, MockPoint, Tunnel, U) {
  4587. /* *
  4588. *
  4589. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4590. *
  4591. * */
  4592. var __extends = (this && this.__extends) || (function () {
  4593. var extendStatics = function (d,
  4594. b) {
  4595. extendStatics = Object.setPrototypeOf ||
  4596. ({ __proto__: [] } instanceof Array && function (d,
  4597. b) { d.__proto__ = b; }) ||
  4598. function (d,
  4599. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4600. return extendStatics(d, b);
  4601. };
  4602. return function (d, b) {
  4603. extendStatics(d, b);
  4604. function __() { this.constructor = d; }
  4605. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4606. };
  4607. })();
  4608. var merge = U.merge;
  4609. /* eslint-disable no-invalid-this, valid-jsdoc */
  4610. var createPathDGenerator = function (retracementIndex,
  4611. isBackground) {
  4612. return function () {
  4613. var annotation = this.annotation,
  4614. leftTop = this.anchor(annotation.startRetracements[retracementIndex]).absolutePosition,
  4615. rightTop = this.anchor(annotation.endRetracements[retracementIndex]).absolutePosition,
  4616. d = [
  4617. ['M',
  4618. Math.round(leftTop.x),
  4619. Math.round(leftTop.y)],
  4620. ['L',
  4621. Math.round(rightTop.x),
  4622. Math.round(rightTop.y)]
  4623. ],
  4624. rightBottom,
  4625. leftBottom;
  4626. if (isBackground) {
  4627. rightBottom = this.anchor(annotation.endRetracements[retracementIndex - 1]).absolutePosition;
  4628. leftBottom = this.anchor(annotation.startRetracements[retracementIndex - 1]).absolutePosition;
  4629. d.push(['L', Math.round(rightBottom.x), Math.round(rightBottom.y)], ['L', Math.round(leftBottom.x), Math.round(leftBottom.y)]);
  4630. }
  4631. return d;
  4632. };
  4633. };
  4634. var Fibonacci = /** @class */ (function (_super) {
  4635. __extends(Fibonacci, _super);
  4636. /* *
  4637. *
  4638. * Constructors
  4639. *
  4640. * */
  4641. function Fibonacci(chart, options) {
  4642. return _super.call(this, chart, options) || this;
  4643. }
  4644. /* *
  4645. *
  4646. * Functions
  4647. *
  4648. * */
  4649. Fibonacci.prototype.linkPoints = function () {
  4650. _super.prototype.linkPoints.call(this);
  4651. this.linkRetracementsPoints();
  4652. return;
  4653. };
  4654. Fibonacci.prototype.linkRetracementsPoints = function () {
  4655. var points = this.points,
  4656. startDiff = points[0].y - points[3].y,
  4657. endDiff = points[1].y - points[2].y,
  4658. startX = points[0].x,
  4659. endX = points[1].x;
  4660. Fibonacci.levels.forEach(function (level, i) {
  4661. var startRetracement = points[0].y - startDiff * level,
  4662. endRetracement = points[1].y - endDiff * level;
  4663. this.startRetracements = this.startRetracements || [];
  4664. this.endRetracements = this.endRetracements || [];
  4665. this.linkRetracementPoint(i, startX, startRetracement, this.startRetracements);
  4666. this.linkRetracementPoint(i, endX, endRetracement, this.endRetracements);
  4667. }, this);
  4668. };
  4669. Fibonacci.prototype.linkRetracementPoint = function (pointIndex, x, y, retracements) {
  4670. var point = retracements[pointIndex],
  4671. typeOptions = this.options.typeOptions;
  4672. if (!point) {
  4673. retracements[pointIndex] = new MockPoint(this.chart, this, {
  4674. x: x,
  4675. y: y,
  4676. xAxis: typeOptions.xAxis,
  4677. yAxis: typeOptions.yAxis
  4678. });
  4679. }
  4680. else {
  4681. point.options.x = x;
  4682. point.options.y = y;
  4683. point.refresh();
  4684. }
  4685. };
  4686. Fibonacci.prototype.addShapes = function () {
  4687. Fibonacci.levels.forEach(function (_level, i) {
  4688. this.initShape({
  4689. type: 'path',
  4690. d: createPathDGenerator(i)
  4691. }, false);
  4692. if (i > 0) {
  4693. this.initShape({
  4694. type: 'path',
  4695. fill: this.options.typeOptions.backgroundColors[i - 1],
  4696. strokeWidth: 0,
  4697. d: createPathDGenerator(i, true)
  4698. });
  4699. }
  4700. }, this);
  4701. };
  4702. Fibonacci.prototype.addLabels = function () {
  4703. Fibonacci.levels.forEach(function (level, i) {
  4704. var options = this.options.typeOptions,
  4705. label = this.initLabel(merge(options.labels[i], {
  4706. point: function (target) {
  4707. var point = MockPoint.pointToOptions(target.annotation.startRetracements[i]);
  4708. return point;
  4709. },
  4710. text: level.toString()
  4711. }));
  4712. options.labels[i] = label.options;
  4713. }, this);
  4714. };
  4715. /* *
  4716. *
  4717. * Static properties
  4718. *
  4719. * */
  4720. Fibonacci.levels = [0, 0.236, 0.382, 0.5, 0.618, 0.786, 1];
  4721. return Fibonacci;
  4722. }(Tunnel));
  4723. Fibonacci.prototype.defaultOptions = merge(Tunnel.prototype.defaultOptions,
  4724. /**
  4725. * A fibonacci annotation.
  4726. *
  4727. * @sample highcharts/annotations-advanced/fibonacci/
  4728. * Fibonacci
  4729. *
  4730. * @extends annotations.crookedLine
  4731. * @product highstock
  4732. * @optionparent annotations.fibonacci
  4733. */
  4734. {
  4735. typeOptions: {
  4736. /**
  4737. * The height of the fibonacci in terms of yAxis.
  4738. */
  4739. height: 2,
  4740. /**
  4741. * An array of background colors:
  4742. * Default to:
  4743. * ```
  4744. * [
  4745. * 'rgba(130, 170, 255, 0.4)',
  4746. * 'rgba(139, 191, 216, 0.4)',
  4747. * 'rgba(150, 216, 192, 0.4)',
  4748. * 'rgba(156, 229, 161, 0.4)',
  4749. * 'rgba(162, 241, 130, 0.4)',
  4750. * 'rgba(169, 255, 101, 0.4)'
  4751. * ]
  4752. * ```
  4753. */
  4754. backgroundColors: [
  4755. 'rgba(130, 170, 255, 0.4)',
  4756. 'rgba(139, 191, 216, 0.4)',
  4757. 'rgba(150, 216, 192, 0.4)',
  4758. 'rgba(156, 229, 161, 0.4)',
  4759. 'rgba(162, 241, 130, 0.4)',
  4760. 'rgba(169, 255, 101, 0.4)'
  4761. ],
  4762. /**
  4763. * The color of line.
  4764. */
  4765. lineColor: 'grey',
  4766. /**
  4767. * An array of colors for the lines.
  4768. */
  4769. lineColors: [],
  4770. /**
  4771. * An array with options for the labels.
  4772. *
  4773. * @type {Array<*>}
  4774. * @extends annotations.crookedLine.labelOptions
  4775. * @apioption annotations.fibonacci.typeOptions.labels
  4776. */
  4777. labels: []
  4778. },
  4779. labelOptions: {
  4780. allowOverlap: true,
  4781. align: 'right',
  4782. backgroundColor: 'none',
  4783. borderWidth: 0,
  4784. crop: false,
  4785. overflow: 'none',
  4786. shape: 'rect',
  4787. style: {
  4788. color: 'grey'
  4789. },
  4790. verticalAlign: 'middle',
  4791. y: 0
  4792. }
  4793. });
  4794. Annotation.types.fibonacci = Fibonacci;
  4795. return Fibonacci;
  4796. });
  4797. _registerModule(_modules, 'Extensions/Annotations/Types/Pitchfork.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/Types/InfinityLine.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, InfinityLine, MockPoint, U) {
  4798. /* *
  4799. *
  4800. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4801. *
  4802. * */
  4803. var __extends = (this && this.__extends) || (function () {
  4804. var extendStatics = function (d,
  4805. b) {
  4806. extendStatics = Object.setPrototypeOf ||
  4807. ({ __proto__: [] } instanceof Array && function (d,
  4808. b) { d.__proto__ = b; }) ||
  4809. function (d,
  4810. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4811. return extendStatics(d, b);
  4812. };
  4813. return function (d, b) {
  4814. extendStatics(d, b);
  4815. function __() { this.constructor = d; }
  4816. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4817. };
  4818. })();
  4819. var merge = U.merge;
  4820. /* eslint-disable no-invalid-this, valid-jsdoc */
  4821. var Pitchfork = /** @class */ (function (_super) {
  4822. __extends(Pitchfork, _super);
  4823. /* *
  4824. *
  4825. * Constructors
  4826. *
  4827. * */
  4828. function Pitchfork(chart, options) {
  4829. return _super.call(this, chart, options) || this;
  4830. }
  4831. /* *
  4832. *
  4833. * Static Functions
  4834. *
  4835. * */
  4836. Pitchfork.outerLineEdgePoint = function (firstPointIndex) {
  4837. return function (target) {
  4838. var annotation = target.annotation,
  4839. points = annotation.points;
  4840. return Pitchfork.findEdgePoint(points[firstPointIndex], points[0], new MockPoint(annotation.chart, target, annotation.midPointOptions()));
  4841. };
  4842. };
  4843. Pitchfork.findEdgePoint = function (point, firstAnglePoint, secondAnglePoint) {
  4844. var angle = Math.atan2(secondAnglePoint.plotY - firstAnglePoint.plotY,
  4845. secondAnglePoint.plotX - firstAnglePoint.plotX),
  4846. distance = 1e7;
  4847. return {
  4848. x: point.plotX + distance * Math.cos(angle),
  4849. y: point.plotY + distance * Math.sin(angle)
  4850. };
  4851. };
  4852. Pitchfork.middleLineEdgePoint = function (target) {
  4853. var annotation = target.annotation,
  4854. points = annotation.points;
  4855. return InfinityLine.findEdgePoint(points[0], new MockPoint(annotation.chart, target, annotation.midPointOptions()));
  4856. };
  4857. /* *
  4858. *
  4859. * Functions
  4860. *
  4861. * */
  4862. Pitchfork.prototype.midPointOptions = function () {
  4863. var points = this.points;
  4864. return {
  4865. x: (points[1].x + points[2].x) / 2,
  4866. y: (points[1].y + points[2].y) / 2,
  4867. xAxis: points[0].series.xAxis,
  4868. yAxis: points[0].series.yAxis
  4869. };
  4870. };
  4871. Pitchfork.prototype.addShapes = function () {
  4872. this.addLines();
  4873. this.addBackgrounds();
  4874. };
  4875. Pitchfork.prototype.addLines = function () {
  4876. this.initShape({
  4877. type: 'path',
  4878. points: [
  4879. this.points[0],
  4880. Pitchfork.middleLineEdgePoint
  4881. ]
  4882. }, false);
  4883. this.initShape({
  4884. type: 'path',
  4885. points: [
  4886. this.points[1],
  4887. Pitchfork.topLineEdgePoint
  4888. ]
  4889. }, false);
  4890. this.initShape({
  4891. type: 'path',
  4892. points: [
  4893. this.points[2],
  4894. Pitchfork.bottomLineEdgePoint
  4895. ]
  4896. }, false);
  4897. };
  4898. Pitchfork.prototype.addBackgrounds = function () {
  4899. var shapes = this.shapes,
  4900. typeOptions = this.options.typeOptions;
  4901. var innerBackground = this.initShape(merge(typeOptions.innerBackground, {
  4902. type: 'path',
  4903. points: [
  4904. function (target) {
  4905. var annotation = target.annotation,
  4906. points = annotation.points,
  4907. midPointOptions = annotation.midPointOptions();
  4908. return {
  4909. x: (points[1].x + midPointOptions.x) / 2,
  4910. y: (points[1].y + midPointOptions.y) / 2,
  4911. xAxis: midPointOptions.xAxis,
  4912. yAxis: midPointOptions.yAxis
  4913. };
  4914. },
  4915. shapes[1].points[1],
  4916. shapes[2].points[1],
  4917. function (target) {
  4918. var annotation = target.annotation,
  4919. points = annotation.points,
  4920. midPointOptions = annotation.midPointOptions();
  4921. return {
  4922. x: (midPointOptions.x + points[2].x) / 2,
  4923. y: (midPointOptions.y + points[2].y) / 2,
  4924. xAxis: midPointOptions.xAxis,
  4925. yAxis: midPointOptions.yAxis
  4926. };
  4927. }
  4928. ]
  4929. }));
  4930. var outerBackground = this.initShape(merge(typeOptions.outerBackground, {
  4931. type: 'path',
  4932. points: [
  4933. this.points[1],
  4934. shapes[1].points[1],
  4935. shapes[2].points[1],
  4936. this.points[2]
  4937. ]
  4938. }));
  4939. typeOptions.innerBackground = innerBackground.options;
  4940. typeOptions.outerBackground = outerBackground.options;
  4941. };
  4942. /**
  4943. *
  4944. * Static Properties
  4945. *
  4946. */
  4947. Pitchfork.topLineEdgePoint = Pitchfork.outerLineEdgePoint(1);
  4948. Pitchfork.bottomLineEdgePoint = Pitchfork.outerLineEdgePoint(0);
  4949. return Pitchfork;
  4950. }(InfinityLine));
  4951. Pitchfork.prototype.defaultOptions = merge(InfinityLine.prototype.defaultOptions,
  4952. /**
  4953. * A pitchfork annotation.
  4954. *
  4955. * @sample highcharts/annotations-advanced/pitchfork/
  4956. * Pitchfork
  4957. *
  4958. * @extends annotations.infinityLine
  4959. * @product highstock
  4960. * @optionparent annotations.pitchfork
  4961. */
  4962. {
  4963. typeOptions: {
  4964. /**
  4965. * Inner background options.
  4966. *
  4967. * @extends annotations.crookedLine.shapeOptions
  4968. * @excluding height, r, type, width
  4969. */
  4970. innerBackground: {
  4971. fill: 'rgba(130, 170, 255, 0.4)',
  4972. strokeWidth: 0
  4973. },
  4974. /**
  4975. * Outer background options.
  4976. *
  4977. * @extends annotations.crookedLine.shapeOptions
  4978. * @excluding height, r, type, width
  4979. */
  4980. outerBackground: {
  4981. fill: 'rgba(156, 229, 161, 0.4)',
  4982. strokeWidth: 0
  4983. }
  4984. }
  4985. });
  4986. Annotation.types.pitchfork = Pitchfork;
  4987. return Pitchfork;
  4988. });
  4989. _registerModule(_modules, 'Extensions/Annotations/Types/VerticalLine.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/MockPoint.js'], _modules['Core/Utilities.js']], function (Annotation, MockPoint, U) {
  4990. /* *
  4991. *
  4992. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4993. *
  4994. * */
  4995. var __extends = (this && this.__extends) || (function () {
  4996. var extendStatics = function (d,
  4997. b) {
  4998. extendStatics = Object.setPrototypeOf ||
  4999. ({ __proto__: [] } instanceof Array && function (d,
  5000. b) { d.__proto__ = b; }) ||
  5001. function (d,
  5002. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5003. return extendStatics(d, b);
  5004. };
  5005. return function (d, b) {
  5006. extendStatics(d, b);
  5007. function __() { this.constructor = d; }
  5008. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5009. };
  5010. })();
  5011. var merge = U.merge;
  5012. /* eslint-disable no-invalid-this, valid-jsdoc */
  5013. var VerticalLine = /** @class */ (function (_super) {
  5014. __extends(VerticalLine, _super);
  5015. /* *
  5016. *
  5017. * Constructors
  5018. *
  5019. * */
  5020. function VerticalLine(chart, userOptions) {
  5021. return _super.call(this, chart, userOptions) || this;
  5022. }
  5023. /* *
  5024. *
  5025. * Static Functions
  5026. *
  5027. * */
  5028. VerticalLine.connectorFirstPoint = function (target) {
  5029. var annotation = target.annotation,
  5030. point = annotation.points[0],
  5031. xy = MockPoint.pointToPixels(point,
  5032. true),
  5033. y = xy.y,
  5034. offset = annotation.options.typeOptions.label.offset;
  5035. if (annotation.chart.inverted) {
  5036. y = xy.x;
  5037. }
  5038. return {
  5039. x: point.x,
  5040. xAxis: point.series.xAxis,
  5041. y: y + offset
  5042. };
  5043. };
  5044. VerticalLine.connectorSecondPoint = function (target) {
  5045. var annotation = target.annotation,
  5046. typeOptions = annotation.options.typeOptions,
  5047. point = annotation.points[0],
  5048. yOffset = typeOptions.yOffset,
  5049. xy = MockPoint.pointToPixels(point,
  5050. true),
  5051. y = xy[annotation.chart.inverted ? 'x' : 'y'];
  5052. if (typeOptions.label.offset < 0) {
  5053. yOffset *= -1;
  5054. }
  5055. return {
  5056. x: point.x,
  5057. xAxis: point.series.xAxis,
  5058. y: y + yOffset
  5059. };
  5060. };
  5061. /* *
  5062. *
  5063. * Functions
  5064. *
  5065. * */
  5066. VerticalLine.prototype.getPointsOptions = function () {
  5067. return [this.options.typeOptions.point];
  5068. };
  5069. VerticalLine.prototype.addShapes = function () {
  5070. var typeOptions = this.options.typeOptions,
  5071. connector = this.initShape(merge(typeOptions.connector, {
  5072. type: 'path',
  5073. points: [
  5074. VerticalLine.connectorFirstPoint,
  5075. VerticalLine.connectorSecondPoint
  5076. ]
  5077. }),
  5078. false);
  5079. typeOptions.connector = connector.options;
  5080. };
  5081. VerticalLine.prototype.addLabels = function () {
  5082. var typeOptions = this.options.typeOptions, labelOptions = typeOptions.label, x = 0, y = labelOptions.offset, verticalAlign = labelOptions.offset < 0 ? 'bottom' : 'top', align = 'center';
  5083. if (this.chart.inverted) {
  5084. x = labelOptions.offset;
  5085. y = 0;
  5086. verticalAlign = 'middle';
  5087. align = labelOptions.offset < 0 ? 'right' : 'left';
  5088. }
  5089. var label = this.initLabel(merge(labelOptions, {
  5090. verticalAlign: verticalAlign,
  5091. align: align,
  5092. x: x,
  5093. y: y
  5094. }));
  5095. typeOptions.label = label.options;
  5096. };
  5097. return VerticalLine;
  5098. }(Annotation));
  5099. VerticalLine.prototype.defaultOptions = merge(Annotation.prototype.defaultOptions,
  5100. /**
  5101. * A vertical line annotation.
  5102. *
  5103. * @sample highcharts/annotations-advanced/vertical-line/
  5104. * Vertical line
  5105. *
  5106. * @extends annotations.crookedLine
  5107. * @excluding labels, shapes, controlPointOptions
  5108. * @product highstock
  5109. * @optionparent annotations.verticalLine
  5110. */
  5111. {
  5112. typeOptions: {
  5113. /**
  5114. * @ignore
  5115. */
  5116. yOffset: 10,
  5117. /**
  5118. * Label options.
  5119. *
  5120. * @extends annotations.crookedLine.labelOptions
  5121. */
  5122. label: {
  5123. offset: -40,
  5124. point: function (target) {
  5125. return target.annotation.points[0];
  5126. },
  5127. allowOverlap: true,
  5128. backgroundColor: 'none',
  5129. borderWidth: 0,
  5130. crop: true,
  5131. overflow: 'none',
  5132. shape: 'rect',
  5133. text: '{y:.2f}'
  5134. },
  5135. /**
  5136. * Connector options.
  5137. *
  5138. * @extends annotations.crookedLine.shapeOptions
  5139. * @excluding height, r, type, width
  5140. */
  5141. connector: {
  5142. strokeWidth: 1,
  5143. markerEnd: 'arrow'
  5144. }
  5145. }
  5146. });
  5147. Annotation.types.verticalLine = VerticalLine;
  5148. return VerticalLine;
  5149. });
  5150. _registerModule(_modules, 'Extensions/Annotations/Types/Measure.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Extensions/Annotations/ControlPoint.js'], _modules['Core/Utilities.js']], function (Annotation, ControlPoint, U) {
  5151. /* *
  5152. *
  5153. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5154. *
  5155. * */
  5156. var __extends = (this && this.__extends) || (function () {
  5157. var extendStatics = function (d,
  5158. b) {
  5159. extendStatics = Object.setPrototypeOf ||
  5160. ({ __proto__: [] } instanceof Array && function (d,
  5161. b) { d.__proto__ = b; }) ||
  5162. function (d,
  5163. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5164. return extendStatics(d, b);
  5165. };
  5166. return function (d, b) {
  5167. extendStatics(d, b);
  5168. function __() { this.constructor = d; }
  5169. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5170. };
  5171. })();
  5172. var extend = U.extend,
  5173. isNumber = U.isNumber,
  5174. merge = U.merge;
  5175. /* eslint-disable no-invalid-this, valid-jsdoc */
  5176. var Measure = /** @class */ (function (_super) {
  5177. __extends(Measure, _super);
  5178. /* *
  5179. *
  5180. * Constructors
  5181. *
  5182. * */
  5183. function Measure(chart, userOptions) {
  5184. return _super.call(this, chart, userOptions) || this;
  5185. }
  5186. /* *
  5187. *
  5188. * Functions
  5189. *
  5190. * */
  5191. /**
  5192. * Init annotation object.
  5193. * @private
  5194. */
  5195. Measure.prototype.init = function (annotationOrChart, userOptions, index) {
  5196. Annotation.prototype.init.call(this, annotationOrChart, userOptions, index);
  5197. this.offsetX = 0;
  5198. this.offsetY = 0;
  5199. this.resizeX = 0;
  5200. this.resizeY = 0;
  5201. Measure.calculations.init.call(this);
  5202. this.addValues();
  5203. this.addShapes();
  5204. };
  5205. /**
  5206. * Overrides default setter to get axes from typeOptions.
  5207. * @private
  5208. */
  5209. Measure.prototype.setClipAxes = function () {
  5210. this.clipXAxis = this.chart.xAxis[this.options.typeOptions.xAxis];
  5211. this.clipYAxis = this.chart.yAxis[this.options.typeOptions.yAxis];
  5212. };
  5213. /**
  5214. * Get measure points configuration objects.
  5215. * @private
  5216. * @return {Array<Highcharts.AnnotationMockPointOptionsObject>}
  5217. */
  5218. Measure.prototype.pointsOptions = function () {
  5219. return this.options.points;
  5220. };
  5221. /**
  5222. * Get points configuration objects for shapes.
  5223. * @private
  5224. * @return {Array<Highcharts.AnnotationMockPointOptionsObject>}
  5225. */
  5226. Measure.prototype.shapePointsOptions = function () {
  5227. var options = this.options.typeOptions,
  5228. xAxis = options.xAxis,
  5229. yAxis = options.yAxis;
  5230. return [
  5231. {
  5232. x: this.xAxisMin,
  5233. y: this.yAxisMin,
  5234. xAxis: xAxis,
  5235. yAxis: yAxis
  5236. },
  5237. {
  5238. x: this.xAxisMax,
  5239. y: this.yAxisMin,
  5240. xAxis: xAxis,
  5241. yAxis: yAxis
  5242. },
  5243. {
  5244. x: this.xAxisMax,
  5245. y: this.yAxisMax,
  5246. xAxis: xAxis,
  5247. yAxis: yAxis
  5248. },
  5249. {
  5250. x: this.xAxisMin,
  5251. y: this.yAxisMax,
  5252. xAxis: xAxis,
  5253. yAxis: yAxis
  5254. }
  5255. ];
  5256. };
  5257. Measure.prototype.addControlPoints = function () {
  5258. var selectType = this.options.typeOptions.selectType,
  5259. controlPoint;
  5260. controlPoint = new ControlPoint(this.chart, this, this.options.controlPointOptions, 0);
  5261. this.controlPoints.push(controlPoint);
  5262. // add extra controlPoint for horizontal and vertical range
  5263. if (selectType !== 'xy') {
  5264. controlPoint = new ControlPoint(this.chart, this, this.options.controlPointOptions, 1);
  5265. this.controlPoints.push(controlPoint);
  5266. }
  5267. };
  5268. /**
  5269. * Add label with calculated values (min, max, average, bins).
  5270. * @private
  5271. * @param {boolean} [resize]
  5272. * The flag for resize shape
  5273. */
  5274. Measure.prototype.addValues = function (resize) {
  5275. var typeOptions = this.options.typeOptions,
  5276. formatter = typeOptions.label.formatter;
  5277. // set xAxisMin, xAxisMax, yAxisMin, yAxisMax
  5278. Measure.calculations.recalculate.call(this, resize);
  5279. if (!typeOptions.label.enabled) {
  5280. return;
  5281. }
  5282. if (this.labels.length > 0) {
  5283. this.labels[0].text = (formatter && formatter.call(this)) ||
  5284. Measure.calculations.defaultFormatter.call(this);
  5285. }
  5286. else {
  5287. this.initLabel(extend({
  5288. shape: 'rect',
  5289. backgroundColor: 'none',
  5290. color: 'black',
  5291. borderWidth: 0,
  5292. dashStyle: 'dash',
  5293. overflow: 'none',
  5294. align: 'left',
  5295. vertical: 'top',
  5296. crop: true,
  5297. point: function (target) {
  5298. var annotation = target.annotation,
  5299. chart = annotation.chart,
  5300. inverted = chart.inverted,
  5301. xAxis = chart.xAxis[typeOptions.xAxis],
  5302. yAxis = chart.yAxis[typeOptions.yAxis],
  5303. top = chart.plotTop,
  5304. left = chart.plotLeft;
  5305. return {
  5306. x: (inverted ? top : 10) +
  5307. xAxis.toPixels(annotation.xAxisMin, !inverted),
  5308. y: (inverted ? -left + 10 : top) +
  5309. yAxis.toPixels(annotation.yAxisMin)
  5310. };
  5311. },
  5312. text: (formatter && formatter.call(this)) ||
  5313. Measure.calculations.defaultFormatter.call(this)
  5314. }, typeOptions.label));
  5315. }
  5316. };
  5317. /**
  5318. * Crosshair, background (rect).
  5319. * @private
  5320. */
  5321. Measure.prototype.addShapes = function () {
  5322. this.addCrosshairs();
  5323. this.addBackground();
  5324. };
  5325. /**
  5326. * Add background shape.
  5327. * @private
  5328. */
  5329. Measure.prototype.addBackground = function () {
  5330. var shapePoints = this.shapePointsOptions();
  5331. if (typeof shapePoints[0].x === 'undefined') {
  5332. return;
  5333. }
  5334. this.initShape(extend({
  5335. type: 'path',
  5336. points: this.shapePointsOptions()
  5337. }, this.options.typeOptions.background), false);
  5338. };
  5339. /**
  5340. * Add internal crosshair shapes (on top and bottom).
  5341. * @private
  5342. */
  5343. Measure.prototype.addCrosshairs = function () {
  5344. var chart = this.chart,
  5345. options = this.options.typeOptions,
  5346. point = this.options.typeOptions.point,
  5347. xAxis = chart.xAxis[options.xAxis],
  5348. yAxis = chart.yAxis[options.yAxis],
  5349. inverted = chart.inverted,
  5350. xAxisMin = xAxis.toPixels(this.xAxisMin),
  5351. xAxisMax = xAxis.toPixels(this.xAxisMax),
  5352. yAxisMin = yAxis.toPixels(this.yAxisMin),
  5353. yAxisMax = yAxis.toPixels(this.yAxisMax),
  5354. defaultOptions = {
  5355. point: point,
  5356. type: 'path'
  5357. },
  5358. pathH = [],
  5359. pathV = [],
  5360. crosshairOptionsX,
  5361. crosshairOptionsY,
  5362. temp;
  5363. if (inverted) {
  5364. temp = xAxisMin;
  5365. xAxisMin = yAxisMin;
  5366. yAxisMin = temp;
  5367. temp = xAxisMax;
  5368. xAxisMax = yAxisMax;
  5369. yAxisMax = temp;
  5370. }
  5371. // horizontal line
  5372. if (options.crosshairX.enabled) {
  5373. pathH = [[
  5374. 'M',
  5375. xAxisMin,
  5376. yAxisMin + ((yAxisMax - yAxisMin) / 2)
  5377. ], [
  5378. 'L',
  5379. xAxisMax,
  5380. yAxisMin + ((yAxisMax - yAxisMin) / 2)
  5381. ]];
  5382. }
  5383. // vertical line
  5384. if (options.crosshairY.enabled) {
  5385. pathV = [[
  5386. 'M',
  5387. xAxisMin + ((xAxisMax - xAxisMin) / 2),
  5388. yAxisMin
  5389. ], [
  5390. 'L',
  5391. xAxisMin + ((xAxisMax - xAxisMin) / 2),
  5392. yAxisMax
  5393. ]];
  5394. }
  5395. // Update existed crosshair
  5396. if (this.shapes.length > 0) {
  5397. this.shapes[0].options.d = pathH;
  5398. this.shapes[1].options.d = pathV;
  5399. }
  5400. else {
  5401. // Add new crosshairs
  5402. crosshairOptionsX = merge(defaultOptions, options.crosshairX);
  5403. crosshairOptionsY = merge(defaultOptions, options.crosshairY);
  5404. this.initShape(extend({
  5405. d: pathH
  5406. }, crosshairOptionsX), false);
  5407. this.initShape(extend({
  5408. d: pathV
  5409. }, crosshairOptionsY), false);
  5410. }
  5411. };
  5412. Measure.prototype.onDrag = function (e) {
  5413. var translation = this.mouseMoveToTranslation(e), selectType = this.options.typeOptions.selectType, x = selectType === 'y' ? 0 : translation.x, y = selectType === 'x' ? 0 : translation.y;
  5414. this.translate(x, y);
  5415. this.offsetX += x;
  5416. this.offsetY += y;
  5417. // animation, resize, setStartPoints
  5418. this.redraw(false, false, true);
  5419. };
  5420. /**
  5421. * Translate start or end ("left" or "right") side of the measure.
  5422. * Update start points (startXMin, startXMax, startYMin, startYMax)
  5423. * @private
  5424. * @param {number} dx - the amount of x translation
  5425. * @param {number} dy - the amount of y translation
  5426. * @param {number} cpIndex - index of control point
  5427. * @param {Highcharts.AnnotationDraggableValue} selectType - x / y / xy
  5428. */
  5429. Measure.prototype.resize = function (dx, dy, cpIndex, selectType) {
  5430. // background shape
  5431. var bckShape = this.shapes[2];
  5432. if (selectType === 'x') {
  5433. if (cpIndex === 0) {
  5434. bckShape.translatePoint(dx, 0, 0);
  5435. bckShape.translatePoint(dx, dy, 3);
  5436. }
  5437. else {
  5438. bckShape.translatePoint(dx, 0, 1);
  5439. bckShape.translatePoint(dx, dy, 2);
  5440. }
  5441. }
  5442. else if (selectType === 'y') {
  5443. if (cpIndex === 0) {
  5444. bckShape.translatePoint(0, dy, 0);
  5445. bckShape.translatePoint(0, dy, 1);
  5446. }
  5447. else {
  5448. bckShape.translatePoint(0, dy, 2);
  5449. bckShape.translatePoint(0, dy, 3);
  5450. }
  5451. }
  5452. else {
  5453. bckShape.translatePoint(dx, 0, 1);
  5454. bckShape.translatePoint(dx, dy, 2);
  5455. bckShape.translatePoint(0, dy, 3);
  5456. }
  5457. Measure.calculations.updateStartPoints
  5458. .call(this, false, true, cpIndex, dx, dy);
  5459. this.options.typeOptions.background.height = Math.abs(this.startYMax - this.startYMin);
  5460. this.options.typeOptions.background.width = Math.abs(this.startXMax - this.startXMin);
  5461. };
  5462. /**
  5463. * Redraw event which render elements and update start points if needed.
  5464. * @private
  5465. * @param {boolean} animation
  5466. * @param {boolean} [resize] - flag if resized
  5467. * @param {boolean} [setStartPoints] - update position of start points
  5468. */
  5469. Measure.prototype.redraw = function (animation, resize, setStartPoints) {
  5470. this.linkPoints();
  5471. if (!this.graphic) {
  5472. this.render();
  5473. }
  5474. if (setStartPoints) {
  5475. Measure.calculations.updateStartPoints.call(this, true, false);
  5476. }
  5477. // #11174 - clipBox was not recalculate during resize / redraw
  5478. if (this.clipRect) {
  5479. this.clipRect.animate(this.getClipBox());
  5480. }
  5481. this.addValues(resize);
  5482. this.addCrosshairs();
  5483. this.redrawItems(this.shapes, animation);
  5484. this.redrawItems(this.labels, animation);
  5485. // redraw control point to run positioner
  5486. this.controlPoints.forEach(function (controlPoint) {
  5487. controlPoint.redraw();
  5488. });
  5489. };
  5490. Measure.prototype.translate = function (dx, dy) {
  5491. this.shapes.forEach(function (item) {
  5492. item.translate(dx, dy);
  5493. });
  5494. this.options.typeOptions.point.x = this.startXMin;
  5495. this.options.typeOptions.point.y = this.startYMin;
  5496. };
  5497. /* *
  5498. *
  5499. * Static Functions
  5500. *
  5501. * */
  5502. Measure.calculations = {
  5503. /**
  5504. * Set starting points
  5505. * @private
  5506. */
  5507. init: function () {
  5508. var options = this.options.typeOptions,
  5509. chart = this.chart,
  5510. getPointPos = Measure.calculations.getPointPos,
  5511. inverted = chart.inverted,
  5512. xAxis = chart.xAxis[options.xAxis],
  5513. yAxis = chart.yAxis[options.yAxis],
  5514. bck = options.background,
  5515. width = inverted ? bck.height : bck.width,
  5516. height = inverted ? bck.width : bck.height,
  5517. selectType = options.selectType,
  5518. top = inverted ? xAxis.left : yAxis.top, // #13664
  5519. left = inverted ? yAxis.top : xAxis.left; // #13664
  5520. this.startXMin = options.point.x;
  5521. this.startYMin = options.point.y;
  5522. if (isNumber(width)) {
  5523. this.startXMax = this.startXMin + width;
  5524. }
  5525. else {
  5526. this.startXMax = getPointPos(xAxis, this.startXMin, parseFloat(width));
  5527. }
  5528. if (isNumber(height)) {
  5529. this.startYMax = this.startYMin - height;
  5530. }
  5531. else {
  5532. this.startYMax = getPointPos(yAxis, this.startYMin, parseFloat(height));
  5533. }
  5534. // x / y selection type
  5535. if (selectType === 'x') {
  5536. this.startYMin = yAxis.toValue(top);
  5537. this.startYMax = yAxis.toValue(top + yAxis.len);
  5538. }
  5539. else if (selectType === 'y') {
  5540. this.startXMin = xAxis.toValue(left);
  5541. this.startXMax = xAxis.toValue(left + xAxis.len);
  5542. }
  5543. },
  5544. /**
  5545. * Set current xAxisMin, xAxisMax, yAxisMin, yAxisMax.
  5546. * Calculations of measure values (min, max, average, bins).
  5547. * @private
  5548. * @param {boolean} [resize]
  5549. * Flag if shape is resized.
  5550. */
  5551. recalculate: function (resize) {
  5552. var calc = Measure.calculations,
  5553. options = this.options.typeOptions,
  5554. xAxis = this.chart.xAxis[options.xAxis],
  5555. yAxis = this.chart.yAxis[options.yAxis],
  5556. getPointPos = Measure.calculations.getPointPos,
  5557. offsetX = this.offsetX,
  5558. offsetY = this.offsetY;
  5559. this.xAxisMin = getPointPos(xAxis, this.startXMin, offsetX);
  5560. this.xAxisMax = getPointPos(xAxis, this.startXMax, offsetX);
  5561. this.yAxisMin = getPointPos(yAxis, this.startYMin, offsetY);
  5562. this.yAxisMax = getPointPos(yAxis, this.startYMax, offsetY);
  5563. this.min = calc.min.call(this);
  5564. this.max = calc.max.call(this);
  5565. this.average = calc.average.call(this);
  5566. this.bins = calc.bins.call(this);
  5567. if (resize) {
  5568. this.resize(0, 0);
  5569. }
  5570. },
  5571. /**
  5572. * Set current xAxisMin, xAxisMax, yAxisMin, yAxisMax.
  5573. * Calculations of measure values (min, max, average, bins).
  5574. * @private
  5575. * @param {Highcharts.Axis} axis
  5576. * X or y axis reference
  5577. * @param {number} value
  5578. * Point's value (x or y)
  5579. * @param {number} offset
  5580. * Amount of pixels
  5581. */
  5582. getPointPos: function (axis, value, offset) {
  5583. return axis.toValue(axis.toPixels(value) + offset);
  5584. },
  5585. /**
  5586. * Update position of start points
  5587. * (startXMin, startXMax, startYMin, startYMax)
  5588. * @private
  5589. * @param {boolean} redraw
  5590. * Flag if shape is redraw
  5591. * @param {boolean} resize
  5592. * Flag if shape is resized
  5593. * @param {number} cpIndex
  5594. * Index of controlPoint
  5595. */
  5596. updateStartPoints: function (redraw, resize, cpIndex, dx, dy) {
  5597. var options = this.options.typeOptions,
  5598. selectType = options.selectType,
  5599. xAxis = this.chart.xAxis[options.xAxis],
  5600. yAxis = this.chart.yAxis[options.yAxis],
  5601. getPointPos = Measure.calculations.getPointPos,
  5602. startXMin = this.startXMin,
  5603. startXMax = this.startXMax,
  5604. startYMin = this.startYMin,
  5605. startYMax = this.startYMax,
  5606. offsetX = this.offsetX,
  5607. offsetY = this.offsetY;
  5608. if (resize) {
  5609. if (selectType === 'x') {
  5610. if (cpIndex === 0) {
  5611. this.startXMin = getPointPos(xAxis, startXMin, dx);
  5612. }
  5613. else {
  5614. this.startXMax = getPointPos(xAxis, startXMax, dx);
  5615. }
  5616. }
  5617. else if (selectType === 'y') {
  5618. if (cpIndex === 0) {
  5619. this.startYMin = getPointPos(yAxis, startYMin, dy);
  5620. }
  5621. else {
  5622. this.startYMax = getPointPos(yAxis, startYMax, dy);
  5623. }
  5624. }
  5625. else {
  5626. this.startXMax = getPointPos(xAxis, startXMax, dx);
  5627. this.startYMax = getPointPos(yAxis, startYMax, dy);
  5628. }
  5629. }
  5630. if (redraw) {
  5631. this.startXMin = getPointPos(xAxis, startXMin, offsetX);
  5632. this.startXMax = getPointPos(xAxis, startXMax, offsetX);
  5633. this.startYMin = getPointPos(yAxis, startYMin, offsetY);
  5634. this.startYMax = getPointPos(yAxis, startYMax, offsetY);
  5635. this.offsetX = 0;
  5636. this.offsetY = 0;
  5637. }
  5638. },
  5639. /**
  5640. * Default formatter of label's content
  5641. * @private
  5642. */
  5643. defaultFormatter: function () {
  5644. return 'Min: ' + this.min +
  5645. '<br>Max: ' + this.max +
  5646. '<br>Average: ' + this.average +
  5647. '<br>Bins: ' + this.bins;
  5648. },
  5649. /**
  5650. * Set values for xAxisMin, xAxisMax, yAxisMin, yAxisMax, also
  5651. * when chart is inverted
  5652. * @private
  5653. */
  5654. getExtremes: function (xAxisMin, xAxisMax, yAxisMin, yAxisMax) {
  5655. return {
  5656. xAxisMin: Math.min(xAxisMax, xAxisMin),
  5657. xAxisMax: Math.max(xAxisMax, xAxisMin),
  5658. yAxisMin: Math.min(yAxisMax, yAxisMin),
  5659. yAxisMax: Math.max(yAxisMax, yAxisMin)
  5660. };
  5661. },
  5662. /**
  5663. * Definitions of calculations (min, max, average, bins)
  5664. * @private
  5665. */
  5666. min: function () {
  5667. var min = Infinity,
  5668. series = this.chart.series,
  5669. ext = Measure.calculations.getExtremes(this.xAxisMin,
  5670. this.xAxisMax,
  5671. this.yAxisMin,
  5672. this.yAxisMax),
  5673. isCalculated = false; // to avoid Infinity in formatter
  5674. series.forEach(function (serie) {
  5675. if (serie.visible &&
  5676. serie.options.id !== 'highcharts-navigator-series') {
  5677. serie.points.forEach(function (point) {
  5678. if (!point.isNull &&
  5679. point.y < min &&
  5680. point.x > ext.xAxisMin &&
  5681. point.x <= ext.xAxisMax &&
  5682. point.y > ext.yAxisMin &&
  5683. point.y <= ext.yAxisMax) {
  5684. min = point.y;
  5685. isCalculated = true;
  5686. }
  5687. });
  5688. }
  5689. });
  5690. if (!isCalculated) {
  5691. min = '';
  5692. }
  5693. return min;
  5694. },
  5695. max: function () {
  5696. var max = -Infinity,
  5697. series = this.chart.series,
  5698. ext = Measure.calculations.getExtremes(this.xAxisMin,
  5699. this.xAxisMax,
  5700. this.yAxisMin,
  5701. this.yAxisMax),
  5702. isCalculated = false; // to avoid Infinity in formatter
  5703. series.forEach(function (serie) {
  5704. if (serie.visible &&
  5705. serie.options.id !== 'highcharts-navigator-series') {
  5706. serie.points.forEach(function (point) {
  5707. if (!point.isNull &&
  5708. point.y > max &&
  5709. point.x > ext.xAxisMin &&
  5710. point.x <= ext.xAxisMax &&
  5711. point.y > ext.yAxisMin &&
  5712. point.y <= ext.yAxisMax) {
  5713. max = point.y;
  5714. isCalculated = true;
  5715. }
  5716. });
  5717. }
  5718. });
  5719. if (!isCalculated) {
  5720. max = '';
  5721. }
  5722. return max;
  5723. },
  5724. average: function () {
  5725. var average = '';
  5726. if (this.max !== '' && this.min !== '') {
  5727. average = (this.max + this.min) / 2;
  5728. }
  5729. return average;
  5730. },
  5731. bins: function () {
  5732. var bins = 0,
  5733. series = this.chart.series,
  5734. ext = Measure.calculations.getExtremes(this.xAxisMin,
  5735. this.xAxisMax,
  5736. this.yAxisMin,
  5737. this.yAxisMax),
  5738. isCalculated = false; // to avoid Infinity in formatter
  5739. series.forEach(function (serie) {
  5740. if (serie.visible &&
  5741. serie.options.id !== 'highcharts-navigator-series') {
  5742. serie.points.forEach(function (point) {
  5743. if (!point.isNull &&
  5744. point.x > ext.xAxisMin &&
  5745. point.x <= ext.xAxisMax &&
  5746. point.y > ext.yAxisMin &&
  5747. point.y <= ext.yAxisMax) {
  5748. bins++;
  5749. isCalculated = true;
  5750. }
  5751. });
  5752. }
  5753. });
  5754. if (!isCalculated) {
  5755. bins = '';
  5756. }
  5757. return bins;
  5758. }
  5759. };
  5760. return Measure;
  5761. }(Annotation));
  5762. Measure.prototype.defaultOptions = merge(Annotation.prototype.defaultOptions,
  5763. /**
  5764. * A measure annotation.
  5765. *
  5766. * @extends annotations.crookedLine
  5767. * @excluding labels, labelOptions, shapes, shapeOptions
  5768. * @sample highcharts/annotations-advanced/measure/
  5769. * Measure
  5770. * @product highstock
  5771. * @optionparent annotations.measure
  5772. */
  5773. {
  5774. typeOptions: {
  5775. /**
  5776. * Decides in what dimensions the user can resize by dragging the
  5777. * mouse. Can be one of x, y or xy.
  5778. */
  5779. selectType: 'xy',
  5780. /**
  5781. * This number defines which xAxis the point is connected to.
  5782. * It refers to either the axis id or the index of the axis
  5783. * in the xAxis array.
  5784. */
  5785. xAxis: 0,
  5786. /**
  5787. * This number defines which yAxis the point is connected to.
  5788. * It refers to either the axis id or the index of the axis
  5789. * in the yAxis array.
  5790. */
  5791. yAxis: 0,
  5792. background: {
  5793. /**
  5794. * The color of the rectangle.
  5795. */
  5796. fill: 'rgba(130, 170, 255, 0.4)',
  5797. /**
  5798. * The width of border.
  5799. */
  5800. strokeWidth: 0,
  5801. /**
  5802. * The color of border.
  5803. */
  5804. stroke: void 0
  5805. },
  5806. /**
  5807. * Configure a crosshair that is horizontally placed in middle of
  5808. * rectangle.
  5809. *
  5810. */
  5811. crosshairX: {
  5812. /**
  5813. * Enable or disable the horizontal crosshair.
  5814. *
  5815. */
  5816. enabled: true,
  5817. /**
  5818. * The Z index of the crosshair in annotation.
  5819. */
  5820. zIndex: 6,
  5821. /**
  5822. * The dash or dot style of the crosshair's line. For possible
  5823. * values, see
  5824. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  5825. *
  5826. * @type {Highcharts.DashStyleValue}
  5827. * @default Dash
  5828. */
  5829. dashStyle: 'Dash',
  5830. /**
  5831. * The marker-end defines the arrowhead that will be drawn
  5832. * at the final vertex of the given crosshair's path.
  5833. *
  5834. * @type {string}
  5835. * @default arrow
  5836. */
  5837. markerEnd: 'arrow'
  5838. },
  5839. /**
  5840. * Configure a crosshair that is vertically placed in middle of
  5841. * rectangle.
  5842. */
  5843. crosshairY: {
  5844. /**
  5845. * Enable or disable the vertical crosshair.
  5846. *
  5847. */
  5848. enabled: true,
  5849. /**
  5850. * The Z index of the crosshair in annotation.
  5851. */
  5852. zIndex: 6,
  5853. /**
  5854. * The dash or dot style of the crosshair's line. For possible
  5855. * values, see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  5856. *
  5857. * @type {Highcharts.DashStyleValue}
  5858. * @default Dash
  5859. * @apioption annotations.measure.typeOptions.crosshairY.dashStyle
  5860. *
  5861. */
  5862. dashStyle: 'Dash',
  5863. /**
  5864. * The marker-end defines the arrowhead that will be drawn
  5865. * at the final vertex of the given crosshair's path.
  5866. *
  5867. * @type {string}
  5868. * @default arrow
  5869. * @validvalue ["none", "arrow"]
  5870. *
  5871. */
  5872. markerEnd: 'arrow'
  5873. },
  5874. label: {
  5875. /**
  5876. * Enable or disable the label text (min, max, average,
  5877. * bins values).
  5878. *
  5879. * Defaults to true.
  5880. */
  5881. enabled: true,
  5882. /**
  5883. * CSS styles for the measure label.
  5884. *
  5885. * @type {Highcharts.CSSObject}
  5886. * @default {"color": "#666666", "fontSize": "11px"}
  5887. */
  5888. style: {
  5889. fontSize: '11px',
  5890. color: '#666666'
  5891. },
  5892. /**
  5893. * Formatter function for the label text.
  5894. *
  5895. * Available data are:
  5896. *
  5897. * <table>
  5898. *
  5899. * <tbody>
  5900. *
  5901. * <tr>
  5902. *
  5903. * <td>`this.min`</td>
  5904. *
  5905. * <td>The mininimum value of the points in the selected
  5906. * range.</td>
  5907. *
  5908. * </tr>
  5909. *
  5910. * <tr>
  5911. *
  5912. * <td>`this.max`</td>
  5913. *
  5914. * <td>The maximum value of the points in the selected
  5915. * range.</td>
  5916. *
  5917. * </tr>
  5918. *
  5919. * <tr>
  5920. *
  5921. * <td>`this.average`</td>
  5922. *
  5923. * <td>The average value of the points in the selected
  5924. * range.</td>
  5925. *
  5926. * </tr>
  5927. *
  5928. * <tr>
  5929. *
  5930. * <td>`this.bins`</td>
  5931. *
  5932. * <td>The amount of the points in the selected range.</td>
  5933. *
  5934. * </tr>
  5935. *
  5936. * </table>
  5937. *
  5938. * @type {function}
  5939. *
  5940. */
  5941. formatter: void 0
  5942. }
  5943. },
  5944. controlPointOptions: {
  5945. positioner: function (target) {
  5946. var cpIndex = this.index,
  5947. chart = target.chart,
  5948. options = target.options,
  5949. typeOptions = options.typeOptions,
  5950. selectType = typeOptions.selectType,
  5951. controlPointOptions = options.controlPointOptions,
  5952. inverted = chart.inverted,
  5953. xAxis = chart.xAxis[typeOptions.xAxis],
  5954. yAxis = chart.yAxis[typeOptions.yAxis],
  5955. targetX = target.xAxisMax,
  5956. targetY = target.yAxisMax,
  5957. ext = Measure.calculations.getExtremes(target.xAxisMin,
  5958. target.xAxisMax,
  5959. target.yAxisMin,
  5960. target.yAxisMax),
  5961. x,
  5962. y;
  5963. if (selectType === 'x') {
  5964. targetY = (ext.yAxisMax - ext.yAxisMin) / 2;
  5965. // first control point
  5966. if (cpIndex === 0) {
  5967. targetX = target.xAxisMin;
  5968. }
  5969. }
  5970. if (selectType === 'y') {
  5971. targetX = ext.xAxisMin +
  5972. ((ext.xAxisMax - ext.xAxisMin) / 2);
  5973. // first control point
  5974. if (cpIndex === 0) {
  5975. targetY = target.yAxisMin;
  5976. }
  5977. }
  5978. if (inverted) {
  5979. x = yAxis.toPixels(targetY);
  5980. y = xAxis.toPixels(targetX);
  5981. }
  5982. else {
  5983. x = xAxis.toPixels(targetX);
  5984. y = yAxis.toPixels(targetY);
  5985. }
  5986. return {
  5987. x: x - (controlPointOptions.width / 2),
  5988. y: y - (controlPointOptions.height / 2)
  5989. };
  5990. },
  5991. events: {
  5992. drag: function (e, target) {
  5993. var translation = this.mouseMoveToTranslation(e), selectType = target.options.typeOptions.selectType, index = this.index, x = selectType === 'y' ? 0 : translation.x, y = selectType === 'x' ? 0 : translation.y;
  5994. target.resize(x, y, index, selectType);
  5995. target.resizeX += x;
  5996. target.resizeY += y;
  5997. target.redraw(false, true);
  5998. }
  5999. }
  6000. }
  6001. });
  6002. Annotation.types.measure = Measure;
  6003. return Measure;
  6004. });
  6005. _registerModule(_modules, 'Mixins/Navigation.js', [], function () {
  6006. /**
  6007. *
  6008. * (c) 2010-2021 Paweł Fus
  6009. *
  6010. * License: www.highcharts.com/license
  6011. *
  6012. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6013. *
  6014. * */
  6015. var chartNavigation = {
  6016. /**
  6017. * Initializes `chart.navigation` object which delegates `update()` methods
  6018. * to all other common classes (used in exporting and navigationBindings).
  6019. *
  6020. * @private
  6021. * @param {Highcharts.Chart} chart
  6022. * The chart instance.
  6023. * @return {void}
  6024. */
  6025. initUpdate: function (chart) {
  6026. if (!chart.navigation) {
  6027. chart.navigation = {
  6028. updates: [],
  6029. update: function (options,
  6030. redraw) {
  6031. this.updates.forEach(function (updateConfig) {
  6032. updateConfig.update.call(updateConfig.context,
  6033. options,
  6034. redraw);
  6035. });
  6036. }
  6037. };
  6038. }
  6039. },
  6040. /**
  6041. * Registers an `update()` method in the `chart.navigation` object.
  6042. *
  6043. * @private
  6044. * @param {Highcharts.ChartNavigationUpdateFunction} update
  6045. * The `update()` method that will be called in `chart.update()`.
  6046. * @param {Highcharts.Chart} chart
  6047. * The chart instance. `update()` will use that as a context
  6048. * (`this`).
  6049. * @return {void}
  6050. */
  6051. addUpdate: function (update, chart) {
  6052. if (!chart.navigation) {
  6053. this.initUpdate(chart);
  6054. }
  6055. chart.navigation.updates.push({
  6056. update: update,
  6057. context: chart
  6058. });
  6059. }
  6060. };
  6061. return chartNavigation;
  6062. });
  6063. _registerModule(_modules, 'Extensions/Annotations/NavigationBindings.js', [_modules['Extensions/Annotations/Annotations.js'], _modules['Core/Chart/Chart.js'], _modules['Mixins/Navigation.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Annotation, Chart, chartNavigationMixin, H, U) {
  6064. /* *
  6065. *
  6066. * (c) 2009-2021 Highsoft, Black Label
  6067. *
  6068. * License: www.highcharts.com/license
  6069. *
  6070. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6071. *
  6072. * */
  6073. var addEvent = U.addEvent,
  6074. attr = U.attr,
  6075. extend = U.extend,
  6076. format = U.format,
  6077. fireEvent = U.fireEvent,
  6078. isArray = U.isArray,
  6079. isFunction = U.isFunction,
  6080. isNumber = U.isNumber,
  6081. isObject = U.isObject,
  6082. merge = U.merge,
  6083. objectEach = U.objectEach,
  6084. pick = U.pick,
  6085. setOptions = U.setOptions;
  6086. /**
  6087. * A config object for navigation bindings in annotations.
  6088. *
  6089. * @interface Highcharts.NavigationBindingsOptionsObject
  6090. */ /**
  6091. * ClassName of the element for a binding.
  6092. * @name Highcharts.NavigationBindingsOptionsObject#className
  6093. * @type {string|undefined}
  6094. */ /**
  6095. * Last event to be fired after last step event.
  6096. * @name Highcharts.NavigationBindingsOptionsObject#end
  6097. * @type {Function|undefined}
  6098. */ /**
  6099. * Initial event, fired on a button click.
  6100. * @name Highcharts.NavigationBindingsOptionsObject#init
  6101. * @type {Function|undefined}
  6102. */ /**
  6103. * Event fired on first click on a chart.
  6104. * @name Highcharts.NavigationBindingsOptionsObject#start
  6105. * @type {Function|undefined}
  6106. */ /**
  6107. * Last event to be fired after last step event. Array of step events to be
  6108. * called sequentially after each user click.
  6109. * @name Highcharts.NavigationBindingsOptionsObject#steps
  6110. * @type {Array<Function>|undefined}
  6111. */
  6112. var doc = H.doc,
  6113. win = H.win,
  6114. PREFIX = 'highcharts-';
  6115. /* eslint-disable no-invalid-this, valid-jsdoc */
  6116. /**
  6117. * IE 9-11 polyfill for Element.closest():
  6118. * @private
  6119. */
  6120. function closestPolyfill(el, s) {
  6121. var ElementProto = win.Element.prototype,
  6122. elementMatches = ElementProto.matches ||
  6123. ElementProto.msMatchesSelector ||
  6124. ElementProto.webkitMatchesSelector,
  6125. ret = null;
  6126. if (ElementProto.closest) {
  6127. ret = ElementProto.closest.call(el, s);
  6128. }
  6129. else {
  6130. do {
  6131. if (elementMatches.call(el, s)) {
  6132. return el;
  6133. }
  6134. el = el.parentElement || el.parentNode;
  6135. } while (el !== null && el.nodeType === 1);
  6136. }
  6137. return ret;
  6138. }
  6139. /**
  6140. * @private
  6141. * @interface bindingsUtils
  6142. */
  6143. var bindingsUtils = {
  6144. /**
  6145. * Update size of background (rect) in some annotations: Measure,
  6146. Simple
  6147. * Rect.
  6148. *
  6149. * @private
  6150. * @function Highcharts.NavigationBindingsUtilsObject.updateRectSize
  6151. *
  6152. * @param {Highcharts.PointerEventObject} event
  6153. * Normalized browser event
  6154. *
  6155. * @param {Highcharts.Annotation} annotation
  6156. * Annotation to be updated
  6157. */
  6158. updateRectSize: function (event,
  6159. annotation) {
  6160. var chart = annotation.chart,
  6161. options = annotation.options.typeOptions,
  6162. coords = chart.pointer.getCoordinates(event),
  6163. width = coords.xAxis[0].value - options.point.x,
  6164. height = options.point.y - coords.yAxis[0].value;
  6165. annotation.update({
  6166. typeOptions: {
  6167. background: {
  6168. width: chart.inverted ? height : width,
  6169. height: chart.inverted ? width : height
  6170. }
  6171. }
  6172. });
  6173. },
  6174. /**
  6175. * Get field type according to value
  6176. *
  6177. * @private
  6178. * @function Highcharts.NavigationBindingsUtilsObject.getFieldType
  6179. *
  6180. * @param {'boolean'|'number'|'string'} value
  6181. * Atomic type (one of: string, number, boolean)
  6182. *
  6183. * @return {'checkbox'|'number'|'text'}
  6184. * Field type (one of: text, number, checkbox)
  6185. */
  6186. getFieldType: function (value) {
  6187. return {
  6188. 'string': 'text',
  6189. 'number': 'number',
  6190. 'boolean': 'checkbox'
  6191. }[typeof value];
  6192. }
  6193. };
  6194. /**
  6195. * @private
  6196. */
  6197. var NavigationBindings = /** @class */ (function () {
  6198. /* *
  6199. *
  6200. * Constructors
  6201. *
  6202. * */
  6203. function NavigationBindings(chart, options) {
  6204. this.boundClassNames = void 0;
  6205. this.selectedButton = void 0;
  6206. this.chart = chart;
  6207. this.options = options;
  6208. this.eventsToUnbind = [];
  6209. this.container = doc.getElementsByClassName(this.options.bindingsClassName || '');
  6210. }
  6211. // Private properties added by bindings:
  6212. // Active (selected) annotation that is editted through popup/forms
  6213. // activeAnnotation: Annotation
  6214. // Holder for current step, used on mouse move to update bound object
  6215. // mouseMoveEvent: function () {}
  6216. // Next event in `step` array to be called on chart's click
  6217. // nextEvent: function () {}
  6218. // Index in the `step` array of the current event
  6219. // stepIndex: 0
  6220. // Flag to determine if current binding has steps
  6221. // steps: true|false
  6222. // Bindings holder for all events
  6223. // selectedButton: {}
  6224. // Holder for user options, returned from `start` event, and passed on to
  6225. // `step`'s' and `end`.
  6226. // currentUserDetails: {}
  6227. /* *
  6228. *
  6229. * Functions
  6230. *
  6231. * */
  6232. /**
  6233. * Initi all events conencted to NavigationBindings.
  6234. *
  6235. * @private
  6236. * @function Highcharts.NavigationBindings#initEvents
  6237. */
  6238. NavigationBindings.prototype.initEvents = function () {
  6239. var navigation = this,
  6240. chart = navigation.chart,
  6241. bindingsContainer = navigation.container,
  6242. options = navigation.options;
  6243. // Shorthand object for getting events for buttons:
  6244. navigation.boundClassNames = {};
  6245. objectEach((options.bindings || {}), function (value) {
  6246. navigation.boundClassNames[value.className] = value;
  6247. });
  6248. // Handle multiple containers with the same class names:
  6249. [].forEach.call(bindingsContainer, function (subContainer) {
  6250. navigation.eventsToUnbind.push(addEvent(subContainer, 'click', function (event) {
  6251. var bindings = navigation.getButtonEvents(subContainer,
  6252. event);
  6253. if (bindings) {
  6254. navigation.bindingsButtonClick(bindings.button, bindings.events, event);
  6255. }
  6256. }));
  6257. });
  6258. objectEach(options.events || {}, function (callback, eventName) {
  6259. if (isFunction(callback)) {
  6260. navigation.eventsToUnbind.push(addEvent(navigation, eventName, callback, { passive: false }));
  6261. }
  6262. });
  6263. navigation.eventsToUnbind.push(addEvent(chart.container, 'click', function (e) {
  6264. if (!chart.cancelClick &&
  6265. chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
  6266. navigation.bindingsChartClick(this, e);
  6267. }
  6268. }));
  6269. navigation.eventsToUnbind.push(addEvent(chart.container, H.isTouchDevice ? 'touchmove' : 'mousemove', function (e) {
  6270. navigation.bindingsContainerMouseMove(this, e);
  6271. }, H.isTouchDevice ? { passive: false } : void 0));
  6272. };
  6273. /**
  6274. * Common chart.update() delegation, shared between bindings and exporting.
  6275. *
  6276. * @private
  6277. * @function Highcharts.NavigationBindings#initUpdate
  6278. */
  6279. NavigationBindings.prototype.initUpdate = function () {
  6280. var navigation = this;
  6281. chartNavigationMixin.addUpdate(function (options) {
  6282. navigation.update(options);
  6283. }, this.chart);
  6284. };
  6285. /**
  6286. * Hook for click on a button, method selcts/unselects buttons,
  6287. * then calls `bindings.init` callback.
  6288. *
  6289. * @private
  6290. * @function Highcharts.NavigationBindings#bindingsButtonClick
  6291. *
  6292. * @param {Highcharts.HTMLDOMElement} [button]
  6293. * Clicked button
  6294. *
  6295. * @param {object} events
  6296. * Events passed down from bindings (`init`, `start`, `step`, `end`)
  6297. *
  6298. * @param {Highcharts.PointerEventObject} clickEvent
  6299. * Browser's click event
  6300. */
  6301. NavigationBindings.prototype.bindingsButtonClick = function (button, events, clickEvent) {
  6302. var navigation = this,
  6303. chart = navigation.chart;
  6304. if (navigation.selectedButtonElement) {
  6305. fireEvent(navigation, 'deselectButton', { button: navigation.selectedButtonElement });
  6306. if (navigation.nextEvent) {
  6307. // Remove in-progress annotations adders:
  6308. if (navigation.currentUserDetails &&
  6309. navigation.currentUserDetails.coll === 'annotations') {
  6310. chart.removeAnnotation(navigation.currentUserDetails);
  6311. }
  6312. navigation.mouseMoveEvent = navigation.nextEvent = false;
  6313. }
  6314. }
  6315. navigation.selectedButton = events;
  6316. navigation.selectedButtonElement = button;
  6317. fireEvent(navigation, 'selectButton', { button: button });
  6318. // Call "init" event, for example to open modal window
  6319. if (events.init) {
  6320. events.init.call(navigation, button, clickEvent);
  6321. }
  6322. if (events.start || events.steps) {
  6323. chart.renderer.boxWrapper.addClass(PREFIX + 'draw-mode');
  6324. }
  6325. };
  6326. /**
  6327. * Hook for click on a chart, first click on a chart calls `start` event,
  6328. * then on all subsequent clicks iterate over `steps` array.
  6329. * When finished, calls `end` event.
  6330. *
  6331. * @private
  6332. * @function Highcharts.NavigationBindings#bindingsChartClick
  6333. *
  6334. * @param {Highcharts.Chart} chart
  6335. * Chart that click was performed on.
  6336. *
  6337. * @param {Highcharts.PointerEventObject} clickEvent
  6338. * Browser's click event.
  6339. */
  6340. NavigationBindings.prototype.bindingsChartClick = function (chart, clickEvent) {
  6341. var navigation = this,
  6342. chart = navigation.chart,
  6343. selectedButton = navigation.selectedButton,
  6344. svgContainer = chart.renderer.boxWrapper;
  6345. // Click outside popups, should close them and deselect the annotation
  6346. if (navigation.activeAnnotation &&
  6347. !clickEvent.activeAnnotation &&
  6348. // Element could be removed in the child action, e.g. button
  6349. clickEvent.target.parentNode &&
  6350. // TO DO: Polyfill for IE11?
  6351. !closestPolyfill(clickEvent.target, '.' + PREFIX + 'popup')) {
  6352. fireEvent(navigation, 'closePopup');
  6353. }
  6354. if (!selectedButton || !selectedButton.start) {
  6355. return;
  6356. }
  6357. if (!navigation.nextEvent) {
  6358. // Call init method:
  6359. navigation.currentUserDetails = selectedButton.start.call(navigation, clickEvent);
  6360. // If steps exists (e.g. Annotations), bind them:
  6361. if (selectedButton.steps) {
  6362. navigation.stepIndex = 0;
  6363. navigation.steps = true;
  6364. navigation.mouseMoveEvent = navigation.nextEvent =
  6365. selectedButton.steps[navigation.stepIndex];
  6366. }
  6367. else {
  6368. fireEvent(navigation, 'deselectButton', { button: navigation.selectedButtonElement });
  6369. svgContainer.removeClass(PREFIX + 'draw-mode');
  6370. navigation.steps = false;
  6371. navigation.selectedButton = null;
  6372. // First click is also the last one:
  6373. if (selectedButton.end) {
  6374. selectedButton.end.call(navigation, clickEvent, navigation.currentUserDetails);
  6375. }
  6376. }
  6377. }
  6378. else {
  6379. navigation.nextEvent(clickEvent, navigation.currentUserDetails);
  6380. if (navigation.steps) {
  6381. navigation.stepIndex++;
  6382. if (selectedButton.steps[navigation.stepIndex]) {
  6383. // If we have more steps, bind them one by one:
  6384. navigation.mouseMoveEvent = navigation.nextEvent =
  6385. selectedButton.steps[navigation.stepIndex];
  6386. }
  6387. else {
  6388. fireEvent(navigation, 'deselectButton', { button: navigation.selectedButtonElement });
  6389. svgContainer.removeClass(PREFIX + 'draw-mode');
  6390. // That was the last step, call end():
  6391. if (selectedButton.end) {
  6392. selectedButton.end.call(navigation, clickEvent, navigation.currentUserDetails);
  6393. }
  6394. navigation.nextEvent = false;
  6395. navigation.mouseMoveEvent = false;
  6396. navigation.selectedButton = null;
  6397. }
  6398. }
  6399. }
  6400. };
  6401. /**
  6402. * Hook for mouse move on a chart's container. It calls current step.
  6403. *
  6404. * @private
  6405. * @function Highcharts.NavigationBindings#bindingsContainerMouseMove
  6406. *
  6407. * @param {Highcharts.HTMLDOMElement} container
  6408. * Chart's container.
  6409. *
  6410. * @param {global.Event} moveEvent
  6411. * Browser's move event.
  6412. */
  6413. NavigationBindings.prototype.bindingsContainerMouseMove = function (_container, moveEvent) {
  6414. if (this.mouseMoveEvent) {
  6415. this.mouseMoveEvent(moveEvent, this.currentUserDetails);
  6416. }
  6417. };
  6418. /**
  6419. * Translate fields (e.g. `params.period` or `marker.styles.color`) to
  6420. * Highcharts options object (e.g. `{ params: { period } }`).
  6421. *
  6422. * @private
  6423. * @function Highcharts.NavigationBindings#fieldsToOptions<T>
  6424. *
  6425. * @param {Highcharts.Dictionary<string>} fields
  6426. * Fields from popup form.
  6427. *
  6428. * @param {T} config
  6429. * Default config to be modified.
  6430. *
  6431. * @return {T}
  6432. * Modified config
  6433. */
  6434. NavigationBindings.prototype.fieldsToOptions = function (fields, config) {
  6435. objectEach(fields, function (value, field) {
  6436. var parsedValue = parseFloat(value),
  6437. path = field.split('.'),
  6438. parent = config,
  6439. pathLength = path.length - 1;
  6440. // If it's a number (not "format" options), parse it:
  6441. if (isNumber(parsedValue) &&
  6442. !value.match(/px/g) &&
  6443. !field.match(/format/g)) {
  6444. value = parsedValue;
  6445. }
  6446. // Remove empty strings or values like 0
  6447. if (value !== '' && value !== 'undefined') {
  6448. path.forEach(function (name, index) {
  6449. var nextName = pick(path[index + 1], '');
  6450. if (pathLength === index) {
  6451. // Last index, put value:
  6452. parent[name] = value;
  6453. }
  6454. else if (!parent[name]) {
  6455. // Create middle property:
  6456. parent[name] = nextName.match(/\d/g) ? [] : {};
  6457. parent = parent[name];
  6458. }
  6459. else {
  6460. // Jump into next property
  6461. parent = parent[name];
  6462. }
  6463. });
  6464. }
  6465. });
  6466. return config;
  6467. };
  6468. /**
  6469. * Shorthand method to deselect an annotation.
  6470. *
  6471. * @function Highcharts.NavigationBindings#deselectAnnotation
  6472. */
  6473. NavigationBindings.prototype.deselectAnnotation = function () {
  6474. if (this.activeAnnotation) {
  6475. this.activeAnnotation.setControlPointsVisibility(false);
  6476. this.activeAnnotation = false;
  6477. }
  6478. };
  6479. /**
  6480. * Generates API config for popup in the same format as options for
  6481. * Annotation object.
  6482. *
  6483. * @function Highcharts.NavigationBindings#annotationToFields
  6484. *
  6485. * @param {Highcharts.Annotation} annotation
  6486. * Annotations object
  6487. *
  6488. * @return {Highcharts.Dictionary<string>}
  6489. * Annotation options to be displayed in popup box
  6490. */
  6491. NavigationBindings.prototype.annotationToFields = function (annotation) {
  6492. var options = annotation.options,
  6493. editables = NavigationBindings.annotationsEditable,
  6494. nestedEditables = editables.nestedOptions,
  6495. getFieldType = this.utils.getFieldType,
  6496. type = pick(options.type,
  6497. options.shapes && options.shapes[0] &&
  6498. options.shapes[0].type,
  6499. options.labels && options.labels[0] &&
  6500. options.labels[0].itemType, 'label'),
  6501. nonEditables = NavigationBindings.annotationsNonEditable[options.langKey] || [],
  6502. visualOptions = {
  6503. langKey: options.langKey,
  6504. type: type
  6505. };
  6506. /**
  6507. * Nested options traversing. Method goes down to the options and copies
  6508. * allowed options (with values) to new object, which is last parameter:
  6509. * "parent".
  6510. *
  6511. * @private
  6512. *
  6513. * @param {*} option
  6514. * Atomic type or object/array
  6515. *
  6516. * @param {string} key
  6517. * Option name, for example "visible" or "x", "y"
  6518. *
  6519. * @param {object} parentEditables
  6520. * Editables from NavigationBindings.annotationsEditable
  6521. *
  6522. * @param {object} parent
  6523. * Where new options will be assigned
  6524. */
  6525. function traverse(option, key, parentEditables, parent) {
  6526. var nextParent;
  6527. if (parentEditables &&
  6528. option &&
  6529. nonEditables.indexOf(key) === -1 &&
  6530. ((parentEditables.indexOf &&
  6531. parentEditables.indexOf(key)) >= 0 ||
  6532. parentEditables[key] || // nested array
  6533. parentEditables === true // simple array
  6534. )) {
  6535. // Roots:
  6536. if (isArray(option)) {
  6537. parent[key] = [];
  6538. option.forEach(function (arrayOption, i) {
  6539. if (!isObject(arrayOption)) {
  6540. // Simple arrays, e.g. [String, Number, Boolean]
  6541. traverse(arrayOption, 0, nestedEditables[key], parent[key]);
  6542. }
  6543. else {
  6544. // Advanced arrays, e.g. [Object, Object]
  6545. parent[key][i] = {};
  6546. objectEach(arrayOption, function (nestedOption, nestedKey) {
  6547. traverse(nestedOption, nestedKey, nestedEditables[key], parent[key][i]);
  6548. });
  6549. }
  6550. });
  6551. }
  6552. else if (isObject(option)) {
  6553. nextParent = {};
  6554. if (isArray(parent)) {
  6555. parent.push(nextParent);
  6556. nextParent[key] = {};
  6557. nextParent = nextParent[key];
  6558. }
  6559. else {
  6560. parent[key] = nextParent;
  6561. }
  6562. objectEach(option, function (nestedOption, nestedKey) {
  6563. traverse(nestedOption, nestedKey, key === 0 ? parentEditables : nestedEditables[key], nextParent);
  6564. });
  6565. }
  6566. else {
  6567. // Leaf:
  6568. if (key === 'format') {
  6569. parent[key] = [
  6570. format(option, annotation.labels[0].points[0]).toString(),
  6571. 'text'
  6572. ];
  6573. }
  6574. else if (isArray(parent)) {
  6575. parent.push([option, getFieldType(option)]);
  6576. }
  6577. else {
  6578. parent[key] = [option, getFieldType(option)];
  6579. }
  6580. }
  6581. }
  6582. }
  6583. objectEach(options, function (option, key) {
  6584. if (key === 'typeOptions') {
  6585. visualOptions[key] = {};
  6586. objectEach(options[key], function (typeOption, typeKey) {
  6587. traverse(typeOption, typeKey, nestedEditables, visualOptions[key], true);
  6588. });
  6589. }
  6590. else {
  6591. traverse(option, key, editables[type], visualOptions);
  6592. }
  6593. });
  6594. return visualOptions;
  6595. };
  6596. /**
  6597. * Get all class names for all parents in the element. Iterates until finds
  6598. * main container.
  6599. *
  6600. * @function Highcharts.NavigationBindings#getClickedClassNames
  6601. *
  6602. * @param {Highcharts.HTMLDOMElement}
  6603. * Container that event is bound to.
  6604. *
  6605. * @param {global.Event} event
  6606. * Browser's event.
  6607. *
  6608. * @return {Array<Array<string, Highcharts.HTMLDOMElement>>}
  6609. * Array of class names with corresponding elements
  6610. */
  6611. NavigationBindings.prototype.getClickedClassNames = function (container, event) {
  6612. var element = event.target,
  6613. classNames = [],
  6614. elemClassName;
  6615. while (element) {
  6616. elemClassName = attr(element, 'class');
  6617. if (elemClassName) {
  6618. classNames = classNames.concat(elemClassName
  6619. .split(' ')
  6620. .map(function (name) {
  6621. return [
  6622. name,
  6623. element
  6624. ];
  6625. }));
  6626. }
  6627. element = element.parentNode;
  6628. if (element === container) {
  6629. return classNames;
  6630. }
  6631. }
  6632. return classNames;
  6633. };
  6634. /**
  6635. * Get events bound to a button. It's a custom event delegation to find all
  6636. * events connected to the element.
  6637. *
  6638. * @private
  6639. * @function Highcharts.NavigationBindings#getButtonEvents
  6640. *
  6641. * @param {Highcharts.HTMLDOMElement} container
  6642. * Container that event is bound to.
  6643. *
  6644. * @param {global.Event} event
  6645. * Browser's event.
  6646. *
  6647. * @return {object}
  6648. * Object with events (init, start, steps, and end)
  6649. */
  6650. NavigationBindings.prototype.getButtonEvents = function (container, event) {
  6651. var navigation = this,
  6652. classNames = this.getClickedClassNames(container,
  6653. event),
  6654. bindings;
  6655. classNames.forEach(function (className) {
  6656. if (navigation.boundClassNames[className[0]] && !bindings) {
  6657. bindings = {
  6658. events: navigation.boundClassNames[className[0]],
  6659. button: className[1]
  6660. };
  6661. }
  6662. });
  6663. return bindings;
  6664. };
  6665. /**
  6666. * Bindings are just events, so the whole update process is simply
  6667. * removing old events and adding new ones.
  6668. *
  6669. * @private
  6670. * @function Highcharts.NavigationBindings#update
  6671. */
  6672. NavigationBindings.prototype.update = function (options) {
  6673. this.options = merge(true, this.options, options);
  6674. this.removeEvents();
  6675. this.initEvents();
  6676. };
  6677. /**
  6678. * Remove all events created in the navigation.
  6679. *
  6680. * @private
  6681. * @function Highcharts.NavigationBindings#removeEvents
  6682. */
  6683. NavigationBindings.prototype.removeEvents = function () {
  6684. this.eventsToUnbind.forEach(function (unbinder) {
  6685. unbinder();
  6686. });
  6687. };
  6688. NavigationBindings.prototype.destroy = function () {
  6689. this.removeEvents();
  6690. };
  6691. /* *
  6692. *
  6693. * Static Properties
  6694. *
  6695. * */
  6696. // Define which options from annotations should show up in edit box:
  6697. NavigationBindings.annotationsEditable = {
  6698. // `typeOptions` are always available
  6699. // Nested and shared options:
  6700. nestedOptions: {
  6701. labelOptions: ['style', 'format', 'backgroundColor'],
  6702. labels: ['style'],
  6703. label: ['style'],
  6704. style: ['fontSize', 'color'],
  6705. background: ['fill', 'strokeWidth', 'stroke'],
  6706. innerBackground: ['fill', 'strokeWidth', 'stroke'],
  6707. outerBackground: ['fill', 'strokeWidth', 'stroke'],
  6708. shapeOptions: ['fill', 'strokeWidth', 'stroke'],
  6709. shapes: ['fill', 'strokeWidth', 'stroke'],
  6710. line: ['strokeWidth', 'stroke'],
  6711. backgroundColors: [true],
  6712. connector: ['fill', 'strokeWidth', 'stroke'],
  6713. crosshairX: ['strokeWidth', 'stroke'],
  6714. crosshairY: ['strokeWidth', 'stroke']
  6715. },
  6716. // Simple shapes:
  6717. circle: ['shapes'],
  6718. verticalLine: [],
  6719. label: ['labelOptions'],
  6720. // Measure
  6721. measure: ['background', 'crosshairY', 'crosshairX'],
  6722. // Others:
  6723. fibonacci: [],
  6724. tunnel: ['background', 'line', 'height'],
  6725. pitchfork: ['innerBackground', 'outerBackground'],
  6726. rect: ['shapes'],
  6727. // Crooked lines, elliots, arrows etc:
  6728. crookedLine: [],
  6729. basicAnnotation: ['shapes', 'labelOptions']
  6730. };
  6731. // Define non editable fields per annotation, for example Rectangle inherits
  6732. // options from Measure, but crosshairs are not available
  6733. NavigationBindings.annotationsNonEditable = {
  6734. rectangle: ['crosshairX', 'crosshairY', 'label']
  6735. };
  6736. return NavigationBindings;
  6737. }());
  6738. /**
  6739. * General utils for bindings
  6740. *
  6741. * @private
  6742. * @name Highcharts.NavigationBindings.utils
  6743. * @type {bindingsUtils}
  6744. */
  6745. NavigationBindings.prototype.utils = bindingsUtils;
  6746. Chart.prototype.initNavigationBindings = function () {
  6747. var chart = this,
  6748. options = chart.options;
  6749. if (options && options.navigation && options.navigation.bindings) {
  6750. chart.navigationBindings = new NavigationBindings(chart, options.navigation);
  6751. chart.navigationBindings.initEvents();
  6752. chart.navigationBindings.initUpdate();
  6753. }
  6754. };
  6755. addEvent(Chart, 'load', function () {
  6756. this.initNavigationBindings();
  6757. });
  6758. addEvent(Chart, 'destroy', function () {
  6759. if (this.navigationBindings) {
  6760. this.navigationBindings.destroy();
  6761. }
  6762. });
  6763. addEvent(NavigationBindings, 'deselectButton', function () {
  6764. this.selectedButtonElement = null;
  6765. });
  6766. addEvent(Annotation, 'remove', function () {
  6767. if (this.chart.navigationBindings) {
  6768. this.chart.navigationBindings.deselectAnnotation();
  6769. }
  6770. });
  6771. /**
  6772. * Show edit-annotation form:
  6773. * @private
  6774. */
  6775. function selectableAnnotation(annotationType) {
  6776. var originalClick = annotationType.prototype.defaultOptions.events &&
  6777. annotationType.prototype.defaultOptions.events.click;
  6778. /**
  6779. * @private
  6780. */
  6781. function selectAndshowPopup(event) {
  6782. var annotation = this,
  6783. navigation = annotation.chart.navigationBindings,
  6784. prevAnnotation = navigation.activeAnnotation;
  6785. if (originalClick) {
  6786. originalClick.call(annotation, event);
  6787. }
  6788. if (prevAnnotation !== annotation) {
  6789. // Select current:
  6790. navigation.deselectAnnotation();
  6791. navigation.activeAnnotation = annotation;
  6792. annotation.setControlPointsVisibility(true);
  6793. fireEvent(navigation, 'showPopup', {
  6794. annotation: annotation,
  6795. formType: 'annotation-toolbar',
  6796. options: navigation.annotationToFields(annotation),
  6797. onSubmit: function (data) {
  6798. var config = {},
  6799. typeOptions;
  6800. if (data.actionType === 'remove') {
  6801. navigation.activeAnnotation = false;
  6802. navigation.chart.removeAnnotation(annotation);
  6803. }
  6804. else {
  6805. navigation.fieldsToOptions(data.fields, config);
  6806. navigation.deselectAnnotation();
  6807. typeOptions = config.typeOptions;
  6808. if (annotation.options.type === 'measure') {
  6809. // Manually disable crooshars according to
  6810. // stroke width of the shape:
  6811. typeOptions.crosshairY.enabled =
  6812. typeOptions.crosshairY.strokeWidth !== 0;
  6813. typeOptions.crosshairX.enabled =
  6814. typeOptions.crosshairX.strokeWidth !== 0;
  6815. }
  6816. annotation.update(config);
  6817. }
  6818. }
  6819. });
  6820. }
  6821. else {
  6822. // Deselect current:
  6823. fireEvent(navigation, 'closePopup');
  6824. }
  6825. // Let bubble event to chart.click:
  6826. event.activeAnnotation = true;
  6827. }
  6828. merge(true, annotationType.prototype.defaultOptions.events, {
  6829. click: selectAndshowPopup
  6830. });
  6831. }
  6832. if (H.Annotation) {
  6833. // Basic shapes:
  6834. selectableAnnotation(Annotation);
  6835. // Advanced annotations:
  6836. objectEach(Annotation.types, function (annotationType) {
  6837. selectableAnnotation(annotationType);
  6838. });
  6839. }
  6840. setOptions({
  6841. /**
  6842. * @optionparent lang
  6843. *
  6844. * @private
  6845. */
  6846. lang: {
  6847. /**
  6848. * Configure the Popup strings in the chart. Requires the
  6849. * `annotations.js` or `annotations-advanced.src.js` module to be
  6850. * loaded.
  6851. *
  6852. * @since 7.0.0
  6853. * @product highcharts highstock
  6854. */
  6855. navigation: {
  6856. /**
  6857. * Translations for all field names used in popup.
  6858. *
  6859. * @product highcharts highstock
  6860. */
  6861. popup: {
  6862. simpleShapes: 'Simple shapes',
  6863. lines: 'Lines',
  6864. circle: 'Circle',
  6865. rectangle: 'Rectangle',
  6866. label: 'Label',
  6867. shapeOptions: 'Shape options',
  6868. typeOptions: 'Details',
  6869. fill: 'Fill',
  6870. format: 'Text',
  6871. strokeWidth: 'Line width',
  6872. stroke: 'Line color',
  6873. title: 'Title',
  6874. name: 'Name',
  6875. labelOptions: 'Label options',
  6876. labels: 'Labels',
  6877. backgroundColor: 'Background color',
  6878. backgroundColors: 'Background colors',
  6879. borderColor: 'Border color',
  6880. borderRadius: 'Border radius',
  6881. borderWidth: 'Border width',
  6882. style: 'Style',
  6883. padding: 'Padding',
  6884. fontSize: 'Font size',
  6885. color: 'Color',
  6886. height: 'Height',
  6887. shapes: 'Shape options'
  6888. }
  6889. }
  6890. },
  6891. /**
  6892. * @optionparent navigation
  6893. * @product highcharts highstock
  6894. *
  6895. * @private
  6896. */
  6897. navigation: {
  6898. /**
  6899. * A CSS class name where all bindings will be attached to. Multiple
  6900. * charts on the same page should have separate class names to prevent
  6901. * duplicating events.
  6902. *
  6903. * Default value of versions < 7.0.4 `highcharts-bindings-wrapper`
  6904. *
  6905. * @since 7.0.0
  6906. * @type {string}
  6907. */
  6908. bindingsClassName: 'highcharts-bindings-container',
  6909. /**
  6910. * Bindings definitions for custom HTML buttons. Each binding implements
  6911. * simple event-driven interface:
  6912. *
  6913. * - `className`: classname used to bind event to
  6914. *
  6915. * - `init`: initial event, fired on button click
  6916. *
  6917. * - `start`: fired on first click on a chart
  6918. *
  6919. * - `steps`: array of sequential events fired one after another on each
  6920. * of users clicks
  6921. *
  6922. * - `end`: last event to be called after last step event
  6923. *
  6924. * @type {Highcharts.Dictionary<Highcharts.NavigationBindingsOptionsObject>|*}
  6925. * @sample stock/stocktools/stocktools-thresholds
  6926. * Custom bindings in Highstock
  6927. * @since 7.0.0
  6928. * @product highcharts highstock
  6929. */
  6930. bindings: {
  6931. /**
  6932. * A circle annotation bindings. Includes `start` and one event in
  6933. * `steps` array.
  6934. *
  6935. * @type {Highcharts.NavigationBindingsOptionsObject}
  6936. * @default {"className": "highcharts-circle-annotation", "start": function() {}, "steps": [function() {}], "annotationsOptions": {}}
  6937. */
  6938. circleAnnotation: {
  6939. /** @ignore-option */
  6940. className: 'highcharts-circle-annotation',
  6941. /** @ignore-option */
  6942. start: function (e) {
  6943. var coords = this.chart.pointer.getCoordinates(e),
  6944. navigation = this.chart.options.navigation;
  6945. return this.chart.addAnnotation(merge({
  6946. langKey: 'circle',
  6947. type: 'basicAnnotation',
  6948. shapes: [{
  6949. type: 'circle',
  6950. point: {
  6951. xAxis: 0,
  6952. yAxis: 0,
  6953. x: coords.xAxis[0].value,
  6954. y: coords.yAxis[0].value
  6955. },
  6956. r: 5
  6957. }]
  6958. }, navigation
  6959. .annotationsOptions, navigation
  6960. .bindings
  6961. .circleAnnotation
  6962. .annotationsOptions));
  6963. },
  6964. /** @ignore-option */
  6965. steps: [
  6966. function (e, annotation) {
  6967. var point = annotation.options.shapes[0].point,
  6968. x = this.chart.xAxis[0].toPixels(point.x),
  6969. y = this.chart.yAxis[0].toPixels(point.y),
  6970. inverted = this.chart.inverted,
  6971. distance = Math.max(Math.sqrt(Math.pow(inverted ? y - e.chartX : x - e.chartX, 2) +
  6972. Math.pow(inverted ? x - e.chartY : y - e.chartY, 2)), 5);
  6973. annotation.update({
  6974. shapes: [{
  6975. r: distance
  6976. }]
  6977. });
  6978. }
  6979. ]
  6980. },
  6981. /**
  6982. * A rectangle annotation bindings. Includes `start` and one event
  6983. * in `steps` array.
  6984. *
  6985. * @type {Highcharts.NavigationBindingsOptionsObject}
  6986. * @default {"className": "highcharts-rectangle-annotation", "start": function() {}, "steps": [function() {}], "annotationsOptions": {}}
  6987. */
  6988. rectangleAnnotation: {
  6989. /** @ignore-option */
  6990. className: 'highcharts-rectangle-annotation',
  6991. /** @ignore-option */
  6992. start: function (e) {
  6993. var coords = this.chart.pointer.getCoordinates(e),
  6994. navigation = this.chart.options.navigation,
  6995. x = coords.xAxis[0].value,
  6996. y = coords.yAxis[0].value;
  6997. return this.chart.addAnnotation(merge({
  6998. langKey: 'rectangle',
  6999. type: 'basicAnnotation',
  7000. shapes: [{
  7001. type: 'path',
  7002. points: [{
  7003. xAxis: 0,
  7004. yAxis: 0,
  7005. x: x,
  7006. y: y
  7007. }, {
  7008. xAxis: 0,
  7009. yAxis: 0,
  7010. x: x,
  7011. y: y
  7012. }, {
  7013. xAxis: 0,
  7014. yAxis: 0,
  7015. x: x,
  7016. y: y
  7017. }, {
  7018. xAxis: 0,
  7019. yAxis: 0,
  7020. x: x,
  7021. y: y
  7022. }]
  7023. }]
  7024. }, navigation
  7025. .annotationsOptions, navigation
  7026. .bindings
  7027. .rectangleAnnotation
  7028. .annotationsOptions));
  7029. },
  7030. /** @ignore-option */
  7031. steps: [
  7032. function (e, annotation) {
  7033. var points = annotation.options.shapes[0].points,
  7034. coords = this.chart.pointer.getCoordinates(e),
  7035. x = coords.xAxis[0].value,
  7036. y = coords.yAxis[0].value;
  7037. // Top right point
  7038. points[1].x = x;
  7039. // Bottom right point (cursor position)
  7040. points[2].x = x;
  7041. points[2].y = y;
  7042. // Bottom left
  7043. points[3].y = y;
  7044. annotation.update({
  7045. shapes: [{
  7046. points: points
  7047. }]
  7048. });
  7049. }
  7050. ]
  7051. },
  7052. /**
  7053. * A label annotation bindings. Includes `start` event only.
  7054. *
  7055. * @type {Highcharts.NavigationBindingsOptionsObject}
  7056. * @default {"className": "highcharts-label-annotation", "start": function() {}, "steps": [function() {}], "annotationsOptions": {}}
  7057. */
  7058. labelAnnotation: {
  7059. /** @ignore-option */
  7060. className: 'highcharts-label-annotation',
  7061. /** @ignore-option */
  7062. start: function (e) {
  7063. var coords = this.chart.pointer.getCoordinates(e),
  7064. navigation = this.chart.options.navigation;
  7065. return this.chart.addAnnotation(merge({
  7066. langKey: 'label',
  7067. type: 'basicAnnotation',
  7068. labelOptions: {
  7069. format: '{y:.2f}'
  7070. },
  7071. labels: [{
  7072. point: {
  7073. xAxis: 0,
  7074. yAxis: 0,
  7075. x: coords.xAxis[0].value,
  7076. y: coords.yAxis[0].value
  7077. },
  7078. overflow: 'none',
  7079. crop: true
  7080. }]
  7081. }, navigation
  7082. .annotationsOptions, navigation
  7083. .bindings
  7084. .labelAnnotation
  7085. .annotationsOptions));
  7086. }
  7087. }
  7088. },
  7089. /**
  7090. * Path where Highcharts will look for icons. Change this to use icons
  7091. * from a different server.
  7092. *
  7093. * @type {string}
  7094. * @default https://code.highcharts.com/9.0.1/gfx/stock-icons/
  7095. * @since 7.1.3
  7096. * @apioption navigation.iconsURL
  7097. */
  7098. /**
  7099. * A `showPopup` event. Fired when selecting for example an annotation.
  7100. *
  7101. * @type {Function}
  7102. * @apioption navigation.events.showPopup
  7103. */
  7104. /**
  7105. * A `closePopup` event. Fired when Popup should be hidden, for example
  7106. * when clicking on an annotation again.
  7107. *
  7108. * @type {Function}
  7109. * @apioption navigation.events.closePopup
  7110. */
  7111. /**
  7112. * Event fired on a button click.
  7113. *
  7114. * @type {Function}
  7115. * @sample highcharts/annotations/gui/
  7116. * Change icon in a dropddown on event
  7117. * @sample highcharts/annotations/gui-buttons/
  7118. * Change button class on event
  7119. * @apioption navigation.events.selectButton
  7120. */
  7121. /**
  7122. * Event fired when button state should change, for example after
  7123. * adding an annotation.
  7124. *
  7125. * @type {Function}
  7126. * @sample highcharts/annotations/gui/
  7127. * Change icon in a dropddown on event
  7128. * @sample highcharts/annotations/gui-buttons/
  7129. * Change button class on event
  7130. * @apioption navigation.events.deselectButton
  7131. */
  7132. /**
  7133. * Events to communicate between Stock Tools and custom GUI.
  7134. *
  7135. * @since 7.0.0
  7136. * @product highcharts highstock
  7137. * @optionparent navigation.events
  7138. */
  7139. events: {},
  7140. /**
  7141. * Additional options to be merged into all annotations.
  7142. *
  7143. * @sample stock/stocktools/navigation-annotation-options
  7144. * Set red color of all line annotations
  7145. *
  7146. * @type {Highcharts.AnnotationsOptions}
  7147. * @extends annotations
  7148. * @exclude crookedLine, elliottWave, fibonacci, infinityLine,
  7149. * measure, pitchfork, tunnel, verticalLine, basicAnnotation
  7150. * @apioption navigation.annotationsOptions
  7151. */
  7152. annotationsOptions: {
  7153. animation: {
  7154. defer: 0
  7155. }
  7156. }
  7157. }
  7158. });
  7159. addEvent(NavigationBindings, 'closePopup', function () {
  7160. this.deselectAnnotation();
  7161. });
  7162. return NavigationBindings;
  7163. });
  7164. _registerModule(_modules, 'Extensions/Annotations/Popup.js', [_modules['Core/Globals.js'], _modules['Extensions/Annotations/NavigationBindings.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, NavigationBindings, Pointer, U) {
  7165. /* *
  7166. *
  7167. * Popup generator for Stock tools
  7168. *
  7169. * (c) 2009-2021 Sebastian Bochan
  7170. *
  7171. * License: www.highcharts.com/license
  7172. *
  7173. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7174. *
  7175. * */
  7176. var isFirefox = H.isFirefox;
  7177. var addEvent = U.addEvent,
  7178. createElement = U.createElement,
  7179. defined = U.defined,
  7180. fireEvent = U.fireEvent,
  7181. getOptions = U.getOptions,
  7182. isArray = U.isArray,
  7183. isObject = U.isObject,
  7184. isString = U.isString,
  7185. objectEach = U.objectEach,
  7186. pick = U.pick,
  7187. stableSort = U.stableSort,
  7188. wrap = U.wrap;
  7189. var indexFilter = /\d/g, PREFIX = 'highcharts-', DIV = 'div', INPUT = 'input', LABEL = 'label', BUTTON = 'button', SELECT = 'select', OPTION = 'option', SPAN = 'span', UL = 'ul', LI = 'li', H3 = 'h3';
  7190. /* eslint-disable no-invalid-this, valid-jsdoc */
  7191. // onContainerMouseDown blocks internal popup events, due to e.preventDefault.
  7192. // Related issue #4606
  7193. wrap(Pointer.prototype, 'onContainerMouseDown', function (proceed, e) {
  7194. var popupClass = e.target && e.target.className;
  7195. // elements is not in popup
  7196. if (!(isString(popupClass) &&
  7197. popupClass.indexOf(PREFIX + 'popup-field') >= 0)) {
  7198. proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  7199. }
  7200. });
  7201. H.Popup = function (parentDiv, iconsURL, chart) {
  7202. this.init(parentDiv, iconsURL, chart);
  7203. };
  7204. H.Popup.prototype = {
  7205. /**
  7206. * Initialize the popup. Create base div and add close button.
  7207. * @private
  7208. * @param {Highcharts.HTMLDOMElement} parentDiv
  7209. * Container where popup should be placed
  7210. * @param {string} iconsURL
  7211. * Icon URL
  7212. */
  7213. init: function (parentDiv, iconsURL, chart) {
  7214. this.chart = chart;
  7215. // create popup div
  7216. this.container = createElement(DIV, {
  7217. className: PREFIX + 'popup'
  7218. }, null, parentDiv);
  7219. this.lang = this.getLangpack();
  7220. this.iconsURL = iconsURL;
  7221. // add close button
  7222. this.addCloseBtn();
  7223. },
  7224. /**
  7225. * Create HTML element and attach click event (close popup).
  7226. * @private
  7227. */
  7228. addCloseBtn: function () {
  7229. var _self = this,
  7230. closeBtn;
  7231. // create close popup btn
  7232. closeBtn = createElement(DIV, {
  7233. className: PREFIX + 'popup-close'
  7234. }, null, this.container);
  7235. closeBtn.style['background-image'] = 'url(' +
  7236. this.iconsURL + 'close.svg)';
  7237. ['click', 'touchstart'].forEach(function (eventName) {
  7238. addEvent(closeBtn, eventName, function () {
  7239. fireEvent(_self.chart.navigationBindings, 'closePopup');
  7240. });
  7241. });
  7242. },
  7243. /**
  7244. * Create two columns (divs) in HTML.
  7245. * @private
  7246. * @param {Highcharts.HTMLDOMElement} container
  7247. * Container of columns
  7248. * @return {Highcharts.Dictionary<Highcharts.HTMLDOMElement>}
  7249. * Reference to two HTML columns (lhsCol, rhsCol)
  7250. */
  7251. addColsContainer: function (container) {
  7252. var rhsCol,
  7253. lhsCol;
  7254. // left column
  7255. lhsCol = createElement(DIV, {
  7256. className: PREFIX + 'popup-lhs-col'
  7257. }, null, container);
  7258. // right column
  7259. rhsCol = createElement(DIV, {
  7260. className: PREFIX + 'popup-rhs-col'
  7261. }, null, container);
  7262. // wrapper content
  7263. createElement(DIV, {
  7264. className: PREFIX + 'popup-rhs-col-wrapper'
  7265. }, null, rhsCol);
  7266. return {
  7267. lhsCol: lhsCol,
  7268. rhsCol: rhsCol
  7269. };
  7270. },
  7271. /**
  7272. * Create input with label.
  7273. * @private
  7274. * @param {string} option
  7275. * Chain of fields i.e params.styles.fontSize
  7276. * @param {string} type
  7277. * Indicator type
  7278. * @param {Highhcharts.HTMLDOMElement}
  7279. * Container where elements should be added
  7280. * @param {string} value
  7281. * Default value of input i.e period value is 14, extracted from
  7282. * defaultOptions (ADD mode) or series options (EDIT mode)
  7283. */
  7284. addInput: function (option, type, parentDiv, value) {
  7285. var optionParamList = option.split('.'), optionName = optionParamList[optionParamList.length - 1], lang = this.lang, inputName = PREFIX + type + '-' + optionName;
  7286. if (!inputName.match(indexFilter)) {
  7287. // add label
  7288. createElement(LABEL, {
  7289. innerHTML: lang[optionName] || optionName,
  7290. htmlFor: inputName
  7291. }, null, parentDiv);
  7292. }
  7293. // add input
  7294. createElement(INPUT, {
  7295. name: inputName,
  7296. value: value[0],
  7297. type: value[1],
  7298. className: PREFIX + 'popup-field'
  7299. }, null, parentDiv).setAttribute(PREFIX + 'data-name', option);
  7300. },
  7301. /**
  7302. * Create button.
  7303. * @private
  7304. * @param {Highcharts.HTMLDOMElement} parentDiv
  7305. * Container where elements should be added
  7306. * @param {string} label
  7307. * Text placed as button label
  7308. * @param {string} type
  7309. * add | edit | remove
  7310. * @param {Function} callback
  7311. * On click callback
  7312. * @param {Highcharts.HTMLDOMElement} fieldsDiv
  7313. * Container where inputs are generated
  7314. * @return {Highcharts.HTMLDOMElement}
  7315. * HTML button
  7316. */
  7317. addButton: function (parentDiv, label, type, callback, fieldsDiv) {
  7318. var _self = this,
  7319. closePopup = this.closePopup,
  7320. getFields = this.getFields,
  7321. button;
  7322. button = createElement(BUTTON, {
  7323. innerHTML: label
  7324. }, null, parentDiv);
  7325. ['click', 'touchstart'].forEach(function (eventName) {
  7326. addEvent(button, eventName, function () {
  7327. closePopup.call(_self);
  7328. return callback(getFields(fieldsDiv, type));
  7329. });
  7330. });
  7331. return button;
  7332. },
  7333. /**
  7334. * Get values from all inputs and create JSON.
  7335. * @private
  7336. * @param {Highcharts.HTMLDOMElement} - container where inputs are created
  7337. * @param {string} - add | edit | remove
  7338. * @return {Highcharts.PopupFieldsObject} - fields
  7339. */
  7340. getFields: function (parentDiv, type) {
  7341. var inputList = parentDiv.querySelectorAll('input'), optionSeries = '#' + PREFIX + 'select-series > option:checked', optionVolume = '#' + PREFIX + 'select-volume > option:checked', linkedTo = parentDiv.querySelectorAll(optionSeries)[0], volumeTo = parentDiv.querySelectorAll(optionVolume)[0], seriesId, param, fieldsOutput;
  7342. fieldsOutput = {
  7343. actionType: type,
  7344. linkedTo: linkedTo && linkedTo.getAttribute('value'),
  7345. fields: {}
  7346. };
  7347. [].forEach.call(inputList, function (input) {
  7348. param = input.getAttribute(PREFIX + 'data-name');
  7349. seriesId = input.getAttribute(PREFIX + 'data-series-id');
  7350. // params
  7351. if (seriesId) {
  7352. fieldsOutput.seriesId = input.value;
  7353. }
  7354. else if (param) {
  7355. fieldsOutput.fields[param] = input.value;
  7356. }
  7357. else {
  7358. // type like sma / ema
  7359. fieldsOutput.type = input.value;
  7360. }
  7361. });
  7362. if (volumeTo) {
  7363. fieldsOutput.fields['params.volumeSeriesID'] = volumeTo.getAttribute('value');
  7364. }
  7365. return fieldsOutput;
  7366. },
  7367. /**
  7368. * Reset content of the current popup and show.
  7369. * @private
  7370. */
  7371. showPopup: function () {
  7372. var popupDiv = this.container,
  7373. toolbarClass = PREFIX + 'annotation-toolbar',
  7374. popupCloseBtn = popupDiv
  7375. .querySelectorAll('.' + PREFIX + 'popup-close')[0];
  7376. // reset content
  7377. popupDiv.innerHTML = '';
  7378. // reset toolbar styles if exists
  7379. if (popupDiv.className.indexOf(toolbarClass) >= 0) {
  7380. popupDiv.classList.remove(toolbarClass);
  7381. // reset toolbar inline styles
  7382. popupDiv.removeAttribute('style');
  7383. }
  7384. // add close button
  7385. popupDiv.appendChild(popupCloseBtn);
  7386. popupDiv.style.display = 'block';
  7387. },
  7388. /**
  7389. * Hide popup.
  7390. * @private
  7391. */
  7392. closePopup: function () {
  7393. this.popup.container.style.display = 'none';
  7394. },
  7395. /**
  7396. * Create content and show popup.
  7397. * @private
  7398. * @param {string} - type of popup i.e indicators
  7399. * @param {Highcharts.Chart} - chart
  7400. * @param {Highcharts.AnnotationsOptions} - options
  7401. * @param {Function} - on click callback
  7402. */
  7403. showForm: function (type, chart, options, callback) {
  7404. this.popup = chart.navigationBindings.popup;
  7405. // show blank popup
  7406. this.showPopup();
  7407. // indicator form
  7408. if (type === 'indicators') {
  7409. this.indicators.addForm.call(this, chart, options, callback);
  7410. }
  7411. // annotation small toolbar
  7412. if (type === 'annotation-toolbar') {
  7413. this.annotations.addToolbar.call(this, chart, options, callback);
  7414. }
  7415. // annotation edit form
  7416. if (type === 'annotation-edit') {
  7417. this.annotations.addForm.call(this, chart, options, callback);
  7418. }
  7419. // flags form - add / edit
  7420. if (type === 'flag') {
  7421. this.annotations.addForm.call(this, chart, options, callback, true);
  7422. }
  7423. },
  7424. /**
  7425. * Return lang definitions for popup.
  7426. * @private
  7427. * @return {Highcharts.Dictionary<string>} - elements translations.
  7428. */
  7429. getLangpack: function () {
  7430. return getOptions().lang.navigation.popup;
  7431. },
  7432. annotations: {
  7433. /**
  7434. * Create annotation simple form. It contains two buttons
  7435. * (edit / remove) and text label.
  7436. * @private
  7437. * @param {Highcharts.Chart} - chart
  7438. * @param {Highcharts.AnnotationsOptions} - options
  7439. * @param {Function} - on click callback
  7440. */
  7441. addToolbar: function (chart, options, callback) {
  7442. var _self = this,
  7443. lang = this.lang,
  7444. popupDiv = this.popup.container,
  7445. showForm = this.showForm,
  7446. toolbarClass = PREFIX + 'annotation-toolbar',
  7447. button;
  7448. // set small size
  7449. if (popupDiv.className.indexOf(toolbarClass) === -1) {
  7450. popupDiv.className += ' ' + toolbarClass;
  7451. }
  7452. // set position
  7453. popupDiv.style.top = chart.plotTop + 10 + 'px';
  7454. // create label
  7455. createElement(SPAN, {
  7456. innerHTML: pick(
  7457. // Advanced annotations:
  7458. lang[options.langKey] || options.langKey,
  7459. // Basic shapes:
  7460. options.shapes && options.shapes[0].type)
  7461. }, null, popupDiv);
  7462. // add buttons
  7463. button = this.addButton(popupDiv, lang.removeButton || 'remove', 'remove', callback, popupDiv);
  7464. button.className += ' ' + PREFIX + 'annotation-remove-button';
  7465. button.style['background-image'] = 'url(' +
  7466. this.iconsURL + 'destroy.svg)';
  7467. button = this.addButton(popupDiv, lang.editButton || 'edit', 'edit', function () {
  7468. showForm.call(_self, 'annotation-edit', chart, options, callback);
  7469. }, popupDiv);
  7470. button.className += ' ' + PREFIX + 'annotation-edit-button';
  7471. button.style['background-image'] = 'url(' +
  7472. this.iconsURL + 'edit.svg)';
  7473. },
  7474. /**
  7475. * Create annotation simple form.
  7476. * It contains fields with param names.
  7477. * @private
  7478. * @param {Highcharts.Chart} chart
  7479. * Chart
  7480. * @param {Object} options
  7481. * Options
  7482. * @param {Function} callback
  7483. * On click callback
  7484. * @param {boolean} [isInit]
  7485. * If it is a form declared for init annotation
  7486. */
  7487. addForm: function (chart, options, callback, isInit) {
  7488. var popupDiv = this.popup.container,
  7489. lang = this.lang,
  7490. bottomRow,
  7491. lhsCol;
  7492. // create title of annotations
  7493. lhsCol = createElement('h2', {
  7494. innerHTML: lang[options.langKey] || options.langKey,
  7495. className: PREFIX + 'popup-main-title'
  7496. }, null, popupDiv);
  7497. // left column
  7498. lhsCol = createElement(DIV, {
  7499. className: PREFIX + 'popup-lhs-col ' + PREFIX + 'popup-lhs-full'
  7500. }, null, popupDiv);
  7501. bottomRow = createElement(DIV, {
  7502. className: PREFIX + 'popup-bottom-row'
  7503. }, null, popupDiv);
  7504. this.annotations.addFormFields.call(this, lhsCol, chart, '', options, [], true);
  7505. this.addButton(bottomRow, isInit ?
  7506. (lang.addButton || 'add') :
  7507. (lang.saveButton || 'save'), isInit ? 'add' : 'save', callback, popupDiv);
  7508. },
  7509. /**
  7510. * Create annotation's form fields.
  7511. * @private
  7512. * @param {Highcharts.HTMLDOMElement} parentDiv
  7513. * Div where inputs are placed
  7514. * @param {Highcharts.Chart} chart
  7515. * Chart
  7516. * @param {string} parentNode
  7517. * Name of parent to create chain of names
  7518. * @param {Highcharts.AnnotationsOptions} options
  7519. * Options
  7520. * @param {Array<unknown>} storage
  7521. * Array where all items are stored
  7522. * @param {boolean} [isRoot]
  7523. * Recursive flag for root
  7524. */
  7525. addFormFields: function (parentDiv, chart, parentNode, options, storage, isRoot) {
  7526. var _self = this,
  7527. addFormFields = this.annotations.addFormFields,
  7528. addInput = this.addInput,
  7529. lang = this.lang,
  7530. parentFullName,
  7531. titleName;
  7532. objectEach(options, function (value, option) {
  7533. // create name like params.styles.fontSize
  7534. parentFullName = parentNode !== '' ?
  7535. parentNode + '.' + option : option;
  7536. if (isObject(value)) {
  7537. if (
  7538. // value is object of options
  7539. !isArray(value) ||
  7540. // array of objects with params. i.e labels in Fibonacci
  7541. (isArray(value) && isObject(value[0]))) {
  7542. titleName = lang[option] || option;
  7543. if (!titleName.match(indexFilter)) {
  7544. storage.push([
  7545. true,
  7546. titleName,
  7547. parentDiv
  7548. ]);
  7549. }
  7550. addFormFields.call(_self, parentDiv, chart, parentFullName, value, storage, false);
  7551. }
  7552. else {
  7553. storage.push([
  7554. _self,
  7555. parentFullName,
  7556. 'annotation',
  7557. parentDiv,
  7558. value
  7559. ]);
  7560. }
  7561. }
  7562. });
  7563. if (isRoot) {
  7564. stableSort(storage, function (a) {
  7565. return a[1].match(/format/g) ? -1 : 1;
  7566. });
  7567. if (isFirefox) {
  7568. storage.reverse(); // (#14691)
  7569. }
  7570. storage.forEach(function (genInput) {
  7571. if (genInput[0] === true) {
  7572. createElement(SPAN, {
  7573. className: PREFIX + 'annotation-title',
  7574. innerHTML: genInput[1]
  7575. }, null, genInput[2]);
  7576. }
  7577. else {
  7578. addInput.apply(genInput[0], genInput.splice(1));
  7579. }
  7580. });
  7581. }
  7582. }
  7583. },
  7584. indicators: {
  7585. /**
  7586. * Create indicator's form. It contains two tabs (ADD and EDIT) with
  7587. * content.
  7588. * @private
  7589. */
  7590. addForm: function (chart, _options, callback) {
  7591. var tabsContainers,
  7592. indicators = this.indicators,
  7593. lang = this.lang,
  7594. buttonParentDiv;
  7595. // add tabs
  7596. this.tabs.init.call(this, chart);
  7597. // get all tabs content divs
  7598. tabsContainers = this.popup.container
  7599. .querySelectorAll('.' + PREFIX + 'tab-item-content');
  7600. // ADD tab
  7601. this.addColsContainer(tabsContainers[0]);
  7602. indicators.addIndicatorList.call(this, chart, tabsContainers[0], 'add');
  7603. buttonParentDiv = tabsContainers[0]
  7604. .querySelectorAll('.' + PREFIX + 'popup-rhs-col')[0];
  7605. this.addButton(buttonParentDiv, lang.addButton || 'add', 'add', callback, buttonParentDiv);
  7606. // EDIT tab
  7607. this.addColsContainer(tabsContainers[1]);
  7608. indicators.addIndicatorList.call(this, chart, tabsContainers[1], 'edit');
  7609. buttonParentDiv = tabsContainers[1]
  7610. .querySelectorAll('.' + PREFIX + 'popup-rhs-col')[0];
  7611. this.addButton(buttonParentDiv, lang.saveButton || 'save', 'edit', callback, buttonParentDiv);
  7612. this.addButton(buttonParentDiv, lang.removeButton || 'remove', 'remove', callback, buttonParentDiv);
  7613. },
  7614. /**
  7615. * Create HTML list of all indicators (ADD mode) or added indicators
  7616. * (EDIT mode).
  7617. * @private
  7618. */
  7619. addIndicatorList: function (chart, parentDiv, listType) {
  7620. var _self = this, lhsCol = parentDiv.querySelectorAll('.' + PREFIX + 'popup-lhs-col')[0], rhsCol = parentDiv.querySelectorAll('.' + PREFIX + 'popup-rhs-col')[0], isEdit = listType === 'edit', series = (isEdit ?
  7621. chart.series : // EDIT mode
  7622. chart.options.plotOptions // ADD mode
  7623. ), addFormFields = this.indicators.addFormFields, rhsColWrapper, indicatorList, item;
  7624. // create wrapper for list
  7625. indicatorList = createElement(UL, {
  7626. className: PREFIX + 'indicator-list'
  7627. }, null, lhsCol);
  7628. rhsColWrapper = rhsCol
  7629. .querySelectorAll('.' + PREFIX + 'popup-rhs-col-wrapper')[0];
  7630. objectEach(series, function (serie, value) {
  7631. var seriesOptions = serie.options;
  7632. if (serie.params ||
  7633. seriesOptions && seriesOptions.params) {
  7634. var indicatorNameType = _self.indicators.getNameType(serie,
  7635. value),
  7636. indicatorType = indicatorNameType.type;
  7637. item = createElement(LI, {
  7638. className: PREFIX + 'indicator-list',
  7639. innerHTML: indicatorNameType.name
  7640. }, null, indicatorList);
  7641. ['click', 'touchstart'].forEach(function (eventName) {
  7642. addEvent(item, eventName, function () {
  7643. addFormFields.call(_self, chart, isEdit ? serie : series[indicatorType], indicatorNameType.type, rhsColWrapper);
  7644. // add hidden input with series.id
  7645. if (isEdit && serie.options) {
  7646. createElement(INPUT, {
  7647. type: 'hidden',
  7648. name: PREFIX + 'id-' + indicatorType,
  7649. value: serie.options.id
  7650. }, null, rhsColWrapper)
  7651. .setAttribute(PREFIX + 'data-series-id', serie.options.id);
  7652. }
  7653. });
  7654. });
  7655. }
  7656. });
  7657. // select first item from the list
  7658. if (indicatorList.childNodes.length > 0) {
  7659. indicatorList.childNodes[0].click();
  7660. }
  7661. },
  7662. /**
  7663. * Extract full name and type of requested indicator.
  7664. * @private
  7665. * @param {Highcharts.Series} series
  7666. * Series which name is needed. (EDIT mode - defaultOptions.series, ADD
  7667. * mode - indicator series).
  7668. * @param {string} - indicator type like: sma, ema, etc.
  7669. * @return {Object} - series name and type like: sma, ema, etc.
  7670. */
  7671. getNameType: function (series, type) {
  7672. var options = series.options,
  7673. seriesTypes = H.seriesTypes,
  7674. // add mode
  7675. seriesName = seriesTypes[type] &&
  7676. seriesTypes[type].prototype.nameBase || type.toUpperCase(),
  7677. seriesType = type;
  7678. // edit
  7679. if (options && options.type) {
  7680. seriesType = series.options.type;
  7681. seriesName = series.name;
  7682. }
  7683. return {
  7684. name: seriesName,
  7685. type: seriesType
  7686. };
  7687. },
  7688. /**
  7689. * List all series with unique ID. Its mandatory for indicators to set
  7690. * correct linking.
  7691. * @private
  7692. * @param {string} type
  7693. * Indicator type like: sma, ema, etc.
  7694. * @param {string} optionName
  7695. * Type of select i.e series or volume.
  7696. * @param {Highcharts.Chart} chart
  7697. * Chart
  7698. * @param {Highcharts.HTMLDOMElement} parentDiv
  7699. * Element where created HTML list is added
  7700. * @param {string} selectedOption
  7701. * optional param for default value in dropdown
  7702. */
  7703. listAllSeries: function (type, optionName, chart, parentDiv, selectedOption) {
  7704. var selectName = PREFIX + optionName + '-type-' + type,
  7705. lang = this.lang,
  7706. selectBox,
  7707. seriesOptions;
  7708. createElement(LABEL, {
  7709. innerHTML: lang[optionName] || optionName,
  7710. htmlFor: selectName
  7711. }, null, parentDiv);
  7712. // select type
  7713. selectBox = createElement(SELECT, {
  7714. name: selectName,
  7715. className: PREFIX + 'popup-field'
  7716. }, null, parentDiv);
  7717. selectBox.setAttribute('id', PREFIX + 'select-' + optionName);
  7718. // list all series which have id - mandatory for creating indicator
  7719. chart.series.forEach(function (serie) {
  7720. seriesOptions = serie.options;
  7721. if (!seriesOptions.params &&
  7722. seriesOptions.id &&
  7723. seriesOptions.id !== PREFIX + 'navigator-series') {
  7724. createElement(OPTION, {
  7725. innerHTML: seriesOptions.name || seriesOptions.id,
  7726. value: seriesOptions.id
  7727. }, null, selectBox);
  7728. }
  7729. });
  7730. if (defined(selectedOption)) {
  7731. selectBox.value = selectedOption;
  7732. }
  7733. },
  7734. /**
  7735. * Create typical inputs for chosen indicator. Fields are extracted from
  7736. * defaultOptions (ADD mode) or current indicator (ADD mode). Two extra
  7737. * fields are added:
  7738. * - hidden input - contains indicator type (required for callback)
  7739. * - select - list of series which can be linked with indicator
  7740. * @private
  7741. * @param {Highcharts.Chart} chart
  7742. * Chart
  7743. * @param {Highcharts.Series} series
  7744. * Indicator
  7745. * @param {string} seriesType
  7746. * Indicator type like: sma, ema, etc.
  7747. * @param {Highcharts.HTMLDOMElement} rhsColWrapper
  7748. * Element where created HTML list is added
  7749. */
  7750. addFormFields: function (chart, series, seriesType, rhsColWrapper) {
  7751. var fields = series.params || series.options.params,
  7752. getNameType = this.indicators.getNameType;
  7753. // reset current content
  7754. rhsColWrapper.innerHTML = '';
  7755. // create title (indicator name in the right column)
  7756. createElement(H3, {
  7757. className: PREFIX + 'indicator-title',
  7758. innerHTML: getNameType(series, seriesType).name
  7759. }, null, rhsColWrapper);
  7760. // input type
  7761. createElement(INPUT, {
  7762. type: 'hidden',
  7763. name: PREFIX + 'type-' + seriesType,
  7764. value: seriesType
  7765. }, null, rhsColWrapper);
  7766. // list all series with id
  7767. this.indicators.listAllSeries.call(this, seriesType, 'series', chart, rhsColWrapper, series.linkedParent && fields.volumeSeriesID);
  7768. if (fields.volumeSeriesID) {
  7769. this.indicators.listAllSeries.call(this, seriesType, 'volume', chart, rhsColWrapper, series.linkedParent && series.linkedParent.options.id);
  7770. }
  7771. // add param fields
  7772. this.indicators.addParamInputs.call(this, chart, 'params', fields, seriesType, rhsColWrapper);
  7773. },
  7774. /**
  7775. * Recurent function which lists all fields, from params object and
  7776. * create them as inputs. Each input has unique `data-name` attribute,
  7777. * which keeps chain of fields i.e params.styles.fontSize.
  7778. * @private
  7779. * @param {Highcharts.Chart} chart
  7780. * Chart
  7781. * @param {string} parentNode
  7782. * Name of parent to create chain of names
  7783. * @param {Highcharts.PopupFieldsDictionary<string>} fields
  7784. * Params which are based for input create
  7785. * @param {string} type
  7786. * Indicator type like: sma, ema, etc.
  7787. * @param {Highcharts.HTMLDOMElement} parentDiv
  7788. * Element where created HTML list is added
  7789. */
  7790. addParamInputs: function (chart, parentNode, fields, type, parentDiv) {
  7791. var _self = this,
  7792. addParamInputs = this.indicators.addParamInputs,
  7793. addInput = this.addInput,
  7794. parentFullName;
  7795. objectEach(fields, function (value, fieldName) {
  7796. // create name like params.styles.fontSize
  7797. parentFullName = parentNode + '.' + fieldName;
  7798. if (isObject(value)) {
  7799. addParamInputs.call(_self, chart, parentFullName, value, type, parentDiv);
  7800. }
  7801. else if (
  7802. // skip volume field which is created by addFormFields
  7803. parentFullName !== 'params.volumeSeriesID') {
  7804. addInput.call(_self, parentFullName, type, parentDiv, [value, 'text'] // all inputs are text type
  7805. );
  7806. }
  7807. });
  7808. },
  7809. /**
  7810. * Get amount of indicators added to chart.
  7811. * @private
  7812. * @return {number} - Amount of indicators
  7813. */
  7814. getAmount: function () {
  7815. var series = this.series,
  7816. counter = 0;
  7817. series.forEach(function (serie) {
  7818. var seriesOptions = serie.options;
  7819. if (serie.params ||
  7820. seriesOptions && seriesOptions.params) {
  7821. counter++;
  7822. }
  7823. });
  7824. return counter;
  7825. }
  7826. },
  7827. tabs: {
  7828. /**
  7829. * Init tabs. Create tab menu items, tabs containers
  7830. * @private
  7831. * @param {Highcharts.Chart} chart
  7832. * Reference to current chart
  7833. */
  7834. init: function (chart) {
  7835. var tabs = this.tabs,
  7836. indicatorsCount = this.indicators.getAmount.call(chart),
  7837. firstTab; // run by default
  7838. // create menu items
  7839. firstTab = tabs.addMenuItem.call(this, 'add');
  7840. tabs.addMenuItem.call(this, 'edit', indicatorsCount);
  7841. // create tabs containers
  7842. tabs.addContentItem.call(this, 'add');
  7843. tabs.addContentItem.call(this, 'edit');
  7844. tabs.switchTabs.call(this, indicatorsCount);
  7845. // activate first tab
  7846. tabs.selectTab.call(this, firstTab, 0);
  7847. },
  7848. /**
  7849. * Create tab menu item
  7850. * @private
  7851. * @param {string} tabName
  7852. * `add` or `edit`
  7853. * @param {number} [disableTab]
  7854. * Disable tab when 0
  7855. * @return {Highcharts.HTMLDOMElement}
  7856. * Created HTML tab-menu element
  7857. */
  7858. addMenuItem: function (tabName, disableTab) {
  7859. var popupDiv = this.popup.container,
  7860. className = PREFIX + 'tab-item',
  7861. lang = this.lang,
  7862. menuItem;
  7863. if (disableTab === 0) {
  7864. className += ' ' + PREFIX + 'tab-disabled';
  7865. }
  7866. // tab 1
  7867. menuItem = createElement(SPAN, {
  7868. innerHTML: lang[tabName + 'Button'] || tabName,
  7869. className: className
  7870. }, null, popupDiv);
  7871. menuItem.setAttribute(PREFIX + 'data-tab-type', tabName);
  7872. return menuItem;
  7873. },
  7874. /**
  7875. * Create tab content
  7876. * @private
  7877. * @return {HTMLDOMElement} - created HTML tab-content element
  7878. */
  7879. addContentItem: function () {
  7880. var popupDiv = this.popup.container;
  7881. return createElement(DIV, {
  7882. className: PREFIX + 'tab-item-content'
  7883. }, null, popupDiv);
  7884. },
  7885. /**
  7886. * Add click event to each tab
  7887. * @private
  7888. * @param {number} disableTab
  7889. * Disable tab when 0
  7890. */
  7891. switchTabs: function (disableTab) {
  7892. var _self = this,
  7893. popupDiv = this.popup.container,
  7894. tabs = popupDiv.querySelectorAll('.' + PREFIX + 'tab-item'),
  7895. dataParam;
  7896. tabs.forEach(function (tab, i) {
  7897. dataParam = tab.getAttribute(PREFIX + 'data-tab-type');
  7898. if (dataParam === 'edit' && disableTab === 0) {
  7899. return;
  7900. }
  7901. ['click', 'touchstart'].forEach(function (eventName) {
  7902. addEvent(tab, eventName, function () {
  7903. // reset class on other elements
  7904. _self.tabs.deselectAll.call(_self);
  7905. _self.tabs.selectTab.call(_self, this, i);
  7906. });
  7907. });
  7908. });
  7909. },
  7910. /**
  7911. * Set tab as visible
  7912. * @private
  7913. * @param {globals.Element} - current tab
  7914. * @param {number} - Index of tab in menu
  7915. */
  7916. selectTab: function (tab, index) {
  7917. var allTabs = this.popup.container
  7918. .querySelectorAll('.' + PREFIX + 'tab-item-content');
  7919. tab.className += ' ' + PREFIX + 'tab-item-active';
  7920. allTabs[index].className += ' ' + PREFIX + 'tab-item-show';
  7921. },
  7922. /**
  7923. * Set all tabs as invisible.
  7924. * @private
  7925. */
  7926. deselectAll: function () {
  7927. var popupDiv = this.popup.container,
  7928. tabs = popupDiv
  7929. .querySelectorAll('.' + PREFIX + 'tab-item'),
  7930. tabsContent = popupDiv
  7931. .querySelectorAll('.' + PREFIX + 'tab-item-content'),
  7932. i;
  7933. for (i = 0; i < tabs.length; i++) {
  7934. tabs[i].classList.remove(PREFIX + 'tab-item-active');
  7935. tabsContent[i].classList.remove(PREFIX + 'tab-item-show');
  7936. }
  7937. }
  7938. }
  7939. };
  7940. addEvent(NavigationBindings, 'showPopup', function (config) {
  7941. if (!this.popup) {
  7942. // Add popup to main container
  7943. this.popup = new H.Popup(this.chart.container, (this.chart.options.navigation.iconsURL ||
  7944. (this.chart.options.stockTools &&
  7945. this.chart.options.stockTools.gui.iconsURL) ||
  7946. 'https://code.highcharts.com/9.0.1/gfx/stock-icons/'), this.chart);
  7947. }
  7948. this.popup.showForm(config.formType, this.chart, config.options, config.onSubmit);
  7949. });
  7950. addEvent(NavigationBindings, 'closePopup', function () {
  7951. if (this.popup) {
  7952. this.popup.closePopup();
  7953. }
  7954. });
  7955. });
  7956. _registerModule(_modules, 'masters/modules/annotations-advanced.src.js', [], function () {
  7957. });
  7958. }));