map.src.js 335 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034
  1. /**
  2. * @license Highmaps JS v9.0.1 (2021-02-16)
  3. *
  4. * Highmaps as a plugin for Highcharts or Highstock.
  5. *
  6. * (c) 2011-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/map', ['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, 'Core/Axis/MapAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  32. /* *
  33. *
  34. * (c) 2010-2021 Torstein Honsi
  35. *
  36. * License: www.highcharts.com/license
  37. *
  38. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39. *
  40. * */
  41. var addEvent = U.addEvent,
  42. pick = U.pick;
  43. /**
  44. * Map support for axes.
  45. * @private
  46. * @class
  47. */
  48. var MapAxisAdditions = /** @class */ (function () {
  49. /* *
  50. *
  51. * Constructors
  52. *
  53. * */
  54. function MapAxisAdditions(axis) {
  55. this.axis = axis;
  56. }
  57. return MapAxisAdditions;
  58. }());
  59. /**
  60. * Axis with map support.
  61. * @private
  62. * @class
  63. */
  64. var MapAxis = /** @class */ (function () {
  65. function MapAxis() {
  66. }
  67. /**
  68. * Extends axes with map support.
  69. * @private
  70. *
  71. * @param {Highcharts.Axis} AxisClass
  72. * Axis class to extend.
  73. */
  74. MapAxis.compose = function (AxisClass) {
  75. AxisClass.keepProps.push('mapAxis');
  76. /* eslint-disable no-invalid-this */
  77. addEvent(AxisClass, 'init', function () {
  78. var axis = this;
  79. if (!axis.mapAxis) {
  80. axis.mapAxis = new MapAxisAdditions(axis);
  81. }
  82. });
  83. // Override to use the extreme coordinates from the SVG shape, not the
  84. // data values
  85. addEvent(AxisClass, 'getSeriesExtremes', function () {
  86. if (!this.mapAxis) {
  87. return;
  88. }
  89. var axis = this;
  90. var xData = [];
  91. // Remove the xData array and cache it locally so that the proceed
  92. // method doesn't use it
  93. if (axis.isXAxis) {
  94. axis.series.forEach(function (series, i) {
  95. if (series.useMapGeometry) {
  96. xData[i] = series.xData;
  97. series.xData = [];
  98. }
  99. });
  100. axis.mapAxis.seriesXData = xData;
  101. }
  102. });
  103. addEvent(AxisClass, 'afterGetSeriesExtremes', function () {
  104. if (!this.mapAxis) {
  105. return;
  106. }
  107. var axis = this;
  108. var xData = axis.mapAxis.seriesXData || [];
  109. var dataMin,
  110. dataMax,
  111. useMapGeometry;
  112. // Run extremes logic for map and mapline
  113. if (axis.isXAxis) {
  114. dataMin = pick(axis.dataMin, Number.MAX_VALUE);
  115. dataMax = pick(axis.dataMax, -Number.MAX_VALUE);
  116. axis.series.forEach(function (series, i) {
  117. if (series.useMapGeometry) {
  118. dataMin = Math.min(dataMin, pick(series.minX, dataMin));
  119. dataMax = Math.max(dataMax, pick(series.maxX, dataMax));
  120. series.xData = xData[i]; // Reset xData array
  121. useMapGeometry = true;
  122. }
  123. });
  124. if (useMapGeometry) {
  125. axis.dataMin = dataMin;
  126. axis.dataMax = dataMax;
  127. }
  128. axis.mapAxis.seriesXData = void 0;
  129. }
  130. });
  131. // Override axis translation to make sure the aspect ratio is always
  132. // kept
  133. addEvent(AxisClass, 'afterSetAxisTranslation', function () {
  134. if (!this.mapAxis) {
  135. return;
  136. }
  137. var axis = this;
  138. var chart = axis.chart;
  139. var plotRatio = chart.plotWidth / chart.plotHeight;
  140. var xAxis = chart.xAxis[0];
  141. var mapRatio,
  142. adjustedAxisLength,
  143. padAxis,
  144. fixTo,
  145. fixDiff,
  146. preserveAspectRatio;
  147. // Check for map-like series
  148. if (axis.coll === 'yAxis' && typeof xAxis.transA !== 'undefined') {
  149. axis.series.forEach(function (series) {
  150. if (series.preserveAspectRatio) {
  151. preserveAspectRatio = true;
  152. }
  153. });
  154. }
  155. // On Y axis, handle both
  156. if (preserveAspectRatio) {
  157. // Use the same translation for both axes
  158. axis.transA = xAxis.transA = Math.min(axis.transA, xAxis.transA);
  159. mapRatio = plotRatio / ((xAxis.max - xAxis.min) /
  160. (axis.max - axis.min));
  161. // What axis to pad to put the map in the middle
  162. padAxis = mapRatio < 1 ? axis : xAxis;
  163. // Pad it
  164. adjustedAxisLength =
  165. (padAxis.max - padAxis.min) * padAxis.transA;
  166. padAxis.mapAxis.pixelPadding = padAxis.len - adjustedAxisLength;
  167. padAxis.minPixelPadding = padAxis.mapAxis.pixelPadding / 2;
  168. fixTo = padAxis.mapAxis.fixTo;
  169. if (fixTo) {
  170. fixDiff = fixTo[1] - padAxis.toValue(fixTo[0], true);
  171. fixDiff *= padAxis.transA;
  172. if (Math.abs(fixDiff) > padAxis.minPixelPadding ||
  173. (padAxis.min === padAxis.dataMin &&
  174. padAxis.max === padAxis.dataMax)) { // zooming out again, keep within restricted area
  175. fixDiff = 0;
  176. }
  177. padAxis.minPixelPadding -= fixDiff;
  178. }
  179. }
  180. });
  181. // Override Axis.render in order to delete the fixTo prop
  182. addEvent(AxisClass, 'render', function () {
  183. var axis = this;
  184. if (axis.mapAxis) {
  185. axis.mapAxis.fixTo = void 0;
  186. }
  187. });
  188. /* eslint-enable no-invalid-this */
  189. };
  190. return MapAxis;
  191. }());
  192. MapAxis.compose(Axis); // @todo move to factory functions
  193. return MapAxis;
  194. });
  195. _registerModule(_modules, 'Mixins/ColorSeries.js', [], function () {
  196. /* *
  197. *
  198. * (c) 2010-2021 Torstein Honsi
  199. *
  200. * License: www.highcharts.com/license
  201. *
  202. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  203. *
  204. * */
  205. /**
  206. * Mixin for maps and heatmaps
  207. *
  208. * @private
  209. * @mixin Highcharts.colorPointMixin
  210. */
  211. var colorPointMixin = {
  212. /* eslint-disable valid-jsdoc */
  213. /**
  214. * Set the visibility of a single point
  215. * @private
  216. * @function Highcharts.colorPointMixin.setVisible
  217. * @param {boolean} visible
  218. * @return {void}
  219. */
  220. setVisible: function (vis) {
  221. var point = this,
  222. method = vis ? 'show' : 'hide';
  223. point.visible = point.options.visible = Boolean(vis);
  224. // Show and hide associated elements
  225. ['graphic', 'dataLabel'].forEach(function (key) {
  226. if (point[key]) {
  227. point[key][method]();
  228. }
  229. });
  230. this.series.buildKDTree(); // rebuild kdtree #13195
  231. }
  232. /* eslint-enable valid-jsdoc */
  233. };
  234. /**
  235. * @private
  236. * @mixin Highcharts.colorSeriesMixin
  237. */
  238. var colorSeriesMixin = {
  239. optionalAxis: 'colorAxis',
  240. colorAxis: 0,
  241. /* eslint-disable valid-jsdoc */
  242. /**
  243. * In choropleth maps,
  244. the color is a result of the value,
  245. so this needs
  246. * translation too
  247. * @private
  248. * @function Highcharts.colorSeriesMixin.translateColors
  249. * @return {void}
  250. */
  251. translateColors: function () {
  252. var series = this,
  253. points = this.data.length ? this.data : this.points,
  254. nullColor = this.options.nullColor,
  255. colorAxis = this.colorAxis,
  256. colorKey = this.colorKey;
  257. points.forEach(function (point) {
  258. var value = point.getNestedProperty(colorKey),
  259. color;
  260. color = point.options.color ||
  261. (point.isNull || point.value === null ?
  262. nullColor :
  263. (colorAxis && typeof value !== 'undefined') ?
  264. colorAxis.toColor(value, point) :
  265. point.color || series.color);
  266. if (color && point.color !== color) {
  267. point.color = color;
  268. if (series.options.legendType === 'point' && point.legendItem) {
  269. series.chart.legend.colorizeItem(point, point.visible);
  270. }
  271. }
  272. });
  273. }
  274. /* eslint-enable valid-jsdoc */
  275. };
  276. var exports = {
  277. colorPointMixin: colorPointMixin,
  278. colorSeriesMixin: colorSeriesMixin
  279. };
  280. return exports;
  281. });
  282. _registerModule(_modules, 'Core/Axis/ColorAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Mixins/ColorSeries.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Axis, Chart, Color, ColorSeriesModule, Fx, H, Legend, LegendSymbolMixin, palette, Point, Series, U) {
  283. /* *
  284. *
  285. * (c) 2010-2021 Torstein Honsi
  286. *
  287. * License: www.highcharts.com/license
  288. *
  289. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  290. *
  291. * */
  292. var __extends = (this && this.__extends) || (function () {
  293. var extendStatics = function (d,
  294. b) {
  295. extendStatics = Object.setPrototypeOf ||
  296. ({ __proto__: [] } instanceof Array && function (d,
  297. b) { d.__proto__ = b; }) ||
  298. function (d,
  299. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  300. return extendStatics(d, b);
  301. };
  302. return function (d, b) {
  303. extendStatics(d, b);
  304. function __() { this.constructor = d; }
  305. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  306. };
  307. })();
  308. var color = Color.parse;
  309. var colorPointMixin = ColorSeriesModule.colorPointMixin,
  310. colorSeriesMixin = ColorSeriesModule.colorSeriesMixin;
  311. var noop = H.noop;
  312. var addEvent = U.addEvent,
  313. erase = U.erase,
  314. extend = U.extend,
  315. isNumber = U.isNumber,
  316. merge = U.merge,
  317. pick = U.pick,
  318. splat = U.splat;
  319. /**
  320. * Color axis types
  321. *
  322. * @typedef {"linear"|"logarithmic"} Highcharts.ColorAxisTypeValue
  323. */
  324. ''; // detach doclet above
  325. extend(Series.prototype, colorSeriesMixin);
  326. extend(Point.prototype, colorPointMixin);
  327. Chart.prototype.collectionsWithUpdate.push('colorAxis');
  328. Chart.prototype.collectionsWithInit.colorAxis = [Chart.prototype.addColorAxis];
  329. /* eslint-disable no-invalid-this, valid-jsdoc */
  330. /**
  331. * The ColorAxis object for inclusion in gradient legends.
  332. *
  333. * @class
  334. * @name Highcharts.ColorAxis
  335. * @augments Highcharts.Axis
  336. *
  337. * @param {Highcharts.Chart} chart
  338. * The related chart of the color axis.
  339. *
  340. * @param {Highcharts.ColorAxisOptions} userOptions
  341. * The color axis options for initialization.
  342. */
  343. var ColorAxis = /** @class */ (function (_super) {
  344. __extends(ColorAxis, _super);
  345. /* *
  346. *
  347. * Constructors
  348. *
  349. * */
  350. /**
  351. * @private
  352. */
  353. function ColorAxis(chart, userOptions) {
  354. var _this = _super.call(this,
  355. chart,
  356. userOptions) || this;
  357. _this.beforePadding = false; // Prevents unnecessary padding with `hc-more`
  358. _this.chart = void 0;
  359. _this.coll = 'colorAxis';
  360. _this.dataClasses = void 0;
  361. _this.legendItem = void 0;
  362. _this.legendItems = void 0;
  363. _this.name = ''; // Prevents 'undefined' in legend in IE8
  364. _this.options = void 0;
  365. _this.stops = void 0;
  366. _this.visible = true;
  367. _this.init(chart, userOptions);
  368. return _this;
  369. }
  370. /* *
  371. *
  372. * Functions
  373. *
  374. * */
  375. /**
  376. * Initializes the color axis.
  377. *
  378. * @function Highcharts.ColorAxis#init
  379. *
  380. * @param {Highcharts.Chart} chart
  381. * The related chart of the color axis.
  382. *
  383. * @param {Highcharts.ColorAxisOptions} userOptions
  384. * The color axis options for initialization.
  385. */
  386. ColorAxis.prototype.init = function (chart, userOptions) {
  387. var axis = this;
  388. var legend = chart.options.legend || {},
  389. horiz = userOptions.layout ?
  390. userOptions.layout !== 'vertical' :
  391. legend.layout !== 'vertical';
  392. var options = merge(ColorAxis.defaultOptions,
  393. userOptions, {
  394. showEmpty: false,
  395. title: null,
  396. visible: legend.enabled &&
  397. (userOptions ? userOptions.visible !== false : true)
  398. });
  399. axis.coll = 'colorAxis';
  400. axis.side = userOptions.side || horiz ? 2 : 1;
  401. axis.reversed = userOptions.reversed || !horiz;
  402. axis.opposite = !horiz;
  403. // Keep the options structure updated for export. Unlike xAxis and
  404. // yAxis, the colorAxis is not an array. (#3207)
  405. chart.options[axis.coll] = options;
  406. _super.prototype.init.call(this, chart, options);
  407. // Base init() pushes it to the xAxis array, now pop it again
  408. // chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
  409. // Prepare data classes
  410. if (userOptions.dataClasses) {
  411. axis.initDataClasses(userOptions);
  412. }
  413. axis.initStops();
  414. // Override original axis properties
  415. axis.horiz = horiz;
  416. axis.zoomEnabled = false;
  417. };
  418. /**
  419. * @private
  420. */
  421. ColorAxis.prototype.initDataClasses = function (userOptions) {
  422. var axis = this;
  423. var chart = axis.chart,
  424. dataClasses,
  425. colorCounter = 0,
  426. colorCount = chart.options.chart.colorCount,
  427. options = axis.options,
  428. len = userOptions.dataClasses.length;
  429. axis.dataClasses = dataClasses = [];
  430. axis.legendItems = [];
  431. userOptions.dataClasses.forEach(function (dataClass, i) {
  432. var colors;
  433. dataClass = merge(dataClass);
  434. dataClasses.push(dataClass);
  435. if (!chart.styledMode && dataClass.color) {
  436. return;
  437. }
  438. if (options.dataClassColor === 'category') {
  439. if (!chart.styledMode) {
  440. colors = chart.options.colors;
  441. colorCount = colors.length;
  442. dataClass.color = colors[colorCounter];
  443. }
  444. dataClass.colorIndex = colorCounter;
  445. // increase and loop back to zero
  446. colorCounter++;
  447. if (colorCounter === colorCount) {
  448. colorCounter = 0;
  449. }
  450. }
  451. else {
  452. dataClass.color = color(options.minColor).tweenTo(color(options.maxColor), len < 2 ? 0.5 : i / (len - 1) // #3219
  453. );
  454. }
  455. });
  456. };
  457. /**
  458. * Returns true if the series has points at all.
  459. *
  460. * @function Highcharts.ColorAxis#hasData
  461. *
  462. * @return {boolean}
  463. * True, if the series has points, otherwise false.
  464. */
  465. ColorAxis.prototype.hasData = function () {
  466. return !!(this.tickPositions || []).length;
  467. };
  468. /**
  469. * Override so that ticks are not added in data class axes (#6914)
  470. * @private
  471. */
  472. ColorAxis.prototype.setTickPositions = function () {
  473. if (!this.dataClasses) {
  474. return _super.prototype.setTickPositions.call(this);
  475. }
  476. };
  477. /**
  478. * @private
  479. */
  480. ColorAxis.prototype.initStops = function () {
  481. var axis = this;
  482. axis.stops = axis.options.stops || [
  483. [0, axis.options.minColor],
  484. [1, axis.options.maxColor]
  485. ];
  486. axis.stops.forEach(function (stop) {
  487. stop.color = color(stop[1]);
  488. });
  489. };
  490. /**
  491. * Extend the setOptions method to process extreme colors and color stops.
  492. * @private
  493. */
  494. ColorAxis.prototype.setOptions = function (userOptions) {
  495. var axis = this;
  496. _super.prototype.setOptions.call(this, userOptions);
  497. axis.options.crosshair = axis.options.marker;
  498. };
  499. /**
  500. * @private
  501. */
  502. ColorAxis.prototype.setAxisSize = function () {
  503. var axis = this;
  504. var symbol = axis.legendSymbol;
  505. var chart = axis.chart;
  506. var legendOptions = chart.options.legend || {};
  507. var x,
  508. y,
  509. width,
  510. height;
  511. if (symbol) {
  512. this.left = x = symbol.attr('x');
  513. this.top = y = symbol.attr('y');
  514. this.width = width = symbol.attr('width');
  515. this.height = height = symbol.attr('height');
  516. this.right = chart.chartWidth - x - width;
  517. this.bottom = chart.chartHeight - y - height;
  518. this.len = this.horiz ? width : height;
  519. this.pos = this.horiz ? x : y;
  520. }
  521. else {
  522. // Fake length for disabled legend to avoid tick issues
  523. // and such (#5205)
  524. this.len = (this.horiz ?
  525. legendOptions.symbolWidth :
  526. legendOptions.symbolHeight) || ColorAxis.defaultLegendLength;
  527. }
  528. };
  529. /**
  530. * @private
  531. */
  532. ColorAxis.prototype.normalizedValue = function (value) {
  533. var axis = this;
  534. if (axis.logarithmic) {
  535. value = axis.logarithmic.log2lin(value);
  536. }
  537. return 1 - ((axis.max - value) /
  538. ((axis.max - axis.min) || 1));
  539. };
  540. /**
  541. * Translate from a value to a color.
  542. * @private
  543. */
  544. ColorAxis.prototype.toColor = function (value, point) {
  545. var axis = this;
  546. var dataClasses = axis.dataClasses;
  547. var stops = axis.stops;
  548. var pos,
  549. from,
  550. to,
  551. color,
  552. dataClass,
  553. i;
  554. if (dataClasses) {
  555. i = dataClasses.length;
  556. while (i--) {
  557. dataClass = dataClasses[i];
  558. from = dataClass.from;
  559. to = dataClass.to;
  560. if ((typeof from === 'undefined' || value >= from) &&
  561. (typeof to === 'undefined' || value <= to)) {
  562. color = dataClass.color;
  563. if (point) {
  564. point.dataClass = i;
  565. point.colorIndex = dataClass.colorIndex;
  566. }
  567. break;
  568. }
  569. }
  570. }
  571. else {
  572. pos = axis.normalizedValue(value);
  573. i = stops.length;
  574. while (i--) {
  575. if (pos > stops[i][0]) {
  576. break;
  577. }
  578. }
  579. from = stops[i] || stops[i + 1];
  580. to = stops[i + 1] || from;
  581. // The position within the gradient
  582. pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
  583. color = from.color.tweenTo(to.color, pos);
  584. }
  585. return color;
  586. };
  587. /**
  588. * Override the getOffset method to add the whole axis groups inside the
  589. * legend.
  590. * @private
  591. */
  592. ColorAxis.prototype.getOffset = function () {
  593. var axis = this;
  594. var group = axis.legendGroup;
  595. var sideOffset = axis.chart.axisOffset[axis.side];
  596. if (group) {
  597. // Hook for the getOffset method to add groups to this parent
  598. // group
  599. axis.axisParent = group;
  600. // Call the base
  601. _super.prototype.getOffset.call(this);
  602. // First time only
  603. if (!axis.added) {
  604. axis.added = true;
  605. axis.labelLeft = 0;
  606. axis.labelRight = axis.width;
  607. }
  608. // Reset it to avoid color axis reserving space
  609. axis.chart.axisOffset[axis.side] = sideOffset;
  610. }
  611. };
  612. /**
  613. * Create the color gradient.
  614. * @private
  615. */
  616. ColorAxis.prototype.setLegendColor = function () {
  617. var axis = this;
  618. var horiz = axis.horiz;
  619. var reversed = axis.reversed;
  620. var one = reversed ? 1 : 0;
  621. var zero = reversed ? 0 : 1;
  622. var grad = horiz ? [one, 0,
  623. zero, 0] : [0,
  624. zero, 0,
  625. one]; // #3190
  626. axis.legendColor = {
  627. linearGradient: {
  628. x1: grad[0],
  629. y1: grad[1],
  630. x2: grad[2],
  631. y2: grad[3]
  632. },
  633. stops: axis.stops
  634. };
  635. };
  636. /**
  637. * The color axis appears inside the legend and has its own legend symbol.
  638. * @private
  639. */
  640. ColorAxis.prototype.drawLegendSymbol = function (legend, item) {
  641. var axis = this;
  642. var padding = legend.padding;
  643. var legendOptions = legend.options;
  644. var horiz = axis.horiz;
  645. var width = pick(legendOptions.symbolWidth,
  646. horiz ? ColorAxis.defaultLegendLength : 12);
  647. var height = pick(legendOptions.symbolHeight,
  648. horiz ? 12 : ColorAxis.defaultLegendLength);
  649. var labelPadding = pick(legendOptions.labelPadding,
  650. horiz ? 16 : 30);
  651. var itemDistance = pick(legendOptions.itemDistance, 10);
  652. this.setLegendColor();
  653. // Create the gradient
  654. item.legendSymbol = this.chart.renderer.rect(0, legend.baseline - 11, width, height).attr({
  655. zIndex: 1
  656. }).add(item.legendGroup);
  657. // Set how much space this legend item takes up
  658. axis.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
  659. axis.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
  660. };
  661. /**
  662. * Fool the legend.
  663. * @private
  664. */
  665. ColorAxis.prototype.setState = function (state) {
  666. this.series.forEach(function (series) {
  667. series.setState(state);
  668. });
  669. };
  670. /**
  671. * @private
  672. */
  673. ColorAxis.prototype.setVisible = function () {
  674. };
  675. /**
  676. * @private
  677. */
  678. ColorAxis.prototype.getSeriesExtremes = function () {
  679. var axis = this;
  680. var series = axis.series;
  681. var colorValArray,
  682. colorKey,
  683. colorValIndex,
  684. pointArrayMap,
  685. calculatedExtremes,
  686. cSeries,
  687. i = series.length,
  688. yData,
  689. j;
  690. this.dataMin = Infinity;
  691. this.dataMax = -Infinity;
  692. while (i--) { // x, y, value, other
  693. cSeries = series[i];
  694. colorKey = cSeries.colorKey = pick(cSeries.options.colorKey, cSeries.colorKey, cSeries.pointValKey, cSeries.zoneAxis, 'y');
  695. pointArrayMap = cSeries.pointArrayMap;
  696. calculatedExtremes = cSeries[colorKey + 'Min'] &&
  697. cSeries[colorKey + 'Max'];
  698. if (cSeries[colorKey + 'Data']) {
  699. colorValArray = cSeries[colorKey + 'Data'];
  700. }
  701. else {
  702. if (!pointArrayMap) {
  703. colorValArray = cSeries.yData;
  704. }
  705. else {
  706. colorValArray = [];
  707. colorValIndex = pointArrayMap.indexOf(colorKey);
  708. yData = cSeries.yData;
  709. if (colorValIndex >= 0 && yData) {
  710. for (j = 0; j < yData.length; j++) {
  711. colorValArray.push(pick(yData[j][colorValIndex], yData[j]));
  712. }
  713. }
  714. }
  715. }
  716. // If color key extremes are already calculated, use them.
  717. if (calculatedExtremes) {
  718. cSeries.minColorValue = cSeries[colorKey + 'Min'];
  719. cSeries.maxColorValue = cSeries[colorKey + 'Max'];
  720. }
  721. else {
  722. var cExtremes = Series.prototype.getExtremes.call(cSeries,
  723. colorValArray);
  724. cSeries.minColorValue = cExtremes.dataMin;
  725. cSeries.maxColorValue = cExtremes.dataMax;
  726. }
  727. if (typeof cSeries.minColorValue !== 'undefined') {
  728. this.dataMin =
  729. Math.min(this.dataMin, cSeries.minColorValue);
  730. this.dataMax =
  731. Math.max(this.dataMax, cSeries.maxColorValue);
  732. }
  733. if (!calculatedExtremes) {
  734. Series.prototype.applyExtremes.call(cSeries);
  735. }
  736. }
  737. };
  738. /**
  739. * Internal function to draw a crosshair.
  740. *
  741. * @function Highcharts.ColorAxis#drawCrosshair
  742. *
  743. * @param {Highcharts.PointerEventObject} [e]
  744. * The event arguments from the modified pointer event, extended with
  745. * `chartX` and `chartY`
  746. *
  747. * @param {Highcharts.Point} [point]
  748. * The Point object if the crosshair snaps to points.
  749. *
  750. * @fires Highcharts.ColorAxis#event:afterDrawCrosshair
  751. * @fires Highcharts.ColorAxis#event:drawCrosshair
  752. */
  753. ColorAxis.prototype.drawCrosshair = function (e, point) {
  754. var axis = this;
  755. var plotX = point && point.plotX;
  756. var plotY = point && point.plotY;
  757. var axisPos = axis.pos;
  758. var axisLen = axis.len;
  759. var crossPos;
  760. if (point) {
  761. crossPos = axis.toPixels(point.getNestedProperty(point.series.colorKey));
  762. if (crossPos < axisPos) {
  763. crossPos = axisPos - 2;
  764. }
  765. else if (crossPos > axisPos + axisLen) {
  766. crossPos = axisPos + axisLen + 2;
  767. }
  768. point.plotX = crossPos;
  769. point.plotY = axis.len - crossPos;
  770. _super.prototype.drawCrosshair.call(this, e, point);
  771. point.plotX = plotX;
  772. point.plotY = plotY;
  773. if (axis.cross &&
  774. !axis.cross.addedToColorAxis &&
  775. axis.legendGroup) {
  776. axis.cross
  777. .addClass('highcharts-coloraxis-marker')
  778. .add(axis.legendGroup);
  779. axis.cross.addedToColorAxis = true;
  780. if (!axis.chart.styledMode &&
  781. axis.crosshair) {
  782. axis.cross.attr({
  783. fill: axis.crosshair.color
  784. });
  785. }
  786. }
  787. }
  788. };
  789. /**
  790. * @private
  791. */
  792. ColorAxis.prototype.getPlotLinePath = function (options) {
  793. var axis = this,
  794. left = axis.left,
  795. pos = options.translatedValue,
  796. top = axis.top;
  797. // crosshairs only
  798. return isNumber(pos) ? // pos can be 0 (#3969)
  799. (axis.horiz ? [
  800. ['M', pos - 4, top - 6],
  801. ['L', pos + 4, top - 6],
  802. ['L', pos, top],
  803. ['Z']
  804. ] : [
  805. ['M', left, pos],
  806. ['L', left - 6, pos + 6],
  807. ['L', left - 6, pos - 6],
  808. ['Z']
  809. ]) :
  810. _super.prototype.getPlotLinePath.call(this, options);
  811. };
  812. /**
  813. * Updates a color axis instance with a new set of options. The options are
  814. * merged with the existing options, so only new or altered options need to
  815. * be specified.
  816. *
  817. * @function Highcharts.ColorAxis#update
  818. *
  819. * @param {Highcharts.ColorAxisOptions} newOptions
  820. * The new options that will be merged in with existing options on the color
  821. * axis.
  822. *
  823. * @param {boolean} [redraw]
  824. * Whether to redraw the chart after the color axis is altered. If doing
  825. * more operations on the chart, it is a good idea to set redraw to `false`
  826. * and call {@link Highcharts.Chart#redraw} after.
  827. */
  828. ColorAxis.prototype.update = function (newOptions, redraw) {
  829. var axis = this,
  830. chart = axis.chart,
  831. legend = chart.legend;
  832. this.series.forEach(function (series) {
  833. // Needed for Axis.update when choropleth colors change
  834. series.isDirtyData = true;
  835. });
  836. // When updating data classes, destroy old items and make sure new
  837. // ones are created (#3207)
  838. if (newOptions.dataClasses && legend.allItems || axis.dataClasses) {
  839. axis.destroyItems();
  840. }
  841. _super.prototype.update.call(this, newOptions, redraw);
  842. if (axis.legendItem) {
  843. axis.setLegendColor();
  844. legend.colorizeItem(this, true);
  845. }
  846. };
  847. /**
  848. * Destroy color axis legend items.
  849. * @private
  850. */
  851. ColorAxis.prototype.destroyItems = function () {
  852. var axis = this;
  853. var chart = axis.chart;
  854. if (axis.legendItem) {
  855. chart.legend.destroyItem(axis);
  856. }
  857. else if (axis.legendItems) {
  858. axis.legendItems.forEach(function (item) {
  859. chart.legend.destroyItem(item);
  860. });
  861. }
  862. chart.isDirtyLegend = true;
  863. };
  864. // Removing the whole axis (#14283)
  865. ColorAxis.prototype.destroy = function () {
  866. this.chart.isDirtyLegend = true;
  867. this.destroyItems();
  868. _super.prototype.destroy.apply(this, [].slice.call(arguments));
  869. };
  870. /**
  871. * Removes the color axis and the related legend item.
  872. *
  873. * @function Highcharts.ColorAxis#remove
  874. *
  875. * @param {boolean} [redraw=true]
  876. * Whether to redraw the chart following the remove.
  877. */
  878. ColorAxis.prototype.remove = function (redraw) {
  879. this.destroyItems();
  880. _super.prototype.remove.call(this, redraw);
  881. };
  882. /**
  883. * Get the legend item symbols for data classes.
  884. * @private
  885. */
  886. ColorAxis.prototype.getDataClassLegendSymbols = function () {
  887. var axis = this;
  888. var chart = axis.chart;
  889. var legendItems = axis.legendItems;
  890. var legendOptions = chart.options.legend;
  891. var valueDecimals = legendOptions.valueDecimals;
  892. var valueSuffix = legendOptions.valueSuffix || '';
  893. var name;
  894. if (!legendItems.length) {
  895. axis.dataClasses.forEach(function (dataClass, i) {
  896. var vis = true,
  897. from = dataClass.from,
  898. to = dataClass.to;
  899. var numberFormatter = chart.numberFormatter;
  900. // Assemble the default name. This can be overridden
  901. // by legend.options.labelFormatter
  902. name = '';
  903. if (typeof from === 'undefined') {
  904. name = '< ';
  905. }
  906. else if (typeof to === 'undefined') {
  907. name = '> ';
  908. }
  909. if (typeof from !== 'undefined') {
  910. name += numberFormatter(from, valueDecimals) + valueSuffix;
  911. }
  912. if (typeof from !== 'undefined' && typeof to !== 'undefined') {
  913. name += ' - ';
  914. }
  915. if (typeof to !== 'undefined') {
  916. name += numberFormatter(to, valueDecimals) + valueSuffix;
  917. }
  918. // Add a mock object to the legend items
  919. legendItems.push(extend({
  920. chart: chart,
  921. name: name,
  922. options: {},
  923. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  924. visible: true,
  925. setState: noop,
  926. isDataClass: true,
  927. setVisible: function () {
  928. vis = axis.visible = !vis;
  929. axis.series.forEach(function (series) {
  930. series.points.forEach(function (point) {
  931. if (point.dataClass === i) {
  932. point.setVisible(vis);
  933. }
  934. });
  935. });
  936. chart.legend.colorizeItem(this, vis);
  937. }
  938. }, dataClass));
  939. });
  940. }
  941. return legendItems;
  942. };
  943. /* *
  944. *
  945. * Static Functions
  946. *
  947. * */
  948. ColorAxis.defaultLegendLength = 200;
  949. /**
  950. * A color axis for series. Visually, the color
  951. * axis will appear as a gradient or as separate items inside the
  952. * legend, depending on whether the axis is scalar or based on data
  953. * classes.
  954. *
  955. * For supported color formats, see the
  956. * [docs article about colors](https://www.highcharts.com/docs/chart-design-and-style/colors).
  957. *
  958. * A scalar color axis is represented by a gradient. The colors either
  959. * range between the [minColor](#colorAxis.minColor) and the
  960. * [maxColor](#colorAxis.maxColor), or for more fine grained control the
  961. * colors can be defined in [stops](#colorAxis.stops). Often times, the
  962. * color axis needs to be adjusted to get the right color spread for the
  963. * data. In addition to stops, consider using a logarithmic
  964. * [axis type](#colorAxis.type), or setting [min](#colorAxis.min) and
  965. * [max](#colorAxis.max) to avoid the colors being determined by
  966. * outliers.
  967. *
  968. * When [dataClasses](#colorAxis.dataClasses) are used, the ranges are
  969. * subdivided into separate classes like categories based on their
  970. * values. This can be used for ranges between two values, but also for
  971. * a true category. However, when your data is categorized, it may be as
  972. * convenient to add each category to a separate series.
  973. *
  974. * Color axis does not work with: `sankey`, `sunburst`, `dependencywheel`,
  975. * `networkgraph`, `wordcloud`, `venn`, `gauge` and `solidgauge` series
  976. * types.
  977. *
  978. * Since v7.2.0 `colorAxis` can also be an array of options objects.
  979. *
  980. * See [the Axis object](/class-reference/Highcharts.Axis) for
  981. * programmatic access to the axis.
  982. *
  983. * @sample {highcharts} highcharts/coloraxis/custom-color-key
  984. * Column chart with color axis
  985. * @sample {highcharts} highcharts/coloraxis/horizontal-layout
  986. * Horizontal layout
  987. * @sample {highmaps} maps/coloraxis/dataclasscolor
  988. * With data classes
  989. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor
  990. * Min color and max color
  991. *
  992. * @extends xAxis
  993. * @excluding alignTicks, allowDecimals, alternateGridColor, breaks,
  994. * categories, crosshair, dateTimeLabelFormats, height, left,
  995. * lineWidth, linkedTo, maxZoom, minRange, minTickInterval,
  996. * offset, opposite, pane, plotBands, plotLines,
  997. * reversedStacks, showEmpty, title, top, width, zoomEnabled
  998. * @product highcharts highstock highmaps
  999. * @type {*|Array<*>}
  1000. * @optionparent colorAxis
  1001. * @ignore
  1002. */
  1003. ColorAxis.defaultOptions = {
  1004. /**
  1005. * Whether to allow decimals on the color axis.
  1006. * @type {boolean}
  1007. * @default true
  1008. * @product highcharts highstock highmaps
  1009. * @apioption colorAxis.allowDecimals
  1010. */
  1011. /**
  1012. * Determines how to set each data class' color if no individual
  1013. * color is set. The default value, `tween`, computes intermediate
  1014. * colors between `minColor` and `maxColor`. The other possible
  1015. * value, `category`, pulls colors from the global or chart specific
  1016. * [colors](#colors) array.
  1017. *
  1018. * @sample {highmaps} maps/coloraxis/dataclasscolor/
  1019. * Category colors
  1020. *
  1021. * @type {string}
  1022. * @default tween
  1023. * @product highcharts highstock highmaps
  1024. * @validvalue ["tween", "category"]
  1025. * @apioption colorAxis.dataClassColor
  1026. */
  1027. /**
  1028. * An array of data classes or ranges for the choropleth map. If
  1029. * none given, the color axis is scalar and values are distributed
  1030. * as a gradient between the minimum and maximum colors.
  1031. *
  1032. * @sample {highmaps} maps/demo/data-class-ranges/
  1033. * Multiple ranges
  1034. *
  1035. * @sample {highmaps} maps/demo/data-class-two-ranges/
  1036. * Two ranges
  1037. *
  1038. * @type {Array<*>}
  1039. * @product highcharts highstock highmaps
  1040. * @apioption colorAxis.dataClasses
  1041. */
  1042. /**
  1043. * The layout of the color axis. Can be `'horizontal'` or `'vertical'`.
  1044. * If none given, the color axis has the same layout as the legend.
  1045. *
  1046. * @sample highcharts/coloraxis/horizontal-layout/
  1047. * Horizontal color axis layout with vertical legend
  1048. *
  1049. * @type {string|undefined}
  1050. * @since 7.2.0
  1051. * @product highcharts highstock highmaps
  1052. * @apioption colorAxis.layout
  1053. */
  1054. /**
  1055. * The color of each data class. If not set, the color is pulled
  1056. * from the global or chart-specific [colors](#colors) array. In
  1057. * styled mode, this option is ignored. Instead, use colors defined
  1058. * in CSS.
  1059. *
  1060. * @sample {highmaps} maps/demo/data-class-two-ranges/
  1061. * Explicit colors
  1062. *
  1063. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1064. * @product highcharts highstock highmaps
  1065. * @apioption colorAxis.dataClasses.color
  1066. */
  1067. /**
  1068. * The start of the value range that the data class represents,
  1069. * relating to the point value.
  1070. *
  1071. * The range of each `dataClass` is closed in both ends, but can be
  1072. * overridden by the next `dataClass`.
  1073. *
  1074. * @type {number}
  1075. * @product highcharts highstock highmaps
  1076. * @apioption colorAxis.dataClasses.from
  1077. */
  1078. /**
  1079. * The name of the data class as it appears in the legend.
  1080. * If no name is given, it is automatically created based on the
  1081. * `from` and `to` values. For full programmatic control,
  1082. * [legend.labelFormatter](#legend.labelFormatter) can be used.
  1083. * In the formatter, `this.from` and `this.to` can be accessed.
  1084. *
  1085. * @sample {highmaps} maps/coloraxis/dataclasses-name/
  1086. * Named data classes
  1087. *
  1088. * @sample {highmaps} maps/coloraxis/dataclasses-labelformatter/
  1089. * Formatted data classes
  1090. *
  1091. * @type {string}
  1092. * @product highcharts highstock highmaps
  1093. * @apioption colorAxis.dataClasses.name
  1094. */
  1095. /**
  1096. * The end of the value range that the data class represents,
  1097. * relating to the point value.
  1098. *
  1099. * The range of each `dataClass` is closed in both ends, but can be
  1100. * overridden by the next `dataClass`.
  1101. *
  1102. * @type {number}
  1103. * @product highcharts highstock highmaps
  1104. * @apioption colorAxis.dataClasses.to
  1105. */
  1106. /** @ignore-option */
  1107. lineWidth: 0,
  1108. /**
  1109. * Padding of the min value relative to the length of the axis. A
  1110. * padding of 0.05 will make a 100px axis 5px longer.
  1111. *
  1112. * @product highcharts highstock highmaps
  1113. */
  1114. minPadding: 0,
  1115. /**
  1116. * The maximum value of the axis in terms of map point values. If
  1117. * `null`, the max value is automatically calculated. If the
  1118. * `endOnTick` option is true, the max value might be rounded up.
  1119. *
  1120. * @sample {highmaps} maps/coloraxis/gridlines/
  1121. * Explicit min and max to reduce the effect of outliers
  1122. *
  1123. * @type {number}
  1124. * @product highcharts highstock highmaps
  1125. * @apioption colorAxis.max
  1126. */
  1127. /**
  1128. * The minimum value of the axis in terms of map point values. If
  1129. * `null`, the min value is automatically calculated. If the
  1130. * `startOnTick` option is true, the min value might be rounded
  1131. * down.
  1132. *
  1133. * @sample {highmaps} maps/coloraxis/gridlines/
  1134. * Explicit min and max to reduce the effect of outliers
  1135. *
  1136. * @type {number}
  1137. * @product highcharts highstock highmaps
  1138. * @apioption colorAxis.min
  1139. */
  1140. /**
  1141. * Padding of the max value relative to the length of the axis. A
  1142. * padding of 0.05 will make a 100px axis 5px longer.
  1143. *
  1144. * @product highcharts highstock highmaps
  1145. */
  1146. maxPadding: 0,
  1147. /**
  1148. * Color of the grid lines extending from the axis across the
  1149. * gradient.
  1150. *
  1151. * @sample {highmaps} maps/coloraxis/gridlines/
  1152. * Grid lines demonstrated
  1153. *
  1154. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1155. * @default #e6e6e6
  1156. * @product highcharts highstock highmaps
  1157. * @apioption colorAxis.gridLineColor
  1158. */
  1159. /**
  1160. * The width of the grid lines extending from the axis across the
  1161. * gradient of a scalar color axis.
  1162. *
  1163. * @sample {highmaps} maps/coloraxis/gridlines/
  1164. * Grid lines demonstrated
  1165. *
  1166. * @product highcharts highstock highmaps
  1167. */
  1168. gridLineWidth: 1,
  1169. /**
  1170. * The interval of the tick marks in axis units. When `null`, the
  1171. * tick interval is computed to approximately follow the
  1172. * `tickPixelInterval`.
  1173. *
  1174. * @type {number}
  1175. * @product highcharts highstock highmaps
  1176. * @apioption colorAxis.tickInterval
  1177. */
  1178. /**
  1179. * If [tickInterval](#colorAxis.tickInterval) is `null` this option
  1180. * sets the approximate pixel interval of the tick marks.
  1181. *
  1182. * @product highcharts highstock highmaps
  1183. */
  1184. tickPixelInterval: 72,
  1185. /**
  1186. * Whether to force the axis to start on a tick. Use this option
  1187. * with the `maxPadding` option to control the axis start.
  1188. *
  1189. * @product highcharts highstock highmaps
  1190. */
  1191. startOnTick: true,
  1192. /**
  1193. * Whether to force the axis to end on a tick. Use this option with
  1194. * the [maxPadding](#colorAxis.maxPadding) option to control the
  1195. * axis end.
  1196. *
  1197. * @product highcharts highstock highmaps
  1198. */
  1199. endOnTick: true,
  1200. /** @ignore */
  1201. offset: 0,
  1202. /**
  1203. * The triangular marker on a scalar color axis that points to the
  1204. * value of the hovered area. To disable the marker, set
  1205. * `marker: null`.
  1206. *
  1207. * @sample {highmaps} maps/coloraxis/marker/
  1208. * Black marker
  1209. *
  1210. * @declare Highcharts.PointMarkerOptionsObject
  1211. * @product highcharts highstock highmaps
  1212. */
  1213. marker: {
  1214. /**
  1215. * Animation for the marker as it moves between values. Set to
  1216. * `false` to disable animation. Defaults to `{ duration: 50 }`.
  1217. *
  1218. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  1219. * @product highcharts highstock highmaps
  1220. */
  1221. animation: {
  1222. /** @internal */
  1223. duration: 50
  1224. },
  1225. /** @internal */
  1226. width: 0.01,
  1227. /**
  1228. * The color of the marker.
  1229. *
  1230. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1231. * @product highcharts highstock highmaps
  1232. */
  1233. color: palette.neutralColor40
  1234. },
  1235. /**
  1236. * The axis labels show the number for each tick.
  1237. *
  1238. * For more live examples on label options, see [xAxis.labels in the
  1239. * Highcharts API.](/highcharts#xAxis.labels)
  1240. *
  1241. * @extends xAxis.labels
  1242. * @product highcharts highstock highmaps
  1243. */
  1244. labels: {
  1245. /**
  1246. * How to handle overflowing labels on horizontal color axis. If set
  1247. * to `"allow"`, it will not be aligned at all. By default it
  1248. * `"justify"` labels inside the chart area. If there is room to
  1249. * move it, it will be aligned to the edge, else it will be removed.
  1250. *
  1251. * @validvalue ["allow", "justify"]
  1252. * @product highcharts highstock highmaps
  1253. */
  1254. overflow: 'justify',
  1255. rotation: 0
  1256. },
  1257. /**
  1258. * The color to represent the minimum of the color axis. Unless
  1259. * [dataClasses](#colorAxis.dataClasses) or
  1260. * [stops](#colorAxis.stops) are set, the gradient starts at this
  1261. * value.
  1262. *
  1263. * If dataClasses are set, the color is based on minColor and
  1264. * maxColor unless a color is set for each data class, or the
  1265. * [dataClassColor](#colorAxis.dataClassColor) is set.
  1266. *
  1267. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  1268. * Min and max colors on scalar (gradient) axis
  1269. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  1270. * On data classes
  1271. *
  1272. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1273. * @product highcharts highstock highmaps
  1274. */
  1275. minColor: palette.highlightColor10,
  1276. /**
  1277. * The color to represent the maximum of the color axis. Unless
  1278. * [dataClasses](#colorAxis.dataClasses) or
  1279. * [stops](#colorAxis.stops) are set, the gradient ends at this
  1280. * value.
  1281. *
  1282. * If dataClasses are set, the color is based on minColor and
  1283. * maxColor unless a color is set for each data class, or the
  1284. * [dataClassColor](#colorAxis.dataClassColor) is set.
  1285. *
  1286. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor/
  1287. * Min and max colors on scalar (gradient) axis
  1288. * @sample {highmaps} maps/coloraxis/mincolor-maxcolor-dataclasses/
  1289. * On data classes
  1290. *
  1291. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1292. * @product highcharts highstock highmaps
  1293. */
  1294. maxColor: palette.highlightColor100,
  1295. /**
  1296. * Color stops for the gradient of a scalar color axis. Use this in
  1297. * cases where a linear gradient between a `minColor` and `maxColor`
  1298. * is not sufficient. The stops is an array of tuples, where the
  1299. * first item is a float between 0 and 1 assigning the relative
  1300. * position in the gradient, and the second item is the color.
  1301. *
  1302. * @sample {highmaps} maps/demo/heatmap/
  1303. * Heatmap with three color stops
  1304. *
  1305. * @type {Array<Array<number,Highcharts.ColorString>>}
  1306. * @product highcharts highstock highmaps
  1307. * @apioption colorAxis.stops
  1308. */
  1309. /**
  1310. * The pixel length of the main tick marks on the color axis.
  1311. */
  1312. tickLength: 5,
  1313. /**
  1314. * The type of interpolation to use for the color axis. Can be
  1315. * `linear` or `logarithmic`.
  1316. *
  1317. * @sample highcharts/coloraxis/logarithmic-with-emulate-negative-values/
  1318. * Logarithmic color axis with extension to emulate negative
  1319. * values
  1320. *
  1321. * @type {Highcharts.ColorAxisTypeValue}
  1322. * @default linear
  1323. * @product highcharts highstock highmaps
  1324. * @apioption colorAxis.type
  1325. */
  1326. /**
  1327. * Whether to reverse the axis so that the highest number is closest
  1328. * to the origin. Defaults to `false` in a horizontal legend and
  1329. * `true` in a vertical legend, where the smallest value starts on
  1330. * top.
  1331. *
  1332. * @type {boolean}
  1333. * @product highcharts highstock highmaps
  1334. * @apioption colorAxis.reversed
  1335. */
  1336. /**
  1337. * @product highcharts highstock highmaps
  1338. * @excluding afterBreaks, pointBreak, pointInBreak
  1339. * @apioption colorAxis.events
  1340. */
  1341. /**
  1342. * Fires when the legend item belonging to the colorAxis is clicked.
  1343. * One parameter, `event`, is passed to the function.
  1344. *
  1345. * @type {Function}
  1346. * @product highcharts highstock highmaps
  1347. * @apioption colorAxis.events.legendItemClick
  1348. */
  1349. /**
  1350. * Whether to display the colorAxis in the legend.
  1351. *
  1352. * @sample highcharts/coloraxis/hidden-coloraxis-with-3d-chart/
  1353. * Hidden color axis with 3d chart
  1354. *
  1355. * @see [heatmap.showInLegend](#series.heatmap.showInLegend)
  1356. *
  1357. * @since 4.2.7
  1358. * @product highcharts highstock highmaps
  1359. */
  1360. showInLegend: true
  1361. };
  1362. /**
  1363. * @private
  1364. */
  1365. ColorAxis.keepProps = [
  1366. 'legendGroup',
  1367. 'legendItemHeight',
  1368. 'legendItemWidth',
  1369. 'legendItem',
  1370. 'legendSymbol'
  1371. ];
  1372. return ColorAxis;
  1373. }(Axis));
  1374. // Properties to preserve after destroy, for Axis.update (#5881, #6025).
  1375. Array.prototype.push.apply(Axis.keepProps, ColorAxis.keepProps);
  1376. H.ColorAxis = ColorAxis;
  1377. /**
  1378. * Handle animation of the color attributes directly
  1379. *
  1380. * @private
  1381. * @function Highcharts.Fx#fillSetter
  1382. */ /**
  1383. * Handle animation of the color attributes directly
  1384. *
  1385. * @private
  1386. * @function Highcharts.Fx#strokeSetter
  1387. */
  1388. ['fill', 'stroke'].forEach(function (prop) {
  1389. Fx.prototype[prop + 'Setter'] = function () {
  1390. this.elem.attr(prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  1391. };
  1392. });
  1393. // Extend the chart getAxes method to also get the color axis
  1394. addEvent(Chart, 'afterGetAxes', function () {
  1395. var chart = this,
  1396. options = chart.options;
  1397. this.colorAxis = [];
  1398. if (options.colorAxis) {
  1399. options.colorAxis = splat(options.colorAxis);
  1400. options.colorAxis.forEach(function (axisOptions, i) {
  1401. axisOptions.index = i;
  1402. new ColorAxis(chart, axisOptions); // eslint-disable-line no-new
  1403. });
  1404. }
  1405. });
  1406. // Add colorAxis to series axisTypes
  1407. addEvent(Series, 'bindAxes', function () {
  1408. var axisTypes = this.axisTypes;
  1409. if (!axisTypes) {
  1410. this.axisTypes = ['colorAxis'];
  1411. }
  1412. else if (axisTypes.indexOf('colorAxis') === -1) {
  1413. axisTypes.push('colorAxis');
  1414. }
  1415. });
  1416. // Add the color axis. This also removes the axis' own series to prevent
  1417. // them from showing up individually.
  1418. addEvent(Legend, 'afterGetAllItems', function (e) {
  1419. var colorAxisItems = [],
  1420. colorAxes = this.chart.colorAxis || [],
  1421. options,
  1422. i;
  1423. colorAxes.forEach(function (colorAxis) {
  1424. options = colorAxis.options;
  1425. if (options && options.showInLegend) {
  1426. // Data classes
  1427. if (options.dataClasses && options.visible) {
  1428. colorAxisItems = colorAxisItems.concat(colorAxis.getDataClassLegendSymbols());
  1429. // Gradient legend
  1430. }
  1431. else if (options.visible) {
  1432. // Add this axis on top
  1433. colorAxisItems.push(colorAxis);
  1434. }
  1435. // If dataClasses are defined or showInLegend option is not set to
  1436. // true, do not add color axis' series to legend.
  1437. colorAxis.series.forEach(function (series) {
  1438. if (!series.options.showInLegend || options.dataClasses) {
  1439. if (series.options.legendType === 'point') {
  1440. series.points.forEach(function (point) {
  1441. erase(e.allItems, point);
  1442. });
  1443. }
  1444. else {
  1445. erase(e.allItems, series);
  1446. }
  1447. }
  1448. });
  1449. }
  1450. });
  1451. i = colorAxisItems.length;
  1452. while (i--) {
  1453. e.allItems.unshift(colorAxisItems[i]);
  1454. }
  1455. });
  1456. addEvent(Legend, 'afterColorizeItem', function (e) {
  1457. if (e.visible && e.item.legendColor) {
  1458. e.item.legendSymbol.attr({
  1459. fill: e.item.legendColor
  1460. });
  1461. }
  1462. });
  1463. // Updates in the legend need to be reflected in the color axis (6888)
  1464. addEvent(Legend, 'afterUpdate', function () {
  1465. var colorAxes = this.chart.colorAxis;
  1466. if (colorAxes) {
  1467. colorAxes.forEach(function (colorAxis) {
  1468. colorAxis.update({}, arguments[2]);
  1469. });
  1470. }
  1471. });
  1472. // Calculate and set colors for points
  1473. addEvent(Series, 'afterTranslate', function () {
  1474. if (this.chart.colorAxis &&
  1475. this.chart.colorAxis.length ||
  1476. this.colorAttribs) {
  1477. this.translateColors();
  1478. }
  1479. });
  1480. return ColorAxis;
  1481. });
  1482. _registerModule(_modules, 'Mixins/ColorMapSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  1483. /* *
  1484. *
  1485. * (c) 2010-2021 Torstein Honsi
  1486. *
  1487. * License: www.highcharts.com/license
  1488. *
  1489. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1490. *
  1491. * */
  1492. var defined = U.defined;
  1493. var noop = H.noop,
  1494. seriesTypes = H.seriesTypes;
  1495. /**
  1496. * Mixin for maps and heatmaps
  1497. *
  1498. * @private
  1499. * @mixin Highcharts.colorMapPointMixin
  1500. */
  1501. var colorMapPointMixin = {
  1502. dataLabelOnNull: true,
  1503. /* eslint-disable valid-jsdoc */
  1504. /**
  1505. * Color points have a value option that determines whether or not it is
  1506. * a null point
  1507. * @private
  1508. */
  1509. isValid: function () {
  1510. // undefined is allowed
  1511. return (this.value !== null &&
  1512. this.value !== Infinity &&
  1513. this.value !== -Infinity);
  1514. },
  1515. /**
  1516. * @private
  1517. */
  1518. setState: function (state) {
  1519. Point.prototype.setState.call(this, state);
  1520. if (this.graphic) {
  1521. this.graphic.attr({
  1522. zIndex: state === 'hover' ? 1 : 0
  1523. });
  1524. }
  1525. }
  1526. /* eslint-enable valid-jsdoc */
  1527. };
  1528. /**
  1529. * @private
  1530. * @mixin Highcharts.colorMapSeriesMixin
  1531. */
  1532. var colorMapSeriesMixin = {
  1533. pointArrayMap: ['value'],
  1534. axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
  1535. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  1536. getSymbol: noop,
  1537. parallelArrays: ['x', 'y', 'value'],
  1538. colorKey: 'value',
  1539. pointAttribs: seriesTypes.column.prototype.pointAttribs,
  1540. /* eslint-disable valid-jsdoc */
  1541. /**
  1542. * Get the color attibutes to apply on the graphic
  1543. * @private
  1544. * @function Highcharts.colorMapSeriesMixin.colorAttribs
  1545. * @param {Highcharts.Point} point
  1546. * @return {Highcharts.SVGAttributes}
  1547. */
  1548. colorAttribs: function (point) {
  1549. var ret = {};
  1550. if (defined(point.color)) {
  1551. ret[this.colorProp || 'fill'] = point.color;
  1552. }
  1553. return ret;
  1554. }
  1555. };
  1556. var exports = {
  1557. colorMapPointMixin: colorMapPointMixin,
  1558. colorMapSeriesMixin: colorMapSeriesMixin
  1559. };
  1560. return exports;
  1561. });
  1562. _registerModule(_modules, 'Maps/MapNavigationOptionsDefault.js', [_modules['Core/Options.js'], _modules['Core/Utilities.js']], function (O, U) {
  1563. /* *
  1564. *
  1565. * (c) 2010-2021 Torstein Honsi
  1566. *
  1567. * License: www.highcharts.com/license
  1568. *
  1569. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1570. *
  1571. * */
  1572. var extend = U.extend;
  1573. /* *
  1574. *
  1575. * Constants
  1576. *
  1577. * */
  1578. /**
  1579. * @product highmaps
  1580. * @optionparent mapNavigation
  1581. */
  1582. var defaultOptions = {
  1583. /**
  1584. * General options for the map navigation buttons. Individual options
  1585. * can be given from the [mapNavigation.buttons](#mapNavigation.buttons)
  1586. * option set.
  1587. *
  1588. * @sample {highmaps} maps/mapnavigation/button-theme/
  1589. * Theming the navigation buttons
  1590. */
  1591. buttonOptions: {
  1592. /**
  1593. * What box to align the buttons to. Possible values are `plotBox`
  1594. * and `spacingBox`.
  1595. *
  1596. * @type {Highcharts.ButtonRelativeToValue}
  1597. */
  1598. alignTo: 'plotBox',
  1599. /**
  1600. * The alignment of the navigation buttons.
  1601. *
  1602. * @type {Highcharts.AlignValue}
  1603. */
  1604. align: 'left',
  1605. /**
  1606. * The vertical alignment of the buttons. Individual alignment can
  1607. * be adjusted by each button's `y` offset.
  1608. *
  1609. * @type {Highcharts.VerticalAlignValue}
  1610. */
  1611. verticalAlign: 'top',
  1612. /**
  1613. * The X offset of the buttons relative to its `align` setting.
  1614. */
  1615. x: 0,
  1616. /**
  1617. * The width of the map navigation buttons.
  1618. */
  1619. width: 18,
  1620. /**
  1621. * The pixel height of the map navigation buttons.
  1622. */
  1623. height: 18,
  1624. /**
  1625. * Padding for the navigation buttons.
  1626. *
  1627. * @since 5.0.0
  1628. */
  1629. padding: 5,
  1630. /**
  1631. * Text styles for the map navigation buttons.
  1632. *
  1633. * @type {Highcharts.CSSObject}
  1634. * @default {"fontSize": "15px", "fontWeight": "bold"}
  1635. */
  1636. style: {
  1637. /** @ignore */
  1638. fontSize: '15px',
  1639. /** @ignore */
  1640. fontWeight: 'bold'
  1641. },
  1642. /**
  1643. * A configuration object for the button theme. The object accepts
  1644. * SVG properties like `stroke-width`, `stroke` and `fill`. Tri-state
  1645. * button styles are supported by the `states.hover` and `states.select`
  1646. * objects.
  1647. *
  1648. * @sample {highmaps} maps/mapnavigation/button-theme/
  1649. * Themed navigation buttons
  1650. *
  1651. * @type {Highcharts.SVGAttributes}
  1652. * @default {"stroke-width": 1, "text-align": "center"}
  1653. */
  1654. theme: {
  1655. /** @ignore */
  1656. 'stroke-width': 1,
  1657. /** @ignore */
  1658. 'text-align': 'center'
  1659. }
  1660. },
  1661. /**
  1662. * The individual buttons for the map navigation. This usually includes
  1663. * the zoom in and zoom out buttons. Properties for each button is
  1664. * inherited from
  1665. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  1666. * individual options can be overridden. But default, the `onclick`, `text`
  1667. * and `y` options are individual.
  1668. */
  1669. buttons: {
  1670. /**
  1671. * Options for the zoom in button. Properties for the zoom in and zoom
  1672. * out buttons are inherited from
  1673. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  1674. * individual options can be overridden. By default, the `onclick`,
  1675. * `text` and `y` options are individual.
  1676. *
  1677. * @extends mapNavigation.buttonOptions
  1678. */
  1679. zoomIn: {
  1680. // eslint-disable-next-line valid-jsdoc
  1681. /**
  1682. * Click handler for the button.
  1683. *
  1684. * @type {Function}
  1685. * @default function () { this.mapZoom(0.5); }
  1686. */
  1687. onclick: function () {
  1688. this.mapZoom(0.5);
  1689. },
  1690. /**
  1691. * The text for the button. The tooltip (title) is a language option
  1692. * given by [lang.zoomIn](#lang.zoomIn).
  1693. */
  1694. text: '+',
  1695. /**
  1696. * The position of the zoomIn button relative to the vertical
  1697. * alignment.
  1698. */
  1699. y: 0
  1700. },
  1701. /**
  1702. * Options for the zoom out button. Properties for the zoom in and
  1703. * zoom out buttons are inherited from
  1704. * [mapNavigation.buttonOptions](#mapNavigation.buttonOptions), while
  1705. * individual options can be overridden. By default, the `onclick`,
  1706. * `text` and `y` options are individual.
  1707. *
  1708. * @extends mapNavigation.buttonOptions
  1709. */
  1710. zoomOut: {
  1711. // eslint-disable-next-line valid-jsdoc
  1712. /**
  1713. * Click handler for the button.
  1714. *
  1715. * @type {Function}
  1716. * @default function () { this.mapZoom(2); }
  1717. */
  1718. onclick: function () {
  1719. this.mapZoom(2);
  1720. },
  1721. /**
  1722. * The text for the button. The tooltip (title) is a language option
  1723. * given by [lang.zoomOut](#lang.zoomIn).
  1724. */
  1725. text: '-',
  1726. /**
  1727. * The position of the zoomOut button relative to the vertical
  1728. * alignment.
  1729. */
  1730. y: 28
  1731. }
  1732. },
  1733. /**
  1734. * Whether to enable navigation buttons. By default it inherits the
  1735. * [enabled](#mapNavigation.enabled) setting.
  1736. *
  1737. * @type {boolean}
  1738. * @apioption mapNavigation.enableButtons
  1739. */
  1740. /**
  1741. * Whether to enable map navigation. The default is not to enable
  1742. * navigation, as many choropleth maps are simple and don't need it.
  1743. * Additionally, when touch zoom and mousewheel zoom is enabled, it breaks
  1744. * the default behaviour of these interactions in the website, and the
  1745. * implementer should be aware of this.
  1746. *
  1747. * Individual interactions can be enabled separately, namely buttons,
  1748. * multitouch zoom, double click zoom, double click zoom to element and
  1749. * mousewheel zoom.
  1750. *
  1751. * @type {boolean}
  1752. * @default false
  1753. * @apioption mapNavigation.enabled
  1754. */
  1755. /**
  1756. * Enables zooming in on an area on double clicking in the map. By default
  1757. * it inherits the [enabled](#mapNavigation.enabled) setting.
  1758. *
  1759. * @type {boolean}
  1760. * @apioption mapNavigation.enableDoubleClickZoom
  1761. */
  1762. /**
  1763. * Whether to zoom in on an area when that area is double clicked.
  1764. *
  1765. * @sample {highmaps} maps/mapnavigation/doubleclickzoomto/
  1766. * Enable double click zoom to
  1767. *
  1768. * @type {boolean}
  1769. * @default false
  1770. * @apioption mapNavigation.enableDoubleClickZoomTo
  1771. */
  1772. /**
  1773. * Enables zooming by mouse wheel. By default it inherits the [enabled](
  1774. * #mapNavigation.enabled) setting.
  1775. *
  1776. * @type {boolean}
  1777. * @apioption mapNavigation.enableMouseWheelZoom
  1778. */
  1779. /**
  1780. * Whether to enable multitouch zooming. Note that if the chart covers the
  1781. * viewport, this prevents the user from using multitouch and touchdrag on
  1782. * the web page, so you should make sure the user is not trapped inside the
  1783. * chart. By default it inherits the [enabled](#mapNavigation.enabled)
  1784. * setting.
  1785. *
  1786. * @type {boolean}
  1787. * @apioption mapNavigation.enableTouchZoom
  1788. */
  1789. /**
  1790. * Sensitivity of mouse wheel or trackpad scrolling. 1 is no sensitivity,
  1791. * while with 2, one mousewheel delta will zoom in 50%.
  1792. *
  1793. * @since 4.2.4
  1794. */
  1795. mouseWheelSensitivity: 1.1
  1796. // enabled: false,
  1797. // enableButtons: null, // inherit from enabled
  1798. // enableTouchZoom: null, // inherit from enabled
  1799. // enableDoubleClickZoom: null, // inherit from enabled
  1800. // enableDoubleClickZoomTo: false
  1801. // enableMouseWheelZoom: null, // inherit from enabled
  1802. };
  1803. /* *
  1804. *
  1805. * Composition
  1806. *
  1807. * */
  1808. // Add language
  1809. extend(O.defaultOptions.lang, {
  1810. zoomIn: 'Zoom in',
  1811. zoomOut: 'Zoom out'
  1812. });
  1813. // Set the default map navigation options
  1814. O.defaultOptions.mapNavigation = defaultOptions;
  1815. /* *
  1816. *
  1817. * Default Export
  1818. *
  1819. * */
  1820. return defaultOptions;
  1821. });
  1822. _registerModule(_modules, 'Maps/MapNavigation.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, H, U) {
  1823. /* *
  1824. *
  1825. * (c) 2010-2021 Torstein Honsi
  1826. *
  1827. * License: www.highcharts.com/license
  1828. *
  1829. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1830. *
  1831. * */
  1832. var doc = H.doc;
  1833. var addEvent = U.addEvent,
  1834. extend = U.extend,
  1835. merge = U.merge,
  1836. objectEach = U.objectEach,
  1837. pick = U.pick;
  1838. /* eslint-disable no-invalid-this, valid-jsdoc */
  1839. /**
  1840. * @private
  1841. */
  1842. function stopEvent(e) {
  1843. if (e) {
  1844. if (e.preventDefault) {
  1845. e.preventDefault();
  1846. }
  1847. if (e.stopPropagation) {
  1848. e.stopPropagation();
  1849. }
  1850. e.cancelBubble = true;
  1851. }
  1852. }
  1853. /**
  1854. * The MapNavigation handles buttons for navigation in addition to mousewheel
  1855. * and doubleclick handlers for chart zooming.
  1856. *
  1857. * @private
  1858. * @class
  1859. * @name MapNavigation
  1860. *
  1861. * @param {Highcharts.Chart} chart
  1862. * The Chart instance.
  1863. */
  1864. function MapNavigation(chart) {
  1865. this.init(chart);
  1866. }
  1867. /**
  1868. * Initialize function.
  1869. *
  1870. * @function MapNavigation#init
  1871. *
  1872. * @param {Highcharts.Chart} chart
  1873. * The Chart instance.
  1874. *
  1875. * @return {void}
  1876. */
  1877. MapNavigation.prototype.init = function (chart) {
  1878. this.chart = chart;
  1879. chart.mapNavButtons = [];
  1880. };
  1881. /**
  1882. * Update the map navigation with new options. Calling this is the same as
  1883. * calling `chart.update({ mapNavigation: {} })`.
  1884. *
  1885. * @function MapNavigation#update
  1886. *
  1887. * @param {Highcharts.MapNavigationOptions} [options]
  1888. * New options for the map navigation.
  1889. *
  1890. * @return {void}
  1891. */
  1892. MapNavigation.prototype.update = function (options) {
  1893. var chart = this.chart,
  1894. o = chart.options.mapNavigation,
  1895. buttonOptions,
  1896. attr,
  1897. states,
  1898. hoverStates,
  1899. selectStates,
  1900. outerHandler = function (e) {
  1901. this.handler.call(chart,
  1902. e);
  1903. stopEvent(e); // Stop default click event (#4444)
  1904. }, mapNavButtons = chart.mapNavButtons;
  1905. // Merge in new options in case of update, and register back to chart
  1906. // options.
  1907. if (options) {
  1908. o = chart.options.mapNavigation =
  1909. merge(chart.options.mapNavigation, options);
  1910. }
  1911. // Destroy buttons in case of dynamic update
  1912. while (mapNavButtons.length) {
  1913. mapNavButtons.pop().destroy();
  1914. }
  1915. if (pick(o.enableButtons, o.enabled) && !chart.renderer.forExport) {
  1916. objectEach(o.buttons, function (button, n) {
  1917. buttonOptions = merge(o.buttonOptions, button);
  1918. // Presentational
  1919. if (!chart.styledMode) {
  1920. attr = buttonOptions.theme;
  1921. attr.style = merge(buttonOptions.theme.style, buttonOptions.style // #3203
  1922. );
  1923. states = attr.states;
  1924. hoverStates = states && states.hover;
  1925. selectStates = states && states.select;
  1926. }
  1927. button = chart.renderer
  1928. .button(buttonOptions.text, 0, 0, outerHandler, attr, hoverStates, selectStates, 0, n === 'zoomIn' ? 'topbutton' : 'bottombutton')
  1929. .addClass('highcharts-map-navigation highcharts-' + {
  1930. zoomIn: 'zoom-in',
  1931. zoomOut: 'zoom-out'
  1932. }[n])
  1933. .attr({
  1934. width: buttonOptions.width,
  1935. height: buttonOptions.height,
  1936. title: chart.options.lang[n],
  1937. padding: buttonOptions.padding,
  1938. zIndex: 5
  1939. })
  1940. .add();
  1941. button.handler = buttonOptions.onclick;
  1942. // Stop double click event (#4444)
  1943. addEvent(button.element, 'dblclick', stopEvent);
  1944. mapNavButtons.push(button);
  1945. // Align it after the plotBox is known (#12776)
  1946. var bo = buttonOptions;
  1947. var un = addEvent(chart, 'load',
  1948. function () {
  1949. button.align(extend(bo, {
  1950. width: button.width,
  1951. height: 2 * button.height
  1952. }),
  1953. null,
  1954. bo.alignTo);
  1955. un();
  1956. });
  1957. });
  1958. }
  1959. this.updateEvents(o);
  1960. };
  1961. /**
  1962. * Update events, called internally from the update function. Add new event
  1963. * handlers, or unbinds events if disabled.
  1964. *
  1965. * @function MapNavigation#updateEvents
  1966. *
  1967. * @param {Highcharts.MapNavigationOptions} options
  1968. * Options for map navigation.
  1969. *
  1970. * @return {void}
  1971. */
  1972. MapNavigation.prototype.updateEvents = function (options) {
  1973. var chart = this.chart;
  1974. // Add the double click event
  1975. if (pick(options.enableDoubleClickZoom, options.enabled) ||
  1976. options.enableDoubleClickZoomTo) {
  1977. this.unbindDblClick = this.unbindDblClick || addEvent(chart.container, 'dblclick', function (e) {
  1978. chart.pointer.onContainerDblClick(e);
  1979. });
  1980. }
  1981. else if (this.unbindDblClick) {
  1982. // Unbind and set unbinder to undefined
  1983. this.unbindDblClick = this.unbindDblClick();
  1984. }
  1985. // Add the mousewheel event
  1986. if (pick(options.enableMouseWheelZoom, options.enabled)) {
  1987. this.unbindMouseWheel = this.unbindMouseWheel || addEvent(chart.container, typeof doc.onmousewheel === 'undefined' ?
  1988. 'DOMMouseScroll' : 'mousewheel', function (e) {
  1989. chart.pointer.onContainerMouseWheel(e);
  1990. // Issue #5011, returning false from non-jQuery event does
  1991. // not prevent default
  1992. stopEvent(e);
  1993. return false;
  1994. });
  1995. }
  1996. else if (this.unbindMouseWheel) {
  1997. // Unbind and set unbinder to undefined
  1998. this.unbindMouseWheel = this.unbindMouseWheel();
  1999. }
  2000. };
  2001. // Add events to the Chart object itself
  2002. extend(Chart.prototype, /** @lends Chart.prototype */ {
  2003. /**
  2004. * Fit an inner box to an outer. If the inner box overflows left or right,
  2005. * align it to the sides of the outer. If it overflows both sides, fit it
  2006. * within the outer. This is a pattern that occurs more places in
  2007. * Highcharts, perhaps it should be elevated to a common utility function.
  2008. *
  2009. * @ignore
  2010. * @function Highcharts.Chart#fitToBox
  2011. *
  2012. * @param {Highcharts.BBoxObject} inner
  2013. *
  2014. * @param {Highcharts.BBoxObject} outer
  2015. *
  2016. * @return {Highcharts.BBoxObject}
  2017. * The inner box
  2018. */
  2019. fitToBox: function (inner, outer) {
  2020. [['x', 'width'], ['y', 'height']].forEach(function (dim) {
  2021. var pos = dim[0],
  2022. size = dim[1];
  2023. if (inner[pos] + inner[size] >
  2024. outer[pos] + outer[size]) { // right
  2025. // the general size is greater, fit fully to outer
  2026. if (inner[size] > outer[size]) {
  2027. inner[size] = outer[size];
  2028. inner[pos] = outer[pos];
  2029. }
  2030. else { // align right
  2031. inner[pos] = outer[pos] +
  2032. outer[size] - inner[size];
  2033. }
  2034. }
  2035. if (inner[size] > outer[size]) {
  2036. inner[size] = outer[size];
  2037. }
  2038. if (inner[pos] < outer[pos]) {
  2039. inner[pos] = outer[pos];
  2040. }
  2041. });
  2042. return inner;
  2043. },
  2044. /**
  2045. * Highmaps only. Zoom in or out of the map. See also {@link Point#zoomTo}.
  2046. * See {@link Chart#fromLatLonToPoint} for how to get the `centerX` and
  2047. * `centerY` parameters for a geographic location.
  2048. *
  2049. * @function Highcharts.Chart#mapZoom
  2050. *
  2051. * @param {number} [howMuch]
  2052. * How much to zoom the map. Values less than 1 zooms in. 0.5 zooms
  2053. * in to half the current view. 2 zooms to twice the current view. If
  2054. * omitted, the zoom is reset.
  2055. *
  2056. * @param {number} [centerX]
  2057. * The X axis position to center around if available space.
  2058. *
  2059. * @param {number} [centerY]
  2060. * The Y axis position to center around if available space.
  2061. *
  2062. * @param {number} [mouseX]
  2063. * Fix the zoom to this position if possible. This is used for
  2064. * example in mousewheel events, where the area under the mouse
  2065. * should be fixed as we zoom in.
  2066. *
  2067. * @param {number} [mouseY]
  2068. * Fix the zoom to this position if possible.
  2069. *
  2070. * @return {void}
  2071. */
  2072. mapZoom: function (howMuch, centerXArg, centerYArg, mouseX, mouseY) {
  2073. var chart = this,
  2074. xAxis = chart.xAxis[0],
  2075. xRange = xAxis.max - xAxis.min,
  2076. centerX = pick(centerXArg,
  2077. xAxis.min + xRange / 2),
  2078. newXRange = xRange * howMuch,
  2079. yAxis = chart.yAxis[0],
  2080. yRange = yAxis.max - yAxis.min,
  2081. centerY = pick(centerYArg,
  2082. yAxis.min + yRange / 2),
  2083. newYRange = yRange * howMuch,
  2084. fixToX = mouseX ? ((mouseX - xAxis.pos) / xAxis.len) : 0.5,
  2085. fixToY = mouseY ? ((mouseY - yAxis.pos) / yAxis.len) : 0.5,
  2086. newXMin = centerX - newXRange * fixToX,
  2087. newYMin = centerY - newYRange * fixToY,
  2088. newExt = chart.fitToBox({
  2089. x: newXMin,
  2090. y: newYMin,
  2091. width: newXRange,
  2092. height: newYRange
  2093. }, {
  2094. x: xAxis.dataMin,
  2095. y: yAxis.dataMin,
  2096. width: xAxis.dataMax - xAxis.dataMin,
  2097. height: yAxis.dataMax - yAxis.dataMin
  2098. }),
  2099. zoomOut = (newExt.x <= xAxis.dataMin &&
  2100. newExt.width >=
  2101. xAxis.dataMax - xAxis.dataMin &&
  2102. newExt.y <= yAxis.dataMin &&
  2103. newExt.height >= yAxis.dataMax - yAxis.dataMin);
  2104. // When mousewheel zooming, fix the point under the mouse
  2105. if (mouseX && xAxis.mapAxis) {
  2106. xAxis.mapAxis.fixTo = [mouseX - xAxis.pos, centerXArg];
  2107. }
  2108. if (mouseY && yAxis.mapAxis) {
  2109. yAxis.mapAxis.fixTo = [mouseY - yAxis.pos, centerYArg];
  2110. }
  2111. // Zoom
  2112. if (typeof howMuch !== 'undefined' && !zoomOut) {
  2113. xAxis.setExtremes(newExt.x, newExt.x + newExt.width, false);
  2114. yAxis.setExtremes(newExt.y, newExt.y + newExt.height, false);
  2115. // Reset zoom
  2116. }
  2117. else {
  2118. xAxis.setExtremes(void 0, void 0, false);
  2119. yAxis.setExtremes(void 0, void 0, false);
  2120. }
  2121. // Prevent zooming until this one is finished animating
  2122. /*
  2123. chart.holdMapZoom = true;
  2124. setTimeout(function () {
  2125. chart.holdMapZoom = false;
  2126. }, 200);
  2127. */
  2128. /*
  2129. delay = animation ? animation.duration || 500 : 0;
  2130. if (delay) {
  2131. chart.isMapZooming = true;
  2132. setTimeout(function () {
  2133. chart.isMapZooming = false;
  2134. if (chart.mapZoomQueue) {
  2135. chart.mapZoom.apply(chart, chart.mapZoomQueue);
  2136. }
  2137. chart.mapZoomQueue = null;
  2138. }, delay);
  2139. }
  2140. */
  2141. chart.redraw();
  2142. }
  2143. });
  2144. // Extend the Chart.render method to add zooming and panning
  2145. addEvent(Chart, 'beforeRender', function () {
  2146. // Render the plus and minus buttons. Doing this before the shapes makes
  2147. // getBBox much quicker, at least in Chrome.
  2148. this.mapNavigation = new MapNavigation(this);
  2149. this.mapNavigation.update();
  2150. });
  2151. H.MapNavigation = MapNavigation;
  2152. });
  2153. _registerModule(_modules, 'Maps/MapPointer.js', [_modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (Pointer, U) {
  2154. /* *
  2155. *
  2156. * (c) 2010-2021 Torstein Honsi
  2157. *
  2158. * License: www.highcharts.com/license
  2159. *
  2160. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2161. *
  2162. * */
  2163. var extend = U.extend,
  2164. pick = U.pick,
  2165. wrap = U.wrap;
  2166. /* eslint-disable no-invalid-this */
  2167. // Extend the Pointer
  2168. extend(Pointer.prototype, {
  2169. // The event handler for the doubleclick event
  2170. onContainerDblClick: function (e) {
  2171. var chart = this.chart;
  2172. e = this.normalize(e);
  2173. if (chart.options.mapNavigation.enableDoubleClickZoomTo) {
  2174. if (chart.pointer.inClass(e.target, 'highcharts-tracker') &&
  2175. chart.hoverPoint) {
  2176. chart.hoverPoint.zoomTo();
  2177. }
  2178. }
  2179. else if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
  2180. chart.mapZoom(0.5, chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY);
  2181. }
  2182. },
  2183. // The event handler for the mouse scroll event
  2184. onContainerMouseWheel: function (e) {
  2185. var chart = this.chart,
  2186. delta;
  2187. e = this.normalize(e);
  2188. // Firefox uses e.detail, WebKit and IE uses wheelDelta
  2189. delta = e.detail || -(e.wheelDelta / 120);
  2190. if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop)) {
  2191. chart.mapZoom(Math.pow(chart.options.mapNavigation.mouseWheelSensitivity, delta), chart.xAxis[0].toValue(e.chartX), chart.yAxis[0].toValue(e.chartY), e.chartX, e.chartY);
  2192. }
  2193. }
  2194. });
  2195. // The pinchType is inferred from mapNavigation options.
  2196. wrap(Pointer.prototype, 'zoomOption', function (proceed) {
  2197. var mapNavigation = this.chart.options.mapNavigation;
  2198. // Pinch status
  2199. if (pick(mapNavigation.enableTouchZoom, mapNavigation.enabled)) {
  2200. this.chart.options.chart.pinchType = 'xy';
  2201. }
  2202. proceed.apply(this, [].slice.call(arguments, 1));
  2203. });
  2204. // Extend the pinchTranslate method to preserve fixed ratio when zooming
  2205. wrap(Pointer.prototype, 'pinchTranslate', function (proceed, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  2206. var xBigger;
  2207. proceed.call(this, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  2208. // Keep ratio
  2209. if (this.chart.options.chart.type === 'map' && this.hasZoom) {
  2210. xBigger = transform.scaleX > transform.scaleY;
  2211. this.pinchTranslateDirection(!xBigger, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, xBigger ? transform.scaleX : transform.scaleY);
  2212. }
  2213. });
  2214. });
  2215. _registerModule(_modules, 'Maps/MapSymbols.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGRenderer.js']], function (H, SVGRenderer) {
  2216. /* *
  2217. *
  2218. * (c) 2010-2021 Torstein Honsi
  2219. *
  2220. * License: www.highcharts.com/license
  2221. *
  2222. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2223. *
  2224. * */
  2225. var Renderer = H.Renderer,
  2226. VMLRenderer = H.VMLRenderer;
  2227. /* *
  2228. *
  2229. * Functions
  2230. *
  2231. * */
  2232. // eslint-disable-next-line valid-jsdoc
  2233. /**
  2234. * Create symbols for the zoom buttons
  2235. * @private
  2236. */
  2237. function selectiveRoundedRect(x, y, w, h, rTopLeft, rTopRight, rBottomRight, rBottomLeft) {
  2238. return [
  2239. ['M', x + rTopLeft, y],
  2240. // top side
  2241. ['L', x + w - rTopRight, y],
  2242. // top right corner
  2243. ['C', x + w - rTopRight / 2, y, x + w, y + rTopRight / 2, x + w, y + rTopRight],
  2244. // right side
  2245. ['L', x + w, y + h - rBottomRight],
  2246. // bottom right corner
  2247. ['C', x + w, y + h - rBottomRight / 2, x + w - rBottomRight / 2, y + h, x + w - rBottomRight, y + h],
  2248. // bottom side
  2249. ['L', x + rBottomLeft, y + h],
  2250. // bottom left corner
  2251. ['C', x + rBottomLeft / 2, y + h, x, y + h - rBottomLeft / 2, x, y + h - rBottomLeft],
  2252. // left side
  2253. ['L', x, y + rTopLeft],
  2254. // top left corner
  2255. ['C', x, y + rTopLeft / 2, x + rTopLeft / 2, y, x + rTopLeft, y],
  2256. ['Z']
  2257. ];
  2258. }
  2259. SVGRenderer.prototype.symbols.topbutton = function (x, y, w, h, options) {
  2260. var r = (options && options.r) || 0;
  2261. return selectiveRoundedRect(x - 1, y - 1, w, h, r, r, 0, 0);
  2262. };
  2263. SVGRenderer.prototype.symbols.bottombutton = function (x, y, w, h, options) {
  2264. var r = (options && options.r) || 0;
  2265. return selectiveRoundedRect(x - 1, y - 1, w, h, 0, 0, r, r);
  2266. };
  2267. // The symbol callbacks are generated on the SVGRenderer object in all browsers.
  2268. // Even VML browsers need this in order to generate shapes in export. Now share
  2269. // them with the VMLRenderer.
  2270. if (Renderer !== SVGRenderer) {
  2271. ['topbutton', 'bottombutton'].forEach(function (shape) {
  2272. Renderer.prototype.symbols[shape] = SVGRenderer.prototype.symbols[shape];
  2273. });
  2274. }
  2275. return SVGRenderer.prototype.symbols;
  2276. });
  2277. _registerModule(_modules, 'Maps/Map.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (Chart, H, SVGRenderer, U) {
  2278. /* *
  2279. *
  2280. * (c) 2010-2021 Torstein Honsi
  2281. *
  2282. * License: www.highcharts.com/license
  2283. *
  2284. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2285. *
  2286. * */
  2287. var getOptions = U.getOptions,
  2288. merge = U.merge,
  2289. pick = U.pick;
  2290. /* eslint-disable valid-jsdoc */
  2291. var Map;
  2292. (function (Map) {
  2293. /* *
  2294. *
  2295. * Constants
  2296. *
  2297. * */
  2298. /**
  2299. * Contains all loaded map data for Highmaps.
  2300. *
  2301. * @requires modules/map
  2302. *
  2303. * @name Highcharts.maps
  2304. * @type {Record<string,*>}
  2305. */
  2306. Map.maps = {};
  2307. /* *
  2308. *
  2309. * Functions
  2310. *
  2311. * */
  2312. /**
  2313. * The factory function for creating new map charts. Creates a new {@link
  2314. * Highcharts.Chart|Chart} object with different default options than the
  2315. * basic Chart.
  2316. *
  2317. * @requires modules/map
  2318. *
  2319. * @function Highcharts.mapChart
  2320. *
  2321. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  2322. * The DOM element to render to, or its id.
  2323. *
  2324. * @param {Highcharts.Options} options
  2325. * The chart options structure as described in the
  2326. * [options reference](https://api.highcharts.com/highstock).
  2327. *
  2328. * @param {Highcharts.ChartCallbackFunction} [callback]
  2329. * A function to execute when the chart object is finished loading and
  2330. * rendering. In most cases the chart is built in one thread, but in
  2331. * Internet Explorer version 8 or less the chart is sometimes initialized
  2332. * before the document is ready, and in these cases the chart object will
  2333. * not be finished synchronously. As a consequence, code that relies on the
  2334. * newly built Chart object should always run in the callback. Defining a
  2335. * [chart.events.load](https://api.highcharts.com/highstock/chart.events.load)
  2336. * handler is equivalent.
  2337. *
  2338. * @return {Highcharts.Chart}
  2339. * The chart object.
  2340. */
  2341. function mapChart(a, b, c) {
  2342. var hasRenderToArg = typeof a === 'string' || a.nodeName,
  2343. options = arguments[hasRenderToArg ? 1 : 0],
  2344. userOptions = options,
  2345. hiddenAxis = {
  2346. endOnTick: false,
  2347. visible: false,
  2348. minPadding: 0,
  2349. maxPadding: 0,
  2350. startOnTick: false
  2351. },
  2352. seriesOptions,
  2353. defaultCreditsOptions = getOptions().credits;
  2354. /* For visual testing
  2355. hiddenAxis.gridLineWidth = 1;
  2356. hiddenAxis.gridZIndex = 10;
  2357. hiddenAxis.tickPositions = undefined;
  2358. // */
  2359. // Don't merge the data
  2360. seriesOptions = options.series;
  2361. options.series = null;
  2362. options = merge({
  2363. chart: {
  2364. panning: {
  2365. enabled: true,
  2366. type: 'xy'
  2367. },
  2368. type: 'map'
  2369. },
  2370. credits: {
  2371. mapText: pick(defaultCreditsOptions.mapText, ' \u00a9 <a href="{geojson.copyrightUrl}">' +
  2372. '{geojson.copyrightShort}</a>'),
  2373. mapTextFull: pick(defaultCreditsOptions.mapTextFull, '{geojson.copyright}')
  2374. },
  2375. tooltip: {
  2376. followTouchMove: false
  2377. },
  2378. xAxis: hiddenAxis,
  2379. yAxis: merge(hiddenAxis, { reversed: true })
  2380. }, options, // user's options
  2381. {
  2382. chart: {
  2383. inverted: false,
  2384. alignTicks: false
  2385. }
  2386. });
  2387. options.series = userOptions.series = seriesOptions;
  2388. return hasRenderToArg ?
  2389. new Chart(a, options, c) :
  2390. new Chart(options, b);
  2391. }
  2392. Map.mapChart = mapChart;
  2393. /**
  2394. * Utility for reading SVG paths directly.
  2395. *
  2396. * @requires modules/map
  2397. *
  2398. * @function Highcharts.splitPath
  2399. *
  2400. * @param {string|Array<string|number>} path
  2401. *
  2402. * @return {Highcharts.SVGPathArray}
  2403. */
  2404. function splitPath(path) {
  2405. var arr;
  2406. if (typeof path === 'string') {
  2407. path = path
  2408. // Move letters apart
  2409. .replace(/([A-Za-z])/g, ' $1 ')
  2410. // Trim
  2411. .replace(/^\s*/, '').replace(/\s*$/, '');
  2412. // Split on spaces and commas. The semicolon is bogus, designed to
  2413. // circumvent string replacement in the pre-v7 assembler that built
  2414. // specific styled mode files.
  2415. var split = path.split(/[ ,;]+/);
  2416. arr = split.map(function (item) {
  2417. if (!/[A-za-z]/.test(item)) {
  2418. return parseFloat(item);
  2419. }
  2420. return item;
  2421. });
  2422. }
  2423. else {
  2424. arr = path;
  2425. }
  2426. return SVGRenderer.prototype.pathToSegments(arr);
  2427. }
  2428. Map.splitPath = splitPath;
  2429. })(Map || (Map = {}));
  2430. /* *
  2431. *
  2432. * Compatibility
  2433. *
  2434. * */
  2435. H.Map = Map.mapChart; // @todo remove fake class for jQuery
  2436. H.mapChart = Map.mapChart;
  2437. H.maps = Map.maps;
  2438. /* *
  2439. *
  2440. * Default Export
  2441. *
  2442. * */
  2443. return Map;
  2444. });
  2445. _registerModule(_modules, 'Series/Map/MapPoint.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, SeriesRegistry, U) {
  2446. /* *
  2447. *
  2448. * (c) 2010-2021 Torstein Honsi
  2449. *
  2450. * License: www.highcharts.com/license
  2451. *
  2452. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2453. *
  2454. * */
  2455. var __extends = (this && this.__extends) || (function () {
  2456. var extendStatics = function (d,
  2457. b) {
  2458. extendStatics = Object.setPrototypeOf ||
  2459. ({ __proto__: [] } instanceof Array && function (d,
  2460. b) { d.__proto__ = b; }) ||
  2461. function (d,
  2462. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2463. return extendStatics(d, b);
  2464. };
  2465. return function (d, b) {
  2466. extendStatics(d, b);
  2467. function __() { this.constructor = d; }
  2468. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2469. };
  2470. })();
  2471. var colorMapPointMixin = ColorMapMixin.colorMapPointMixin;
  2472. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  2473. var extend = U.extend;
  2474. /* *
  2475. *
  2476. * Class
  2477. *
  2478. * */
  2479. var MapPoint = /** @class */ (function (_super) {
  2480. __extends(MapPoint, _super);
  2481. function MapPoint() {
  2482. /* *
  2483. *
  2484. * Properties
  2485. *
  2486. * */
  2487. var _this = _super !== null && _super.apply(this,
  2488. arguments) || this;
  2489. _this.options = void 0;
  2490. _this.path = void 0;
  2491. _this.series = void 0;
  2492. return _this;
  2493. /* eslint-enable valid-jsdoc */
  2494. }
  2495. /* *
  2496. *
  2497. * Functions
  2498. *
  2499. * */
  2500. /* eslint-disable valid-jsdoc */
  2501. /**
  2502. * Extend the Point object to split paths.
  2503. * @private
  2504. */
  2505. MapPoint.prototype.applyOptions = function (options, x) {
  2506. var series = this.series,
  2507. point = _super.prototype.applyOptions.call(this,
  2508. options,
  2509. x),
  2510. joinBy = series.joinBy,
  2511. mapPoint;
  2512. if (series.mapData && series.mapMap) {
  2513. var joinKey = joinBy[1];
  2514. var mapKey = _super.prototype.getNestedProperty.call(point,
  2515. joinKey);
  2516. mapPoint = typeof mapKey !== 'undefined' &&
  2517. series.mapMap[mapKey];
  2518. if (mapPoint) {
  2519. // This applies only to bubbles
  2520. if (series.xyFromShape) {
  2521. point.x = mapPoint._midX;
  2522. point.y = mapPoint._midY;
  2523. }
  2524. extend(point, mapPoint); // copy over properties
  2525. }
  2526. else {
  2527. point.value = point.value || null;
  2528. }
  2529. }
  2530. return point;
  2531. };
  2532. /**
  2533. * Stop the fade-out
  2534. * @private
  2535. */
  2536. MapPoint.prototype.onMouseOver = function (e) {
  2537. U.clearTimeout(this.colorInterval);
  2538. if (this.value !== null || this.series.options.nullInteraction) {
  2539. _super.prototype.onMouseOver.call(this, e);
  2540. }
  2541. else {
  2542. // #3401 Tooltip doesn't hide when hovering over null points
  2543. this.series.onMouseOut(e);
  2544. }
  2545. };
  2546. /**
  2547. * Highmaps only. Zoom in on the point using the global animation.
  2548. *
  2549. * @sample maps/members/point-zoomto/
  2550. * Zoom to points from butons
  2551. *
  2552. * @requires modules/map
  2553. *
  2554. * @function Highcharts.Point#zoomTo
  2555. */
  2556. MapPoint.prototype.zoomTo = function () {
  2557. var point = this,
  2558. series = point.series;
  2559. series.xAxis.setExtremes(point._minX, point._maxX, false);
  2560. series.yAxis.setExtremes(point._minY, point._maxY, false);
  2561. series.chart.redraw();
  2562. };
  2563. return MapPoint;
  2564. }(ScatterSeries.prototype.pointClass));
  2565. extend(MapPoint.prototype, {
  2566. dataLabelOnNull: colorMapPointMixin.dataLabelOnNull,
  2567. isValid: colorMapPointMixin.isValid,
  2568. setState: colorMapPointMixin.setState
  2569. });
  2570. /* *
  2571. *
  2572. * Default Export
  2573. *
  2574. * */
  2575. return MapPoint;
  2576. });
  2577. _registerModule(_modules, 'Series/Map/MapSeries.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Maps/Map.js'], _modules['Series/Map/MapPoint.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, H, LegendSymbolMixin, mapModule, MapPoint, palette, Series, SeriesRegistry, SVGRenderer, U) {
  2578. /* *
  2579. *
  2580. * (c) 2010-2021 Torstein Honsi
  2581. *
  2582. * License: www.highcharts.com/license
  2583. *
  2584. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2585. *
  2586. * */
  2587. var __extends = (this && this.__extends) || (function () {
  2588. var extendStatics = function (d,
  2589. b) {
  2590. extendStatics = Object.setPrototypeOf ||
  2591. ({ __proto__: [] } instanceof Array && function (d,
  2592. b) { d.__proto__ = b; }) ||
  2593. function (d,
  2594. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2595. return extendStatics(d, b);
  2596. };
  2597. return function (d, b) {
  2598. extendStatics(d, b);
  2599. function __() { this.constructor = d; }
  2600. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2601. };
  2602. })();
  2603. var colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  2604. var noop = H.noop;
  2605. var maps = mapModule.maps,
  2606. splitPath = mapModule.splitPath;
  2607. var
  2608. // indirect dependency to keep product size low
  2609. _a = SeriesRegistry.seriesTypes,
  2610. ColumnSeries = _a.column,
  2611. ScatterSeries = _a.scatter;
  2612. var extend = U.extend,
  2613. fireEvent = U.fireEvent,
  2614. getNestedProperty = U.getNestedProperty,
  2615. isArray = U.isArray,
  2616. isNumber = U.isNumber,
  2617. merge = U.merge,
  2618. objectEach = U.objectEach,
  2619. pick = U.pick,
  2620. splat = U.splat;
  2621. /* *
  2622. *
  2623. * Class
  2624. *
  2625. * */
  2626. /**
  2627. * @private
  2628. * @class
  2629. * @name Highcharts.seriesTypes.map
  2630. *
  2631. * @augments Highcharts.Series
  2632. */
  2633. var MapSeries = /** @class */ (function (_super) {
  2634. __extends(MapSeries, _super);
  2635. function MapSeries() {
  2636. /* *
  2637. *
  2638. * Static Properties
  2639. *
  2640. * */
  2641. var _this = _super !== null && _super.apply(this,
  2642. arguments) || this;
  2643. /* *
  2644. *
  2645. * Properties
  2646. *
  2647. * */
  2648. _this.baseTrans = void 0;
  2649. _this.chart = void 0;
  2650. _this.data = void 0;
  2651. _this.group = void 0;
  2652. _this.joinBy = void 0;
  2653. _this.options = void 0;
  2654. _this.points = void 0;
  2655. _this.transformGroup = void 0;
  2656. return _this;
  2657. /* eslint-enable valid-jsdoc */
  2658. }
  2659. /* *
  2660. *
  2661. * Functions
  2662. *
  2663. * */
  2664. /* eslint-disable valid-jsdoc */
  2665. /**
  2666. * The initial animation for the map series. By default, animation is
  2667. * disabled. Animation of map shapes is not at all supported in VML
  2668. * browsers.
  2669. * @private
  2670. */
  2671. MapSeries.prototype.animate = function (init) {
  2672. var chart = this.chart,
  2673. animation = this.options.animation,
  2674. group = this.group,
  2675. xAxis = this.xAxis,
  2676. yAxis = this.yAxis,
  2677. left = xAxis.pos,
  2678. top = yAxis.pos;
  2679. if (chart.renderer.isSVG) {
  2680. if (animation === true) {
  2681. animation = {
  2682. duration: 1000
  2683. };
  2684. }
  2685. // Initialize the animation
  2686. if (init) {
  2687. // Scale down the group and place it in the center
  2688. group.attr({
  2689. translateX: left + xAxis.len / 2,
  2690. translateY: top + yAxis.len / 2,
  2691. scaleX: 0.001,
  2692. scaleY: 0.001
  2693. });
  2694. // Run the animation
  2695. }
  2696. else {
  2697. group.animate({
  2698. translateX: left,
  2699. translateY: top,
  2700. scaleX: 1,
  2701. scaleY: 1
  2702. }, animation);
  2703. }
  2704. }
  2705. };
  2706. /**
  2707. * Animate in the new series from the clicked point in the old series.
  2708. * Depends on the drilldown.js module
  2709. * @private
  2710. */
  2711. MapSeries.prototype.animateDrilldown = function (init) {
  2712. var toBox = this.chart.plotBox,
  2713. level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1],
  2714. fromBox = level.bBox,
  2715. animationOptions = this.chart.options.drilldown.animation,
  2716. scale;
  2717. if (!init) {
  2718. scale = Math.min(fromBox.width / toBox.width, fromBox.height / toBox.height);
  2719. level.shapeArgs = {
  2720. scaleX: scale,
  2721. scaleY: scale,
  2722. translateX: fromBox.x,
  2723. translateY: fromBox.y
  2724. };
  2725. this.points.forEach(function (point) {
  2726. if (point.graphic) {
  2727. point.graphic
  2728. .attr(level.shapeArgs)
  2729. .animate({
  2730. scaleX: 1,
  2731. scaleY: 1,
  2732. translateX: 0,
  2733. translateY: 0
  2734. }, animationOptions);
  2735. }
  2736. });
  2737. }
  2738. };
  2739. /**
  2740. * When drilling up, pull out the individual point graphics from the lower
  2741. * series and animate them into the origin point in the upper series.
  2742. * @private
  2743. */
  2744. MapSeries.prototype.animateDrillupFrom = function (level) {
  2745. ColumnSeries.prototype.animateDrillupFrom.call(this, level);
  2746. };
  2747. /**
  2748. * When drilling up, keep the upper series invisible until the lower series
  2749. * has moved into place.
  2750. * @private
  2751. */
  2752. MapSeries.prototype.animateDrillupTo = function (init) {
  2753. ColumnSeries.prototype.animateDrillupTo.call(this, init);
  2754. };
  2755. /**
  2756. * Allow a quick redraw by just translating the area group. Used for zooming
  2757. * and panning in capable browsers.
  2758. * @private
  2759. */
  2760. MapSeries.prototype.doFullTranslate = function () {
  2761. return (this.isDirtyData ||
  2762. this.chart.isResizing ||
  2763. this.chart.renderer.isVML ||
  2764. !this.baseTrans);
  2765. };
  2766. /**
  2767. * Draw the data labels. Special for maps is the time that the data labels
  2768. * are drawn (after points), and the clipping of the dataLabelsGroup.
  2769. * @private
  2770. */
  2771. MapSeries.prototype.drawMapDataLabels = function () {
  2772. Series.prototype.drawDataLabels.call(this);
  2773. if (this.dataLabelsGroup) {
  2774. this.dataLabelsGroup.clip(this.chart.clipRect);
  2775. }
  2776. };
  2777. /**
  2778. * Use the drawPoints method of column, that is able to handle simple
  2779. * shapeArgs. Extend it by assigning the tooltip position.
  2780. * @private
  2781. */
  2782. MapSeries.prototype.drawPoints = function () {
  2783. var series = this,
  2784. xAxis = series.xAxis,
  2785. yAxis = series.yAxis,
  2786. group = series.group,
  2787. chart = series.chart,
  2788. renderer = chart.renderer,
  2789. scaleX,
  2790. scaleY,
  2791. translateX,
  2792. translateY,
  2793. baseTrans = this.baseTrans,
  2794. transformGroup,
  2795. startTranslateX,
  2796. startTranslateY,
  2797. startScaleX,
  2798. startScaleY;
  2799. // Set a group that handles transform during zooming and panning in
  2800. // order to preserve clipping on series.group
  2801. if (!series.transformGroup) {
  2802. series.transformGroup = renderer.g()
  2803. .attr({
  2804. scaleX: 1,
  2805. scaleY: 1
  2806. })
  2807. .add(group);
  2808. series.transformGroup.survive = true;
  2809. }
  2810. // Draw the shapes again
  2811. if (series.doFullTranslate()) {
  2812. // Individual point actions.
  2813. if (chart.hasRendered && !chart.styledMode) {
  2814. series.points.forEach(function (point) {
  2815. // Restore state color on update/redraw (#3529)
  2816. if (point.shapeArgs) {
  2817. point.shapeArgs.fill = series.pointAttribs(point, point.state).fill;
  2818. }
  2819. });
  2820. }
  2821. // Draw them in transformGroup
  2822. series.group = series.transformGroup;
  2823. ColumnSeries.prototype.drawPoints.apply(series);
  2824. series.group = group; // Reset
  2825. // Add class names
  2826. series.points.forEach(function (point) {
  2827. if (point.graphic) {
  2828. var className = '';
  2829. if (point.name) {
  2830. className +=
  2831. 'highcharts-name-' +
  2832. point.name.replace(/ /g, '-').toLowerCase();
  2833. }
  2834. if (point.properties &&
  2835. point.properties['hc-key']) {
  2836. className +=
  2837. ' highcharts-key-' +
  2838. point.properties['hc-key'].toLowerCase();
  2839. }
  2840. if (className) {
  2841. point.graphic.addClass(className);
  2842. }
  2843. // In styled mode, apply point colors by CSS
  2844. if (chart.styledMode) {
  2845. point.graphic.css(series.pointAttribs(point, point.selected && 'select' || void 0));
  2846. }
  2847. }
  2848. });
  2849. // Set the base for later scale-zooming. The originX and originY
  2850. // properties are the axis values in the plot area's upper left
  2851. // corner.
  2852. this.baseTrans = {
  2853. originX: (xAxis.min -
  2854. xAxis.minPixelPadding / xAxis.transA),
  2855. originY: (yAxis.min -
  2856. yAxis.minPixelPadding / yAxis.transA +
  2857. (yAxis.reversed ? 0 : yAxis.len / yAxis.transA)),
  2858. transAX: xAxis.transA,
  2859. transAY: yAxis.transA
  2860. };
  2861. // Reset transformation in case we're doing a full translate
  2862. // (#3789)
  2863. this.transformGroup.animate({
  2864. translateX: 0,
  2865. translateY: 0,
  2866. scaleX: 1,
  2867. scaleY: 1
  2868. });
  2869. // Just update the scale and transform for better performance
  2870. }
  2871. else {
  2872. scaleX = xAxis.transA / baseTrans.transAX;
  2873. scaleY = yAxis.transA / baseTrans.transAY;
  2874. translateX = xAxis.toPixels(baseTrans.originX, true);
  2875. translateY = yAxis.toPixels(baseTrans.originY, true);
  2876. // Handle rounding errors in normal view (#3789)
  2877. if (scaleX > 0.99 &&
  2878. scaleX < 1.01 &&
  2879. scaleY > 0.99 &&
  2880. scaleY < 1.01) {
  2881. scaleX = 1;
  2882. scaleY = 1;
  2883. translateX = Math.round(translateX);
  2884. translateY = Math.round(translateY);
  2885. }
  2886. /* Animate or move to the new zoom level. In order to prevent
  2887. flickering as the different transform components are set out
  2888. of sync (#5991), we run a fake animator attribute and set
  2889. scale and translation synchronously in the same step.
  2890. A possible improvement to the API would be to handle this in
  2891. the renderer or animation engine itself, to ensure that when
  2892. we are animating multiple properties, we make sure that each
  2893. step for each property is performed in the same step. Also,
  2894. for symbols and for transform properties, it should induce a
  2895. single updateTransform and symbolAttr call. */
  2896. transformGroup = this.transformGroup;
  2897. if (chart.renderer.globalAnimation) {
  2898. startTranslateX = transformGroup.attr('translateX');
  2899. startTranslateY = transformGroup.attr('translateY');
  2900. startScaleX = transformGroup.attr('scaleX');
  2901. startScaleY = transformGroup.attr('scaleY');
  2902. transformGroup
  2903. .attr({ animator: 0 })
  2904. .animate({
  2905. animator: 1
  2906. }, {
  2907. step: function (now, fx) {
  2908. transformGroup.attr({
  2909. translateX: (startTranslateX +
  2910. (translateX - startTranslateX) * fx.pos),
  2911. translateY: (startTranslateY +
  2912. (translateY - startTranslateY) * fx.pos),
  2913. scaleX: (startScaleX +
  2914. (scaleX - startScaleX) *
  2915. fx.pos),
  2916. scaleY: (startScaleY +
  2917. (scaleY - startScaleY) * fx.pos)
  2918. });
  2919. }
  2920. });
  2921. // When dragging, animation is off.
  2922. }
  2923. else {
  2924. transformGroup.attr({
  2925. translateX: translateX,
  2926. translateY: translateY,
  2927. scaleX: scaleX,
  2928. scaleY: scaleY
  2929. });
  2930. }
  2931. }
  2932. /* Set the stroke-width directly on the group element so the
  2933. children inherit it. We need to use setAttribute directly,
  2934. because the stroke-widthSetter method expects a stroke color also
  2935. to be set. */
  2936. if (!chart.styledMode) {
  2937. group.element.setAttribute('stroke-width', (pick(series.options[(series.pointAttrToOptions &&
  2938. series.pointAttrToOptions['stroke-width']) || 'borderWidth'], 1 // Styled mode
  2939. ) / (scaleX || 1)));
  2940. }
  2941. this.drawMapDataLabels();
  2942. };
  2943. /**
  2944. * Get the bounding box of all paths in the map combined.
  2945. * @private
  2946. */
  2947. MapSeries.prototype.getBox = function (paths) {
  2948. var MAX_VALUE = Number.MAX_VALUE,
  2949. maxX = -MAX_VALUE,
  2950. minX = MAX_VALUE,
  2951. maxY = -MAX_VALUE,
  2952. minY = MAX_VALUE,
  2953. minRange = MAX_VALUE,
  2954. xAxis = this.xAxis,
  2955. yAxis = this.yAxis,
  2956. hasBox;
  2957. // Find the bounding box
  2958. (paths || []).forEach(function (point) {
  2959. if (point.path) {
  2960. if (typeof point.path === 'string') {
  2961. point.path = splitPath(point.path);
  2962. // Legacy one-dimensional array
  2963. }
  2964. else if (point.path[0] === 'M') {
  2965. point.path = SVGRenderer.prototype.pathToSegments(point.path);
  2966. }
  2967. var path = point.path || [],
  2968. pointMaxX = -MAX_VALUE,
  2969. pointMinX = MAX_VALUE,
  2970. pointMaxY = -MAX_VALUE,
  2971. pointMinY = MAX_VALUE,
  2972. properties = point.properties;
  2973. // The first time a map point is used, analyze its box
  2974. if (!point._foundBox) {
  2975. path.forEach(function (seg) {
  2976. var x = seg[seg.length - 2];
  2977. var y = seg[seg.length - 1];
  2978. if (typeof x === 'number' && typeof y === 'number') {
  2979. pointMinX = Math.min(pointMinX, x);
  2980. pointMaxX = Math.max(pointMaxX, x);
  2981. pointMinY = Math.min(pointMinY, y);
  2982. pointMaxY = Math.max(pointMaxY, y);
  2983. }
  2984. });
  2985. // Cache point bounding box for use to position data
  2986. // labels, bubbles etc
  2987. point._midX = (pointMinX + (pointMaxX - pointMinX) * pick(point.middleX, properties &&
  2988. properties['hc-middle-x'], 0.5));
  2989. point._midY = (pointMinY + (pointMaxY - pointMinY) * pick(point.middleY, properties &&
  2990. properties['hc-middle-y'], 0.5));
  2991. point._maxX = pointMaxX;
  2992. point._minX = pointMinX;
  2993. point._maxY = pointMaxY;
  2994. point._minY = pointMinY;
  2995. point.labelrank = pick(point.labelrank, (pointMaxX - pointMinX) * (pointMaxY - pointMinY));
  2996. point._foundBox = true;
  2997. }
  2998. maxX = Math.max(maxX, point._maxX);
  2999. minX = Math.min(minX, point._minX);
  3000. maxY = Math.max(maxY, point._maxY);
  3001. minY = Math.min(minY, point._minY);
  3002. minRange = Math.min(point._maxX - point._minX, point._maxY - point._minY, minRange);
  3003. hasBox = true;
  3004. }
  3005. });
  3006. // Set the box for the whole series
  3007. if (hasBox) {
  3008. this.minY = Math.min(minY, pick(this.minY, MAX_VALUE));
  3009. this.maxY = Math.max(maxY, pick(this.maxY, -MAX_VALUE));
  3010. this.minX = Math.min(minX, pick(this.minX, MAX_VALUE));
  3011. this.maxX = Math.max(maxX, pick(this.maxX, -MAX_VALUE));
  3012. // If no minRange option is set, set the default minimum zooming
  3013. // range to 5 times the size of the smallest element
  3014. if (xAxis && typeof xAxis.options.minRange === 'undefined') {
  3015. xAxis.minRange = Math.min(5 * minRange, (this.maxX - this.minX) / 5, xAxis.minRange || MAX_VALUE);
  3016. }
  3017. if (yAxis && typeof yAxis.options.minRange === 'undefined') {
  3018. yAxis.minRange = Math.min(5 * minRange, (this.maxY - this.minY) / 5, yAxis.minRange || MAX_VALUE);
  3019. }
  3020. }
  3021. };
  3022. MapSeries.prototype.getExtremes = function () {
  3023. // Get the actual value extremes for colors
  3024. var _a = Series.prototype.getExtremes
  3025. .call(this,
  3026. this.valueData),
  3027. dataMin = _a.dataMin,
  3028. dataMax = _a.dataMax;
  3029. // Recalculate box on updated data
  3030. if (this.chart.hasRendered && this.isDirtyData) {
  3031. this.getBox(this.options.data);
  3032. }
  3033. if (isNumber(dataMin)) {
  3034. this.valueMin = dataMin;
  3035. }
  3036. if (isNumber(dataMax)) {
  3037. this.valueMax = dataMax;
  3038. }
  3039. // Extremes for the mock Y axis
  3040. return { dataMin: this.minY, dataMax: this.maxY };
  3041. };
  3042. /**
  3043. * Define hasData function for non-cartesian series. Returns true if the
  3044. * series has points at all.
  3045. * @private
  3046. */
  3047. MapSeries.prototype.hasData = function () {
  3048. return !!this.processedXData.length; // != 0
  3049. };
  3050. /**
  3051. * Get presentational attributes. In the maps series this runs in both
  3052. * styled and non-styled mode, because colors hold data when a colorAxis is
  3053. * used.
  3054. * @private
  3055. */
  3056. MapSeries.prototype.pointAttribs = function (point, state) {
  3057. var attr = point.series.chart.styledMode ?
  3058. this.colorAttribs(point) :
  3059. ColumnSeries.prototype.pointAttribs.call(this,
  3060. point,
  3061. state);
  3062. // Set the stroke-width on the group element and let all point
  3063. // graphics inherit. That way we don't have to iterate over all
  3064. // points to update the stroke-width on zooming.
  3065. attr['stroke-width'] = pick(point.options[(this.pointAttrToOptions &&
  3066. this.pointAttrToOptions['stroke-width']) || 'borderWidth'], 'inherit');
  3067. return attr;
  3068. };
  3069. /**
  3070. * Override render to throw in an async call in IE8. Otherwise it chokes on
  3071. * the US counties demo.
  3072. * @private
  3073. */
  3074. MapSeries.prototype.render = function () {
  3075. var series = this,
  3076. render = Series.prototype.render;
  3077. // Give IE8 some time to breathe.
  3078. if (series.chart.renderer.isVML && series.data.length > 3000) {
  3079. setTimeout(function () {
  3080. render.call(series);
  3081. });
  3082. }
  3083. else {
  3084. render.call(series);
  3085. }
  3086. };
  3087. /**
  3088. * Extend setData to join in mapData. If the allAreas option is true, all
  3089. * areas from the mapData are used, and those that don't correspond to a
  3090. * data value are given null values.
  3091. * @private
  3092. */
  3093. MapSeries.prototype.setData = function (data, redraw, animation, updatePoints) {
  3094. var options = this.options,
  3095. chartOptions = this.chart.options.chart,
  3096. globalMapData = chartOptions && chartOptions.map,
  3097. mapData = options.mapData,
  3098. joinBy = this.joinBy,
  3099. pointArrayMap = options.keys || this.pointArrayMap,
  3100. dataUsed = [],
  3101. mapMap = {},
  3102. mapPoint,
  3103. mapTransforms = this.chart.mapTransforms,
  3104. props,
  3105. i;
  3106. // Collect mapData from chart options if not defined on series
  3107. if (!mapData && globalMapData) {
  3108. mapData = typeof globalMapData === 'string' ?
  3109. maps[globalMapData] :
  3110. globalMapData;
  3111. }
  3112. // Pick up numeric values, add index
  3113. // Convert Array point definitions to objects using pointArrayMap
  3114. if (data) {
  3115. data.forEach(function (val, i) {
  3116. var ix = 0;
  3117. if (isNumber(val)) {
  3118. data[i] = {
  3119. value: val
  3120. };
  3121. }
  3122. else if (isArray(val)) {
  3123. data[i] = {};
  3124. // Automatically copy first item to hc-key if there is
  3125. // an extra leading string
  3126. if (!options.keys &&
  3127. val.length > pointArrayMap.length &&
  3128. typeof val[0] === 'string') {
  3129. data[i]['hc-key'] = val[0];
  3130. ++ix;
  3131. }
  3132. // Run through pointArrayMap and what's left of the
  3133. // point data array in parallel, copying over the values
  3134. for (var j = 0; j < pointArrayMap.length; ++j, ++ix) {
  3135. if (pointArrayMap[j] &&
  3136. typeof val[ix] !== 'undefined') {
  3137. if (pointArrayMap[j].indexOf('.') > 0) {
  3138. MapPoint.prototype.setNestedProperty(data[i], val[ix], pointArrayMap[j]);
  3139. }
  3140. else {
  3141. data[i][pointArrayMap[j]] =
  3142. val[ix];
  3143. }
  3144. }
  3145. }
  3146. }
  3147. if (joinBy && joinBy[0] === '_i') {
  3148. data[i]._i = i;
  3149. }
  3150. });
  3151. }
  3152. this.getBox(data);
  3153. // Pick up transform definitions for chart
  3154. this.chart.mapTransforms = mapTransforms =
  3155. chartOptions && chartOptions.mapTransforms ||
  3156. mapData && mapData['hc-transform'] ||
  3157. mapTransforms;
  3158. // Cache cos/sin of transform rotation angle
  3159. if (mapTransforms) {
  3160. objectEach(mapTransforms, function (transform) {
  3161. if (transform.rotation) {
  3162. transform.cosAngle = Math.cos(transform.rotation);
  3163. transform.sinAngle = Math.sin(transform.rotation);
  3164. }
  3165. });
  3166. }
  3167. if (mapData) {
  3168. if (mapData.type === 'FeatureCollection') {
  3169. this.mapTitle = mapData.title;
  3170. mapData = H.geojson(mapData, this.type, this);
  3171. }
  3172. this.mapData = mapData;
  3173. this.mapMap = {};
  3174. for (i = 0; i < mapData.length; i++) {
  3175. mapPoint = mapData[i];
  3176. props = mapPoint.properties;
  3177. mapPoint._i = i;
  3178. // Copy the property over to root for faster access
  3179. if (joinBy[0] && props && props[joinBy[0]]) {
  3180. mapPoint[joinBy[0]] = props[joinBy[0]];
  3181. }
  3182. mapMap[mapPoint[joinBy[0]]] = mapPoint;
  3183. }
  3184. this.mapMap = mapMap;
  3185. // Registered the point codes that actually hold data
  3186. if (data && joinBy[1]) {
  3187. var joinKey_1 = joinBy[1];
  3188. data.forEach(function (pointOptions) {
  3189. var mapKey = getNestedProperty(joinKey_1,
  3190. pointOptions);
  3191. if (mapMap[mapKey]) {
  3192. dataUsed.push(mapMap[mapKey]);
  3193. }
  3194. });
  3195. }
  3196. if (options.allAreas) {
  3197. this.getBox(mapData);
  3198. data = data || [];
  3199. // Registered the point codes that actually hold data
  3200. if (joinBy[1]) {
  3201. var joinKey_2 = joinBy[1];
  3202. data.forEach(function (pointOptions) {
  3203. dataUsed.push(getNestedProperty(joinKey_2, pointOptions));
  3204. });
  3205. }
  3206. // Add those map points that don't correspond to data, which
  3207. // will be drawn as null points
  3208. dataUsed = ('|' + dataUsed.map(function (point) {
  3209. return point && point[joinBy[0]];
  3210. }).join('|') + '|'); // Faster than array.indexOf
  3211. mapData.forEach(function (mapPoint) {
  3212. if (!joinBy[0] ||
  3213. dataUsed.indexOf('|' + mapPoint[joinBy[0]] + '|') === -1) {
  3214. data.push(merge(mapPoint, { value: null }));
  3215. // #5050 - adding all areas causes the update
  3216. // optimization of setData to kick in, even though
  3217. // the point order has changed
  3218. updatePoints = false;
  3219. }
  3220. });
  3221. }
  3222. else {
  3223. this.getBox(dataUsed); // Issue #4784
  3224. }
  3225. }
  3226. Series.prototype.setData.call(this, data, redraw, animation, updatePoints);
  3227. };
  3228. /**
  3229. * Extend setOptions by picking up the joinBy option and applying it to a
  3230. * series property.
  3231. * @private
  3232. */
  3233. MapSeries.prototype.setOptions = function (itemOptions) {
  3234. var options = Series.prototype.setOptions.call(this,
  3235. itemOptions),
  3236. joinBy = options.joinBy,
  3237. joinByNull = joinBy === null;
  3238. if (joinByNull) {
  3239. joinBy = '_i';
  3240. }
  3241. joinBy = this.joinBy = splat(joinBy);
  3242. if (!joinBy[1]) {
  3243. joinBy[1] = joinBy[0];
  3244. }
  3245. return options;
  3246. };
  3247. /**
  3248. * Add the path option for data points. Find the max value for color
  3249. * calculation.
  3250. * @private
  3251. */
  3252. MapSeries.prototype.translate = function () {
  3253. var series = this,
  3254. xAxis = series.xAxis,
  3255. yAxis = series.yAxis,
  3256. doFullTranslate = series.doFullTranslate();
  3257. series.generatePoints();
  3258. series.data.forEach(function (point) {
  3259. // Record the middle point (loosely based on centroid),
  3260. // determined by the middleX and middleY options.
  3261. if (isNumber(point._midX) && isNumber(point._midY)) {
  3262. point.plotX = xAxis.toPixels(point._midX, true);
  3263. point.plotY = yAxis.toPixels(point._midY, true);
  3264. }
  3265. if (doFullTranslate) {
  3266. point.shapeType = 'path';
  3267. point.shapeArgs = {
  3268. d: series.translatePath(point.path)
  3269. };
  3270. }
  3271. });
  3272. fireEvent(series, 'afterTranslate');
  3273. };
  3274. /**
  3275. * Translate the path, so it automatically fits into the plot area box.
  3276. * @private
  3277. */
  3278. MapSeries.prototype.translatePath = function (path) {
  3279. var series = this,
  3280. xAxis = series.xAxis,
  3281. yAxis = series.yAxis,
  3282. xMin = xAxis.min,
  3283. xTransA = xAxis.transA,
  3284. xMinPixelPadding = xAxis.minPixelPadding,
  3285. yMin = yAxis.min,
  3286. yTransA = yAxis.transA,
  3287. yMinPixelPadding = yAxis.minPixelPadding,
  3288. ret = []; // Preserve the original
  3289. // Do the translation
  3290. if (path) {
  3291. path.forEach(function (seg) {
  3292. if (seg[0] === 'M') {
  3293. ret.push([
  3294. 'M',
  3295. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3296. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding
  3297. ]);
  3298. }
  3299. else if (seg[0] === 'L') {
  3300. ret.push([
  3301. 'L',
  3302. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3303. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding
  3304. ]);
  3305. }
  3306. else if (seg[0] === 'C') {
  3307. ret.push([
  3308. 'C',
  3309. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3310. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding,
  3311. (seg[3] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3312. (seg[4] - (yMin || 0)) * yTransA + yMinPixelPadding,
  3313. (seg[5] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3314. (seg[6] - (yMin || 0)) * yTransA + yMinPixelPadding
  3315. ]);
  3316. }
  3317. else if (seg[0] === 'Q') {
  3318. ret.push([
  3319. 'Q',
  3320. (seg[1] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3321. (seg[2] - (yMin || 0)) * yTransA + yMinPixelPadding,
  3322. (seg[3] - (xMin || 0)) * xTransA + xMinPixelPadding,
  3323. (seg[4] - (yMin || 0)) * yTransA + yMinPixelPadding
  3324. ]);
  3325. }
  3326. else if (seg[0] === 'Z') {
  3327. ret.push(['Z']);
  3328. }
  3329. });
  3330. }
  3331. return ret;
  3332. };
  3333. /**
  3334. * The map series is used for basic choropleth maps, where each map area has
  3335. * a color based on its value.
  3336. *
  3337. * @sample maps/demo/all-maps/
  3338. * Choropleth map
  3339. *
  3340. * @extends plotOptions.scatter
  3341. * @excluding marker, cluster
  3342. * @product highmaps
  3343. * @optionparent plotOptions.map
  3344. */
  3345. MapSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  3346. animation: false,
  3347. dataLabels: {
  3348. crop: false,
  3349. formatter: function () {
  3350. return this.point.value;
  3351. },
  3352. inside: true,
  3353. overflow: false,
  3354. padding: 0,
  3355. verticalAlign: 'middle'
  3356. },
  3357. /**
  3358. * @ignore-option
  3359. *
  3360. * @private
  3361. */
  3362. marker: null,
  3363. /**
  3364. * The color to apply to null points.
  3365. *
  3366. * In styled mode, the null point fill is set in the
  3367. * `.highcharts-null-point` class.
  3368. *
  3369. * @sample maps/demo/all-areas-as-null/
  3370. * Null color
  3371. *
  3372. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3373. *
  3374. * @private
  3375. */
  3376. nullColor: palette.neutralColor3,
  3377. /**
  3378. * Whether to allow pointer interaction like tooltips and mouse events
  3379. * on null points.
  3380. *
  3381. * @type {boolean}
  3382. * @since 4.2.7
  3383. * @apioption plotOptions.map.nullInteraction
  3384. *
  3385. * @private
  3386. */
  3387. stickyTracking: false,
  3388. tooltip: {
  3389. followPointer: true,
  3390. pointFormat: '{point.name}: {point.value}<br/>'
  3391. },
  3392. /**
  3393. * @ignore-option
  3394. *
  3395. * @private
  3396. */
  3397. turboThreshold: 0,
  3398. /**
  3399. * Whether all areas of the map defined in `mapData` should be rendered.
  3400. * If `true`, areas which don't correspond to a data point, are rendered
  3401. * as `null` points. If `false`, those areas are skipped.
  3402. *
  3403. * @sample maps/plotoptions/series-allareas-false/
  3404. * All areas set to false
  3405. *
  3406. * @type {boolean}
  3407. * @default true
  3408. * @product highmaps
  3409. * @apioption plotOptions.series.allAreas
  3410. *
  3411. * @private
  3412. */
  3413. allAreas: true,
  3414. /**
  3415. * The border color of the map areas.
  3416. *
  3417. * In styled mode, the border stroke is given in the `.highcharts-point`
  3418. * class.
  3419. *
  3420. * @sample {highmaps} maps/plotoptions/series-border/
  3421. * Borders demo
  3422. *
  3423. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3424. * @default #cccccc
  3425. * @product highmaps
  3426. * @apioption plotOptions.series.borderColor
  3427. *
  3428. * @private
  3429. */
  3430. borderColor: palette.neutralColor20,
  3431. /**
  3432. * The border width of each map area.
  3433. *
  3434. * In styled mode, the border stroke width is given in the
  3435. * `.highcharts-point` class.
  3436. *
  3437. * @sample maps/plotoptions/series-border/
  3438. * Borders demo
  3439. *
  3440. * @type {number}
  3441. * @default 1
  3442. * @product highmaps
  3443. * @apioption plotOptions.series.borderWidth
  3444. *
  3445. * @private
  3446. */
  3447. borderWidth: 1,
  3448. /**
  3449. * @type {string}
  3450. * @default value
  3451. * @apioption plotOptions.map.colorKey
  3452. */
  3453. /**
  3454. * What property to join the `mapData` to the value data. For example,
  3455. * if joinBy is "code", the mapData items with a specific code is merged
  3456. * into the data with the same code. For maps loaded from GeoJSON, the
  3457. * keys may be held in each point's `properties` object.
  3458. *
  3459. * The joinBy option can also be an array of two values, where the first
  3460. * points to a key in the `mapData`, and the second points to another
  3461. * key in the `data`.
  3462. *
  3463. * When joinBy is `null`, the map items are joined by their position in
  3464. * the array, which performs much better in maps with many data points.
  3465. * This is the recommended option if you are printing more than a
  3466. * thousand data points and have a backend that can preprocess the data
  3467. * into a parallel array of the mapData.
  3468. *
  3469. * @sample maps/plotoptions/series-border/
  3470. * Joined by "code"
  3471. * @sample maps/demo/geojson/
  3472. * GeoJSON joined by an array
  3473. * @sample maps/series/joinby-null/
  3474. * Simple data joined by null
  3475. *
  3476. * @type {string|Array<string>}
  3477. * @default hc-key
  3478. * @product highmaps
  3479. * @apioption plotOptions.series.joinBy
  3480. *
  3481. * @private
  3482. */
  3483. joinBy: 'hc-key',
  3484. /**
  3485. * Define the z index of the series.
  3486. *
  3487. * @type {number}
  3488. * @product highmaps
  3489. * @apioption plotOptions.series.zIndex
  3490. */
  3491. /**
  3492. * @apioption plotOptions.series.states
  3493. *
  3494. * @private
  3495. */
  3496. states: {
  3497. /**
  3498. * @apioption plotOptions.series.states.hover
  3499. */
  3500. hover: {
  3501. /** @ignore-option */
  3502. halo: null,
  3503. /**
  3504. * The color of the shape in this state.
  3505. *
  3506. * @sample maps/plotoptions/series-states-hover/
  3507. * Hover options
  3508. *
  3509. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3510. * @product highmaps
  3511. * @apioption plotOptions.series.states.hover.color
  3512. */
  3513. /**
  3514. * The border color of the point in this state.
  3515. *
  3516. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3517. * @product highmaps
  3518. * @apioption plotOptions.series.states.hover.borderColor
  3519. */
  3520. /**
  3521. * The border width of the point in this state
  3522. *
  3523. * @type {number}
  3524. * @product highmaps
  3525. * @apioption plotOptions.series.states.hover.borderWidth
  3526. */
  3527. /**
  3528. * The relative brightness of the point when hovered, relative
  3529. * to the normal point color.
  3530. *
  3531. * @type {number}
  3532. * @product highmaps
  3533. * @default 0.2
  3534. * @apioption plotOptions.series.states.hover.brightness
  3535. */
  3536. brightness: 0.2
  3537. },
  3538. /**
  3539. * @apioption plotOptions.series.states.normal
  3540. */
  3541. normal: {
  3542. /**
  3543. * @productdesc {highmaps}
  3544. * The animation adds some latency in order to reduce the effect
  3545. * of flickering when hovering in and out of for example an
  3546. * uneven coastline.
  3547. *
  3548. * @sample {highmaps} maps/plotoptions/series-states-animation-false/
  3549. * No animation of fill color
  3550. *
  3551. * @apioption plotOptions.series.states.normal.animation
  3552. */
  3553. animation: true
  3554. },
  3555. /**
  3556. * @apioption plotOptions.series.states.select
  3557. */
  3558. select: {
  3559. /**
  3560. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3561. * @default ${palette.neutralColor20}
  3562. * @product highmaps
  3563. * @apioption plotOptions.series.states.select.color
  3564. */
  3565. color: palette.neutralColor20
  3566. },
  3567. inactive: {
  3568. opacity: 1
  3569. }
  3570. }
  3571. });
  3572. return MapSeries;
  3573. }(ScatterSeries));
  3574. extend(MapSeries.prototype, {
  3575. type: 'map',
  3576. axisTypes: colorMapSeriesMixin.axisTypes,
  3577. colorAttribs: colorMapSeriesMixin.colorAttribs,
  3578. colorKey: colorMapSeriesMixin.colorKey,
  3579. // When tooltip is not shared, this series (and derivatives) requires
  3580. // direct touch/hover. KD-tree does not apply.
  3581. directTouch: true,
  3582. // We need the points' bounding boxes in order to draw the data labels,
  3583. // so we skip it now and call it from drawPoints instead.
  3584. drawDataLabels: noop,
  3585. // No graph for the map series
  3586. drawGraph: noop,
  3587. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  3588. forceDL: true,
  3589. getExtremesFromAll: true,
  3590. getSymbol: colorMapSeriesMixin.getSymbol,
  3591. parallelArrays: colorMapSeriesMixin.parallelArrays,
  3592. pointArrayMap: colorMapSeriesMixin.pointArrayMap,
  3593. pointClass: MapPoint,
  3594. // X axis and Y axis must have same translation slope
  3595. preserveAspectRatio: true,
  3596. searchPoint: noop,
  3597. trackerGroups: colorMapSeriesMixin.trackerGroups,
  3598. // Get axis extremes from paths, not values
  3599. useMapGeometry: true
  3600. });
  3601. SeriesRegistry.registerSeriesType('map', MapSeries);
  3602. /* *
  3603. *
  3604. * Default Export
  3605. *
  3606. * */
  3607. /* *
  3608. *
  3609. * API Options
  3610. *
  3611. * */
  3612. /**
  3613. * A map data object containing a `path` definition and optionally additional
  3614. * properties to join in the data as per the `joinBy` option.
  3615. *
  3616. * @sample maps/demo/category-map/
  3617. * Map data and joinBy
  3618. *
  3619. * @type {Array<Highcharts.SeriesMapDataOptions>|*}
  3620. * @product highmaps
  3621. * @apioption series.mapData
  3622. */
  3623. /**
  3624. * A `map` series. If the [type](#series.map.type) option is not specified, it
  3625. * is inherited from [chart.type](#chart.type).
  3626. *
  3627. * @extends series,plotOptions.map
  3628. * @excluding dataParser, dataURL, marker
  3629. * @product highmaps
  3630. * @apioption series.map
  3631. */
  3632. /**
  3633. * An array of data points for the series. For the `map` series type, points can
  3634. * be given in the following ways:
  3635. *
  3636. * 1. An array of numerical values. In this case, the numerical values will be
  3637. * interpreted as `value` options. Example:
  3638. * ```js
  3639. * data: [0, 5, 3, 5]
  3640. * ```
  3641. *
  3642. * 2. An array of arrays with 2 values. In this case, the values correspond to
  3643. * `[hc-key, value]`. Example:
  3644. * ```js
  3645. * data: [
  3646. * ['us-ny', 0],
  3647. * ['us-mi', 5],
  3648. * ['us-tx', 3],
  3649. * ['us-ak', 5]
  3650. * ]
  3651. * ```
  3652. *
  3653. * 3. An array of objects with named values. The following snippet shows only a
  3654. * few settings, see the complete options set below. If the total number of
  3655. * data points exceeds the series'
  3656. * [turboThreshold](#series.map.turboThreshold),
  3657. * this option is not available.
  3658. * ```js
  3659. * data: [{
  3660. * value: 6,
  3661. * name: "Point2",
  3662. * color: "#00FF00"
  3663. * }, {
  3664. * value: 6,
  3665. * name: "Point1",
  3666. * color: "#FF00FF"
  3667. * }]
  3668. * ```
  3669. *
  3670. * @type {Array<number|Array<string,(number|null)>|null|*>}
  3671. * @product highmaps
  3672. * @apioption series.map.data
  3673. */
  3674. /**
  3675. * Individual color for the point. By default the color is either used
  3676. * to denote the value, or pulled from the global `colors` array.
  3677. *
  3678. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3679. * @product highmaps
  3680. * @apioption series.map.data.color
  3681. */
  3682. /**
  3683. * Individual data label for each point. The options are the same as
  3684. * the ones for [plotOptions.series.dataLabels](
  3685. * #plotOptions.series.dataLabels).
  3686. *
  3687. * @sample maps/series/data-datalabels/
  3688. * Disable data labels for individual areas
  3689. *
  3690. * @type {Highcharts.DataLabelsOptions}
  3691. * @product highmaps
  3692. * @apioption series.map.data.dataLabels
  3693. */
  3694. /**
  3695. * The `id` of a series in the [drilldown.series](#drilldown.series)
  3696. * array to use for a drilldown for this point.
  3697. *
  3698. * @sample maps/demo/map-drilldown/
  3699. * Basic drilldown
  3700. *
  3701. * @type {string}
  3702. * @product highmaps
  3703. * @apioption series.map.data.drilldown
  3704. */
  3705. /**
  3706. * An id for the point. This can be used after render time to get a
  3707. * pointer to the point object through `chart.get()`.
  3708. *
  3709. * @sample maps/series/data-id/
  3710. * Highlight a point by id
  3711. *
  3712. * @type {string}
  3713. * @product highmaps
  3714. * @apioption series.map.data.id
  3715. */
  3716. /**
  3717. * When data labels are laid out on a map, Highmaps runs a simplified
  3718. * algorithm to detect collision. When two labels collide, the one with
  3719. * the lowest rank is hidden. By default the rank is computed from the
  3720. * area.
  3721. *
  3722. * @type {number}
  3723. * @product highmaps
  3724. * @apioption series.map.data.labelrank
  3725. */
  3726. /**
  3727. * The relative mid point of an area, used to place the data label.
  3728. * Ranges from 0 to 1\. When `mapData` is used, middleX can be defined
  3729. * there.
  3730. *
  3731. * @type {number}
  3732. * @default 0.5
  3733. * @product highmaps
  3734. * @apioption series.map.data.middleX
  3735. */
  3736. /**
  3737. * The relative mid point of an area, used to place the data label.
  3738. * Ranges from 0 to 1\. When `mapData` is used, middleY can be defined
  3739. * there.
  3740. *
  3741. * @type {number}
  3742. * @default 0.5
  3743. * @product highmaps
  3744. * @apioption series.map.data.middleY
  3745. */
  3746. /**
  3747. * The name of the point as shown in the legend, tooltip, dataLabel
  3748. * etc.
  3749. *
  3750. * @sample maps/series/data-datalabels/
  3751. * Point names
  3752. *
  3753. * @type {string}
  3754. * @product highmaps
  3755. * @apioption series.map.data.name
  3756. */
  3757. /**
  3758. * For map and mapline series types, the SVG path for the shape. For
  3759. * compatibily with old IE, not all SVG path definitions are supported,
  3760. * but M, L and C operators are safe.
  3761. *
  3762. * To achieve a better separation between the structure and the data,
  3763. * it is recommended to use `mapData` to define that paths instead
  3764. * of defining them on the data points themselves.
  3765. *
  3766. * @sample maps/series/data-path/
  3767. * Paths defined in data
  3768. *
  3769. * @type {string}
  3770. * @product highmaps
  3771. * @apioption series.map.data.path
  3772. */
  3773. /**
  3774. * The numeric value of the data point.
  3775. *
  3776. * @type {number|null}
  3777. * @product highmaps
  3778. * @apioption series.map.data.value
  3779. */
  3780. /**
  3781. * Individual point events
  3782. *
  3783. * @extends plotOptions.series.point.events
  3784. * @product highmaps
  3785. * @apioption series.map.data.events
  3786. */
  3787. ''; // adds doclets above to the transpiled file
  3788. return MapSeries;
  3789. });
  3790. _registerModule(_modules, 'Series/MapLine/MapLineSeries.js', [_modules['Series/Map/MapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MapSeries, SeriesRegistry, U) {
  3791. /* *
  3792. *
  3793. * (c) 2010-2021 Torstein Honsi
  3794. *
  3795. * License: www.highcharts.com/license
  3796. *
  3797. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3798. *
  3799. * */
  3800. var __extends = (this && this.__extends) || (function () {
  3801. var extendStatics = function (d,
  3802. b) {
  3803. extendStatics = Object.setPrototypeOf ||
  3804. ({ __proto__: [] } instanceof Array && function (d,
  3805. b) { d.__proto__ = b; }) ||
  3806. function (d,
  3807. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3808. return extendStatics(d, b);
  3809. };
  3810. return function (d, b) {
  3811. extendStatics(d, b);
  3812. function __() { this.constructor = d; }
  3813. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3814. };
  3815. })();
  3816. var Series = SeriesRegistry.series;
  3817. var extend = U.extend,
  3818. merge = U.merge;
  3819. /* *
  3820. *
  3821. * Class
  3822. *
  3823. * */
  3824. /**
  3825. * @private
  3826. * @class
  3827. * @name Highcharts.seriesTypes.mapline
  3828. *
  3829. * @augments Highcharts.Series
  3830. */
  3831. var MapLineSeries = /** @class */ (function (_super) {
  3832. __extends(MapLineSeries, _super);
  3833. function MapLineSeries() {
  3834. /* *
  3835. *
  3836. * Static Properties
  3837. *
  3838. * */
  3839. var _this = _super !== null && _super.apply(this,
  3840. arguments) || this;
  3841. /* *
  3842. *
  3843. * Properties
  3844. *
  3845. * */
  3846. _this.data = void 0;
  3847. _this.options = void 0;
  3848. _this.points = void 0;
  3849. return _this;
  3850. /* eslint-enable valid-jsdoc */
  3851. }
  3852. /* *
  3853. *
  3854. * Functions
  3855. *
  3856. * */
  3857. /* eslint-disable valid-jsdoc */
  3858. /**
  3859. * Get presentational attributes
  3860. *
  3861. * @private
  3862. * @function Highcharts.seriesTypes.mapline#pointAttribs
  3863. * @param {Highcharts.Point} point
  3864. * @param {string} state
  3865. * @return {Highcharts.SVGAttributes}
  3866. */
  3867. MapLineSeries.prototype.pointAttribs = function (point, state) {
  3868. var attr = MapSeries.prototype.pointAttribs.call(this,
  3869. point,
  3870. state);
  3871. // The difference from a map series is that the stroke takes the
  3872. // point color
  3873. attr.fill = this.options.fillColor;
  3874. return attr;
  3875. };
  3876. /**
  3877. * A mapline series is a special case of the map series where the value
  3878. * colors are applied to the strokes rather than the fills. It can also be
  3879. * used for freeform drawing, like dividers, in the map.
  3880. *
  3881. * @sample maps/demo/mapline-mappoint/
  3882. * Mapline and map-point chart
  3883. *
  3884. * @extends plotOptions.map
  3885. * @product highmaps
  3886. * @optionparent plotOptions.mapline
  3887. */
  3888. MapLineSeries.defaultOptions = merge(MapSeries.defaultOptions, {
  3889. /**
  3890. * The width of the map line.
  3891. */
  3892. lineWidth: 1,
  3893. /**
  3894. * Fill color for the map line shapes
  3895. *
  3896. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3897. */
  3898. fillColor: 'none'
  3899. });
  3900. return MapLineSeries;
  3901. }(MapSeries));
  3902. extend(MapLineSeries.prototype, {
  3903. type: 'mapline',
  3904. colorProp: 'stroke',
  3905. drawLegendSymbol: Series.prototype.drawLegendSymbol,
  3906. pointAttrToOptions: {
  3907. 'stroke': 'color',
  3908. 'stroke-width': 'lineWidth'
  3909. }
  3910. });
  3911. SeriesRegistry.registerSeriesType('mapline', MapLineSeries);
  3912. /* *
  3913. *
  3914. * Default Export
  3915. *
  3916. * */
  3917. /* *
  3918. *
  3919. * API Options
  3920. *
  3921. * */
  3922. /**
  3923. * A `mapline` series. If the [type](#series.mapline.type) option is
  3924. * not specified, it is inherited from [chart.type](#chart.type).
  3925. *
  3926. * @extends series,plotOptions.mapline
  3927. * @excluding dataParser, dataURL, marker
  3928. * @product highmaps
  3929. * @apioption series.mapline
  3930. */
  3931. /**
  3932. * An array of data points for the series. For the `mapline` series type,
  3933. * points can be given in the following ways:
  3934. *
  3935. * 1. An array of numerical values. In this case, the numerical values
  3936. * will be interpreted as `value` options. Example:
  3937. *
  3938. * ```js
  3939. * data: [0, 5, 3, 5]
  3940. * ```
  3941. *
  3942. * 2. An array of arrays with 2 values. In this case, the values correspond
  3943. * to `[hc-key, value]`. Example:
  3944. *
  3945. * ```js
  3946. * data: [
  3947. * ['us-ny', 0],
  3948. * ['us-mi', 5],
  3949. * ['us-tx', 3],
  3950. * ['us-ak', 5]
  3951. * ]
  3952. * ```
  3953. *
  3954. * 3. An array of objects with named values. The following snippet shows only a
  3955. * few settings, see the complete options set below. If the total number of data
  3956. * points exceeds the series' [turboThreshold](#series.map.turboThreshold),
  3957. * this option is not available.
  3958. *
  3959. * ```js
  3960. * data: [{
  3961. * value: 6,
  3962. * name: "Point2",
  3963. * color: "#00FF00"
  3964. * }, {
  3965. * value: 6,
  3966. * name: "Point1",
  3967. * color: "#FF00FF"
  3968. * }]
  3969. * ```
  3970. *
  3971. * @type {Array<number|Array<string,(number|null)>|null|*>}
  3972. * @product highmaps
  3973. * @apioption series.mapline.data
  3974. */
  3975. ''; // adds doclets above to transpiled file
  3976. return MapLineSeries;
  3977. });
  3978. _registerModule(_modules, 'Series/MapPoint/MapPointPoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  3979. /* *
  3980. *
  3981. * (c) 2010-2021 Torstein Honsi
  3982. *
  3983. * License: www.highcharts.com/license
  3984. *
  3985. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3986. *
  3987. * */
  3988. var __extends = (this && this.__extends) || (function () {
  3989. var extendStatics = function (d,
  3990. b) {
  3991. extendStatics = Object.setPrototypeOf ||
  3992. ({ __proto__: [] } instanceof Array && function (d,
  3993. b) { d.__proto__ = b; }) ||
  3994. function (d,
  3995. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3996. return extendStatics(d, b);
  3997. };
  3998. return function (d, b) {
  3999. extendStatics(d, b);
  4000. function __() { this.constructor = d; }
  4001. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4002. };
  4003. })();
  4004. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  4005. var merge = U.merge;
  4006. /* *
  4007. *
  4008. * Class
  4009. *
  4010. * */
  4011. var MapPointPoint = /** @class */ (function (_super) {
  4012. __extends(MapPointPoint, _super);
  4013. function MapPointPoint() {
  4014. /* *
  4015. *
  4016. * Properties
  4017. *
  4018. * */
  4019. var _this = _super !== null && _super.apply(this,
  4020. arguments) || this;
  4021. _this.options = void 0;
  4022. _this.series = void 0;
  4023. return _this;
  4024. /* eslint-enable valid-jsdoc */
  4025. }
  4026. /* *
  4027. *
  4028. * Functions
  4029. *
  4030. * */
  4031. /* eslint-disable valid-jsdoc */
  4032. MapPointPoint.prototype.applyOptions = function (options, x) {
  4033. var mergedOptions = (typeof options.lat !== 'undefined' &&
  4034. typeof options.lon !== 'undefined' ?
  4035. merge(options,
  4036. this.series.chart.fromLatLonToPoint(options)) :
  4037. options);
  4038. return _super.prototype.applyOptions.call(this, mergedOptions, x);
  4039. };
  4040. return MapPointPoint;
  4041. }(ScatterSeries.prototype.pointClass));
  4042. /* *
  4043. *
  4044. * Default Export
  4045. *
  4046. * */
  4047. return MapPointPoint;
  4048. });
  4049. _registerModule(_modules, 'Series/MapPoint/MapPointSeries.js', [_modules['Series/MapPoint/MapPointPoint.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MapPointPoint, palette, SeriesRegistry, U) {
  4050. /* *
  4051. *
  4052. * (c) 2010-2021 Torstein Honsi
  4053. *
  4054. * License: www.highcharts.com/license
  4055. *
  4056. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4057. *
  4058. * */
  4059. var __extends = (this && this.__extends) || (function () {
  4060. var extendStatics = function (d,
  4061. b) {
  4062. extendStatics = Object.setPrototypeOf ||
  4063. ({ __proto__: [] } instanceof Array && function (d,
  4064. b) { d.__proto__ = b; }) ||
  4065. function (d,
  4066. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4067. return extendStatics(d, b);
  4068. };
  4069. return function (d, b) {
  4070. extendStatics(d, b);
  4071. function __() { this.constructor = d; }
  4072. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4073. };
  4074. })();
  4075. var ScatterSeries = SeriesRegistry.seriesTypes.scatter;
  4076. var extend = U.extend,
  4077. merge = U.merge;
  4078. /* *
  4079. *
  4080. * Class
  4081. *
  4082. * */
  4083. /**
  4084. * @private
  4085. * @class
  4086. * @name Highcharts.seriesTypes.mappoint
  4087. *
  4088. * @augments Highcharts.Series
  4089. */
  4090. var MapPointSeries = /** @class */ (function (_super) {
  4091. __extends(MapPointSeries, _super);
  4092. function MapPointSeries() {
  4093. /* *
  4094. *
  4095. * Static Properties
  4096. *
  4097. * */
  4098. var _this = _super !== null && _super.apply(this,
  4099. arguments) || this;
  4100. /* *
  4101. *
  4102. * Properties
  4103. *
  4104. * */
  4105. _this.data = void 0;
  4106. _this.options = void 0;
  4107. _this.points = void 0;
  4108. return _this;
  4109. /* eslint-enable valid-jsdoc */
  4110. }
  4111. /* *
  4112. *
  4113. * Functions
  4114. *
  4115. * */
  4116. /* eslint-disable valid-jsdoc */
  4117. MapPointSeries.prototype.drawDataLabels = function () {
  4118. _super.prototype.drawDataLabels.call(this);
  4119. if (this.dataLabelsGroup) {
  4120. this.dataLabelsGroup.clip(this.chart.clipRect);
  4121. }
  4122. };
  4123. /**
  4124. * A mappoint series is a special form of scatter series where the points
  4125. * can be laid out in map coordinates on top of a map.
  4126. *
  4127. * @sample maps/demo/mapline-mappoint/
  4128. * Map-line and map-point series.
  4129. *
  4130. * @extends plotOptions.scatter
  4131. * @product highmaps
  4132. * @optionparent plotOptions.mappoint
  4133. */
  4134. MapPointSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  4135. dataLabels: {
  4136. crop: false,
  4137. defer: false,
  4138. enabled: true,
  4139. formatter: function () {
  4140. return this.point.name;
  4141. },
  4142. overflow: false,
  4143. style: {
  4144. /** @internal */
  4145. color: palette.neutralColor100
  4146. }
  4147. }
  4148. });
  4149. return MapPointSeries;
  4150. }(ScatterSeries));
  4151. extend(MapPointSeries.prototype, {
  4152. type: 'mappoint',
  4153. forceDL: true,
  4154. pointClass: MapPointPoint
  4155. });
  4156. SeriesRegistry.registerSeriesType('mappoint', MapPointSeries);
  4157. /* *
  4158. *
  4159. * Default Export
  4160. *
  4161. * */
  4162. /* *
  4163. *
  4164. * API Options
  4165. *
  4166. * */
  4167. /**
  4168. * A `mappoint` series. If the [type](#series.mappoint.type) option
  4169. * is not specified, it is inherited from [chart.type](#chart.type).
  4170. *
  4171. *
  4172. * @extends series,plotOptions.mappoint
  4173. * @excluding dataParser, dataURL
  4174. * @product highmaps
  4175. * @apioption series.mappoint
  4176. */
  4177. /**
  4178. * An array of data points for the series. For the `mappoint` series
  4179. * type, points can be given in the following ways:
  4180. *
  4181. * 1. An array of numerical values. In this case, the numerical values will be
  4182. * interpreted as `y` options. The `x` values will be automatically
  4183. * calculated, either starting at 0 and incremented by 1, or from
  4184. * `pointStart` and `pointInterval` given in the series options. If the axis
  4185. * has categories, these will be used. Example:
  4186. * ```js
  4187. * data: [0, 5, 3, 5]
  4188. * ```
  4189. *
  4190. * 2. An array of arrays with 2 values. In this case, the values correspond to
  4191. * `x,y`. If the first value is a string, it is applied as the name of the
  4192. * point, and the `x` value is inferred.
  4193. * ```js
  4194. * data: [
  4195. * [0, 1],
  4196. * [1, 8],
  4197. * [2, 7]
  4198. * ]
  4199. * ```
  4200. *
  4201. * 3. An array of objects with named values. The following snippet shows only a
  4202. * few settings, see the complete options set below. If the total number of
  4203. * data points exceeds the series'
  4204. * [turboThreshold](#series.mappoint.turboThreshold),
  4205. * this option is not available.
  4206. * ```js
  4207. * data: [{
  4208. * x: 1,
  4209. * y: 7,
  4210. * name: "Point2",
  4211. * color: "#00FF00"
  4212. * }, {
  4213. * x: 1,
  4214. * y: 4,
  4215. * name: "Point1",
  4216. * color: "#FF00FF"
  4217. * }]
  4218. * ```
  4219. *
  4220. * @type {Array<number|Array<number,(number|null)>|null|*>}
  4221. * @extends series.map.data
  4222. * @excluding labelrank, middleX, middleY, path, value
  4223. * @product highmaps
  4224. * @apioption series.mappoint.data
  4225. */
  4226. /**
  4227. * The latitude of the point. Must be combined with the `lon` option
  4228. * to work. Overrides `x` and `y` values.
  4229. *
  4230. * @sample {highmaps} maps/demo/mappoint-latlon/
  4231. * Point position by lat/lon
  4232. *
  4233. * @type {number}
  4234. * @since 1.1.0
  4235. * @product highmaps
  4236. * @apioption series.mappoint.data.lat
  4237. */
  4238. /**
  4239. * The longitude of the point. Must be combined with the `lon` option
  4240. * to work. Overrides `x` and `y` values.
  4241. *
  4242. * @sample {highmaps} maps/demo/mappoint-latlon/
  4243. * Point position by lat/lon
  4244. *
  4245. * @type {number}
  4246. * @since 1.1.0
  4247. * @product highmaps
  4248. * @apioption series.mappoint.data.lon
  4249. */
  4250. /**
  4251. * The x coordinate of the point in terms of the map path coordinates.
  4252. *
  4253. * @sample {highmaps} maps/demo/mapline-mappoint/
  4254. * Map point demo
  4255. *
  4256. * @type {number}
  4257. * @product highmaps
  4258. * @apioption series.mappoint.data.x
  4259. */
  4260. /**
  4261. * The x coordinate of the point in terms of the map path coordinates.
  4262. *
  4263. * @sample {highmaps} maps/demo/mapline-mappoint/
  4264. * Map point demo
  4265. *
  4266. * @type {number|null}
  4267. * @product highmaps
  4268. * @apioption series.mappoint.data.y
  4269. */
  4270. ''; // adds doclets above to transpiled file
  4271. return MapPointSeries;
  4272. });
  4273. _registerModule(_modules, 'Series/Bubble/BubblePoint.js', [_modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Point, SeriesRegistry, U) {
  4274. /* *
  4275. *
  4276. * (c) 2010-2021 Torstein Honsi
  4277. *
  4278. * License: www.highcharts.com/license
  4279. *
  4280. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4281. *
  4282. * */
  4283. var __extends = (this && this.__extends) || (function () {
  4284. var extendStatics = function (d,
  4285. b) {
  4286. extendStatics = Object.setPrototypeOf ||
  4287. ({ __proto__: [] } instanceof Array && function (d,
  4288. b) { d.__proto__ = b; }) ||
  4289. function (d,
  4290. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4291. return extendStatics(d, b);
  4292. };
  4293. return function (d, b) {
  4294. extendStatics(d, b);
  4295. function __() { this.constructor = d; }
  4296. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4297. };
  4298. })();
  4299. var ScatterPoint = SeriesRegistry.seriesTypes.scatter.prototype.pointClass;
  4300. var extend = U.extend;
  4301. /* *
  4302. *
  4303. * Class
  4304. *
  4305. * */
  4306. var BubblePoint = /** @class */ (function (_super) {
  4307. __extends(BubblePoint, _super);
  4308. function BubblePoint() {
  4309. /* *
  4310. *
  4311. * Properties
  4312. *
  4313. * */
  4314. var _this = _super !== null && _super.apply(this,
  4315. arguments) || this;
  4316. _this.options = void 0;
  4317. _this.series = void 0;
  4318. return _this;
  4319. /* eslint-enable valid-jsdoc */
  4320. }
  4321. /* *
  4322. *
  4323. * Functions
  4324. *
  4325. * */
  4326. /* eslint-disable valid-jsdoc */
  4327. /**
  4328. * @private
  4329. */
  4330. BubblePoint.prototype.haloPath = function (size) {
  4331. return Point.prototype.haloPath.call(this,
  4332. // #6067
  4333. size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size);
  4334. };
  4335. return BubblePoint;
  4336. }(ScatterPoint));
  4337. extend(BubblePoint.prototype, {
  4338. ttBelow: false
  4339. });
  4340. /* *
  4341. *
  4342. * Default Export
  4343. *
  4344. * */
  4345. return BubblePoint;
  4346. });
  4347. _registerModule(_modules, 'Series/Bubble/BubbleLegend.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Chart, Color, H, Legend, palette, Series, U) {
  4348. /* *
  4349. *
  4350. * (c) 2010-2021 Highsoft AS
  4351. *
  4352. * Author: Paweł Potaczek
  4353. *
  4354. * License: www.highcharts.com/license
  4355. *
  4356. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4357. *
  4358. * */
  4359. var color = Color.parse;
  4360. var noop = H.noop;
  4361. var addEvent = U.addEvent,
  4362. arrayMax = U.arrayMax,
  4363. arrayMin = U.arrayMin,
  4364. isNumber = U.isNumber,
  4365. merge = U.merge,
  4366. objectEach = U.objectEach,
  4367. pick = U.pick,
  4368. setOptions = U.setOptions,
  4369. stableSort = U.stableSort,
  4370. wrap = U.wrap;
  4371. /**
  4372. * @interface Highcharts.BubbleLegendFormatterContextObject
  4373. */ /**
  4374. * The center y position of the range.
  4375. * @name Highcharts.BubbleLegendFormatterContextObject#center
  4376. * @type {number}
  4377. */ /**
  4378. * The radius of the bubble range.
  4379. * @name Highcharts.BubbleLegendFormatterContextObject#radius
  4380. * @type {number}
  4381. */ /**
  4382. * The bubble value.
  4383. * @name Highcharts.BubbleLegendFormatterContextObject#value
  4384. * @type {number}
  4385. */
  4386. ''; // detach doclets above
  4387. setOptions({
  4388. legend: {
  4389. /**
  4390. * The bubble legend is an additional element in legend which
  4391. * presents the scale of the bubble series. Individual bubble ranges
  4392. * can be defined by user or calculated from series. In the case of
  4393. * automatically calculated ranges, a 1px margin of error is
  4394. * permitted.
  4395. *
  4396. * @since 7.0.0
  4397. * @product highcharts highstock highmaps
  4398. * @requires highcharts-more
  4399. * @optionparent legend.bubbleLegend
  4400. */
  4401. bubbleLegend: {
  4402. /**
  4403. * The color of the ranges borders, can be also defined for an
  4404. * individual range.
  4405. *
  4406. * @sample highcharts/bubble-legend/similartoseries/
  4407. * Similar look to the bubble series
  4408. * @sample highcharts/bubble-legend/bordercolor/
  4409. * Individual bubble border color
  4410. *
  4411. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4412. */
  4413. borderColor: void 0,
  4414. /**
  4415. * The width of the ranges borders in pixels, can be also
  4416. * defined for an individual range.
  4417. */
  4418. borderWidth: 2,
  4419. /**
  4420. * An additional class name to apply to the bubble legend'
  4421. * circle graphical elements. This option does not replace
  4422. * default class names of the graphical element.
  4423. *
  4424. * @sample {highcharts} highcharts/css/bubble-legend/
  4425. * Styling by CSS
  4426. *
  4427. * @type {string}
  4428. */
  4429. className: void 0,
  4430. /**
  4431. * The main color of the bubble legend. Applies to ranges, if
  4432. * individual color is not defined.
  4433. *
  4434. * @sample highcharts/bubble-legend/similartoseries/
  4435. * Similar look to the bubble series
  4436. * @sample highcharts/bubble-legend/color/
  4437. * Individual bubble color
  4438. *
  4439. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4440. */
  4441. color: void 0,
  4442. /**
  4443. * An additional class name to apply to the bubble legend's
  4444. * connector graphical elements. This option does not replace
  4445. * default class names of the graphical element.
  4446. *
  4447. * @sample {highcharts} highcharts/css/bubble-legend/
  4448. * Styling by CSS
  4449. *
  4450. * @type {string}
  4451. */
  4452. connectorClassName: void 0,
  4453. /**
  4454. * The color of the connector, can be also defined
  4455. * for an individual range.
  4456. *
  4457. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4458. */
  4459. connectorColor: void 0,
  4460. /**
  4461. * The length of the connectors in pixels. If labels are
  4462. * centered, the distance is reduced to 0.
  4463. *
  4464. * @sample highcharts/bubble-legend/connectorandlabels/
  4465. * Increased connector length
  4466. */
  4467. connectorDistance: 60,
  4468. /**
  4469. * The width of the connectors in pixels.
  4470. *
  4471. * @sample highcharts/bubble-legend/connectorandlabels/
  4472. * Increased connector width
  4473. */
  4474. connectorWidth: 1,
  4475. /**
  4476. * Enable or disable the bubble legend.
  4477. */
  4478. enabled: false,
  4479. /**
  4480. * Options for the bubble legend labels.
  4481. */
  4482. labels: {
  4483. /**
  4484. * An additional class name to apply to the bubble legend
  4485. * label graphical elements. This option does not replace
  4486. * default class names of the graphical element.
  4487. *
  4488. * @sample {highcharts} highcharts/css/bubble-legend/
  4489. * Styling by CSS
  4490. *
  4491. * @type {string}
  4492. */
  4493. className: void 0,
  4494. /**
  4495. * Whether to allow data labels to overlap.
  4496. */
  4497. allowOverlap: false,
  4498. /**
  4499. * A format string for the bubble legend labels. Available
  4500. * variables are the same as for `formatter`.
  4501. *
  4502. * @sample highcharts/bubble-legend/format/
  4503. * Add a unit
  4504. *
  4505. * @type {string}
  4506. */
  4507. format: '',
  4508. /**
  4509. * Available `this` properties are:
  4510. *
  4511. * - `this.value`: The bubble value.
  4512. *
  4513. * - `this.radius`: The radius of the bubble range.
  4514. *
  4515. * - `this.center`: The center y position of the range.
  4516. *
  4517. * @type {Highcharts.FormatterCallbackFunction<Highcharts.BubbleLegendFormatterContextObject>}
  4518. */
  4519. formatter: void 0,
  4520. /**
  4521. * The alignment of the labels compared to the bubble
  4522. * legend. Can be one of `left`, `center` or `right`.
  4523. *
  4524. * @sample highcharts/bubble-legend/connectorandlabels/
  4525. * Labels on left
  4526. *
  4527. * @type {Highcharts.AlignValue}
  4528. */
  4529. align: 'right',
  4530. /**
  4531. * CSS styles for the labels.
  4532. *
  4533. * @type {Highcharts.CSSObject}
  4534. */
  4535. style: {
  4536. /** @ignore-option */
  4537. fontSize: 10,
  4538. /** @ignore-option */
  4539. color: void 0
  4540. },
  4541. /**
  4542. * The x position offset of the label relative to the
  4543. * connector.
  4544. */
  4545. x: 0,
  4546. /**
  4547. * The y position offset of the label relative to the
  4548. * connector.
  4549. */
  4550. y: 0
  4551. },
  4552. /**
  4553. * Miximum bubble legend range size. If values for ranges are
  4554. * not specified, the `minSize` and the `maxSize` are calculated
  4555. * from bubble series.
  4556. */
  4557. maxSize: 60,
  4558. /**
  4559. * Minimum bubble legend range size. If values for ranges are
  4560. * not specified, the `minSize` and the `maxSize` are calculated
  4561. * from bubble series.
  4562. */
  4563. minSize: 10,
  4564. /**
  4565. * The position of the bubble legend in the legend.
  4566. * @sample highcharts/bubble-legend/connectorandlabels/
  4567. * Bubble legend as last item in legend
  4568. */
  4569. legendIndex: 0,
  4570. /**
  4571. * Options for specific range. One range consists of bubble,
  4572. * label and connector.
  4573. *
  4574. * @sample highcharts/bubble-legend/ranges/
  4575. * Manually defined ranges
  4576. * @sample highcharts/bubble-legend/autoranges/
  4577. * Auto calculated ranges
  4578. *
  4579. * @type {Array<*>}
  4580. */
  4581. ranges: {
  4582. /**
  4583. * Range size value, similar to bubble Z data.
  4584. * @type {number}
  4585. */
  4586. value: void 0,
  4587. /**
  4588. * The color of the border for individual range.
  4589. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4590. */
  4591. borderColor: void 0,
  4592. /**
  4593. * The color of the bubble for individual range.
  4594. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4595. */
  4596. color: void 0,
  4597. /**
  4598. * The color of the connector for individual range.
  4599. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4600. */
  4601. connectorColor: void 0
  4602. },
  4603. /**
  4604. * Whether the bubble legend range value should be represented
  4605. * by the area or the width of the bubble. The default, area,
  4606. * corresponds best to the human perception of the size of each
  4607. * bubble.
  4608. *
  4609. * @sample highcharts/bubble-legend/ranges/
  4610. * Size by width
  4611. *
  4612. * @type {Highcharts.BubbleSizeByValue}
  4613. */
  4614. sizeBy: 'area',
  4615. /**
  4616. * When this is true, the absolute value of z determines the
  4617. * size of the bubble. This means that with the default
  4618. * zThreshold of 0, a bubble of value -1 will have the same size
  4619. * as a bubble of value 1, while a bubble of value 0 will have a
  4620. * smaller size according to minSize.
  4621. */
  4622. sizeByAbsoluteValue: false,
  4623. /**
  4624. * Define the visual z index of the bubble legend.
  4625. */
  4626. zIndex: 1,
  4627. /**
  4628. * Ranges with with lower value than zThreshold, are skipped.
  4629. */
  4630. zThreshold: 0
  4631. }
  4632. }
  4633. });
  4634. /* eslint-disable no-invalid-this, valid-jsdoc */
  4635. /**
  4636. * BubbleLegend class.
  4637. *
  4638. * @private
  4639. * @class
  4640. * @name Highcharts.BubbleLegend
  4641. * @param {Highcharts.LegendBubbleLegendOptions} options
  4642. * Bubble legend options
  4643. * @param {Highcharts.Legend} legend
  4644. * Legend
  4645. */
  4646. var BubbleLegend = /** @class */ (function () {
  4647. function BubbleLegend(options, legend) {
  4648. this.chart = void 0;
  4649. this.fontMetrics = void 0;
  4650. this.legend = void 0;
  4651. this.legendGroup = void 0;
  4652. this.legendItem = void 0;
  4653. this.legendItemHeight = void 0;
  4654. this.legendItemWidth = void 0;
  4655. this.legendSymbol = void 0;
  4656. this.maxLabel = void 0;
  4657. this.movementX = void 0;
  4658. this.ranges = void 0;
  4659. this.visible = void 0;
  4660. this.symbols = void 0;
  4661. this.options = void 0;
  4662. this.setState = noop;
  4663. this.init(options, legend);
  4664. }
  4665. /**
  4666. * Create basic bubbleLegend properties similar to item in legend.
  4667. *
  4668. * @private
  4669. * @function Highcharts.BubbleLegend#init
  4670. * @param {Highcharts.LegendBubbleLegendOptions} options
  4671. * Bubble legend options
  4672. * @param {Highcharts.Legend} legend
  4673. * Legend
  4674. * @return {void}
  4675. */
  4676. BubbleLegend.prototype.init = function (options, legend) {
  4677. this.options = options;
  4678. this.visible = true;
  4679. this.chart = legend.chart;
  4680. this.legend = legend;
  4681. };
  4682. /**
  4683. * Depending on the position option, add bubbleLegend to legend items.
  4684. *
  4685. * @private
  4686. * @function Highcharts.BubbleLegend#addToLegend
  4687. * @param {Array<(Highcharts.Point|Highcharts.Series)>}
  4688. * All legend items
  4689. * @return {void}
  4690. */
  4691. BubbleLegend.prototype.addToLegend = function (items) {
  4692. // Insert bubbleLegend into legend items
  4693. items.splice(this.options.legendIndex, 0, this);
  4694. };
  4695. /**
  4696. * Calculate ranges, sizes and call the next steps of bubbleLegend
  4697. * creation.
  4698. *
  4699. * @private
  4700. * @function Highcharts.BubbleLegend#drawLegendSymbol
  4701. * @param {Highcharts.Legend} legend
  4702. * Legend instance
  4703. * @return {void}
  4704. */
  4705. BubbleLegend.prototype.drawLegendSymbol = function (legend) {
  4706. var chart = this.chart,
  4707. options = this.options,
  4708. size,
  4709. itemDistance = pick(legend.options.itemDistance, 20),
  4710. connectorSpace,
  4711. ranges = options.ranges,
  4712. radius,
  4713. maxLabel,
  4714. connectorDistance = options.connectorDistance;
  4715. // Predict label dimensions
  4716. this.fontMetrics = chart.renderer.fontMetrics(options.labels.style.fontSize.toString() + 'px');
  4717. // Do not create bubbleLegend now if ranges or ranges valeus are not
  4718. // specified or if are empty array.
  4719. if (!ranges || !ranges.length || !isNumber(ranges[0].value)) {
  4720. legend.options.bubbleLegend.autoRanges = true;
  4721. return;
  4722. }
  4723. // Sort ranges to right render order
  4724. stableSort(ranges, function (a, b) {
  4725. return b.value - a.value;
  4726. });
  4727. this.ranges = ranges;
  4728. this.setOptions();
  4729. this.render();
  4730. // Get max label size
  4731. maxLabel = this.getMaxLabelSize();
  4732. radius = this.ranges[0].radius;
  4733. size = radius * 2;
  4734. // Space for connectors and labels.
  4735. connectorSpace =
  4736. connectorDistance - radius + maxLabel.width;
  4737. connectorSpace = connectorSpace > 0 ? connectorSpace : 0;
  4738. this.maxLabel = maxLabel;
  4739. this.movementX = options.labels.align === 'left' ?
  4740. connectorSpace : 0;
  4741. this.legendItemWidth = size + connectorSpace + itemDistance;
  4742. this.legendItemHeight = size + this.fontMetrics.h / 2;
  4743. };
  4744. /**
  4745. * Set style options for each bubbleLegend range.
  4746. *
  4747. * @private
  4748. * @function Highcharts.BubbleLegend#setOptions
  4749. * @return {void}
  4750. */
  4751. BubbleLegend.prototype.setOptions = function () {
  4752. var ranges = this.ranges,
  4753. options = this.options,
  4754. series = this.chart.series[options.seriesIndex],
  4755. baseline = this.legend.baseline,
  4756. bubbleStyle = {
  4757. 'z-index': options.zIndex,
  4758. 'stroke-width': options.borderWidth
  4759. },
  4760. connectorStyle = {
  4761. 'z-index': options.zIndex,
  4762. 'stroke-width': options.connectorWidth
  4763. },
  4764. labelStyle = this.getLabelStyles(),
  4765. fillOpacity = series.options.marker.fillOpacity,
  4766. styledMode = this.chart.styledMode;
  4767. // Allow to parts of styles be used individually for range
  4768. ranges.forEach(function (range, i) {
  4769. if (!styledMode) {
  4770. bubbleStyle.stroke = pick(range.borderColor, options.borderColor, series.color);
  4771. bubbleStyle.fill = pick(range.color, options.color, fillOpacity !== 1 ?
  4772. color(series.color).setOpacity(fillOpacity)
  4773. .get('rgba') :
  4774. series.color);
  4775. connectorStyle.stroke = pick(range.connectorColor, options.connectorColor, series.color);
  4776. }
  4777. // Set options needed for rendering each range
  4778. ranges[i].radius = this.getRangeRadius(range.value);
  4779. ranges[i] = merge(ranges[i], {
  4780. center: (ranges[0].radius - ranges[i].radius +
  4781. baseline)
  4782. });
  4783. if (!styledMode) {
  4784. merge(true, ranges[i], {
  4785. bubbleStyle: merge(false, bubbleStyle),
  4786. connectorStyle: merge(false, connectorStyle),
  4787. labelStyle: labelStyle
  4788. });
  4789. }
  4790. }, this);
  4791. };
  4792. /**
  4793. * Merge options for bubbleLegend labels.
  4794. *
  4795. * @private
  4796. * @function Highcharts.BubbleLegend#getLabelStyles
  4797. * @return {Highcharts.CSSObject}
  4798. */
  4799. BubbleLegend.prototype.getLabelStyles = function () {
  4800. var options = this.options,
  4801. additionalLabelsStyle = {},
  4802. labelsOnLeft = options.labels.align === 'left',
  4803. rtl = this.legend.options.rtl;
  4804. // To separate additional style options
  4805. objectEach(options.labels.style, function (value, key) {
  4806. if (key !== 'color' &&
  4807. key !== 'fontSize' &&
  4808. key !== 'z-index') {
  4809. additionalLabelsStyle[key] = value;
  4810. }
  4811. });
  4812. return merge(false, additionalLabelsStyle, {
  4813. 'font-size': options.labels.style.fontSize,
  4814. fill: pick(options.labels.style.color, palette.neutralColor100),
  4815. 'z-index': options.zIndex,
  4816. align: rtl || labelsOnLeft ? 'right' : 'left'
  4817. });
  4818. };
  4819. /**
  4820. * Calculate radius for each bubble range,
  4821. * used code from BubbleSeries.js 'getRadius' method.
  4822. *
  4823. * @private
  4824. * @function Highcharts.BubbleLegend#getRangeRadius
  4825. * @param {number} value
  4826. * Range value
  4827. * @return {number|null}
  4828. * Radius for one range
  4829. */
  4830. BubbleLegend.prototype.getRangeRadius = function (value) {
  4831. var options = this.options,
  4832. seriesIndex = this.options.seriesIndex,
  4833. bubbleSeries = this.chart.series[seriesIndex],
  4834. zMax = options.ranges[0].value,
  4835. zMin = options.ranges[options.ranges.length - 1].value,
  4836. minSize = options.minSize,
  4837. maxSize = options.maxSize;
  4838. return bubbleSeries.getRadius.call(this, zMin, zMax, minSize, maxSize, value);
  4839. };
  4840. /**
  4841. * Render the legendSymbol group.
  4842. *
  4843. * @private
  4844. * @function Highcharts.BubbleLegend#render
  4845. * @return {void}
  4846. */
  4847. BubbleLegend.prototype.render = function () {
  4848. var renderer = this.chart.renderer,
  4849. zThreshold = this.options.zThreshold;
  4850. if (!this.symbols) {
  4851. this.symbols = {
  4852. connectors: [],
  4853. bubbleItems: [],
  4854. labels: []
  4855. };
  4856. }
  4857. // Nesting SVG groups to enable handleOverflow
  4858. this.legendSymbol = renderer.g('bubble-legend');
  4859. this.legendItem = renderer.g('bubble-legend-item');
  4860. // To enable default 'hideOverlappingLabels' method
  4861. this.legendSymbol.translateX = 0;
  4862. this.legendSymbol.translateY = 0;
  4863. this.ranges.forEach(function (range) {
  4864. if (range.value >= zThreshold) {
  4865. this.renderRange(range);
  4866. }
  4867. }, this);
  4868. // To use handleOverflow method
  4869. this.legendSymbol.add(this.legendItem);
  4870. this.legendItem.add(this.legendGroup);
  4871. this.hideOverlappingLabels();
  4872. };
  4873. /**
  4874. * Render one range, consisting of bubble symbol, connector and label.
  4875. *
  4876. * @private
  4877. * @function Highcharts.BubbleLegend#renderRange
  4878. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  4879. * Range options
  4880. * @return {void}
  4881. */
  4882. BubbleLegend.prototype.renderRange = function (range) {
  4883. var mainRange = this.ranges[0],
  4884. legend = this.legend,
  4885. options = this.options,
  4886. labelsOptions = options.labels,
  4887. chart = this.chart,
  4888. renderer = chart.renderer,
  4889. symbols = this.symbols,
  4890. labels = symbols.labels,
  4891. label,
  4892. elementCenter = range.center,
  4893. absoluteRadius = Math.abs(range.radius),
  4894. connectorDistance = options.connectorDistance || 0,
  4895. labelsAlign = labelsOptions.align,
  4896. rtl = legend.options.rtl,
  4897. fontSize = labelsOptions.style.fontSize,
  4898. connectorLength = rtl || labelsAlign === 'left' ?
  4899. -connectorDistance : connectorDistance,
  4900. borderWidth = options.borderWidth,
  4901. connectorWidth = options.connectorWidth,
  4902. posX = mainRange.radius || 0,
  4903. posY = elementCenter - absoluteRadius -
  4904. borderWidth / 2 + connectorWidth / 2,
  4905. labelY,
  4906. labelX,
  4907. fontMetrics = this.fontMetrics,
  4908. labelMovement = fontSize / 2 - (fontMetrics.h - fontSize) / 2,
  4909. crispMovement = (posY % 1 ? 1 : 0.5) -
  4910. (connectorWidth % 2 ? 0 : 0.5),
  4911. styledMode = renderer.styledMode;
  4912. // Set options for centered labels
  4913. if (labelsAlign === 'center') {
  4914. connectorLength = 0; // do not use connector
  4915. options.connectorDistance = 0;
  4916. range.labelStyle.align = 'center';
  4917. }
  4918. labelY = posY + options.labels.y;
  4919. labelX = posX + connectorLength + options.labels.x;
  4920. // Render bubble symbol
  4921. symbols.bubbleItems.push(renderer
  4922. .circle(posX, elementCenter + crispMovement, absoluteRadius)
  4923. .attr(styledMode ? {} : range.bubbleStyle)
  4924. .addClass((styledMode ?
  4925. 'highcharts-color-' +
  4926. this.options.seriesIndex + ' ' :
  4927. '') +
  4928. 'highcharts-bubble-legend-symbol ' +
  4929. (options.className || '')).add(this.legendSymbol));
  4930. // Render connector
  4931. symbols.connectors.push(renderer
  4932. .path(renderer.crispLine([
  4933. ['M', posX, posY],
  4934. ['L', posX + connectorLength, posY]
  4935. ], options.connectorWidth))
  4936. .attr(styledMode ? {} : range.connectorStyle)
  4937. .addClass((styledMode ?
  4938. 'highcharts-color-' +
  4939. this.options.seriesIndex + ' ' : '') +
  4940. 'highcharts-bubble-legend-connectors ' +
  4941. (options.connectorClassName || '')).add(this.legendSymbol));
  4942. // Render label
  4943. label = renderer
  4944. .text(this.formatLabel(range), labelX, labelY + labelMovement)
  4945. .attr(styledMode ? {} : range.labelStyle)
  4946. .addClass('highcharts-bubble-legend-labels ' +
  4947. (options.labels.className || '')).add(this.legendSymbol);
  4948. labels.push(label);
  4949. // To enable default 'hideOverlappingLabels' method
  4950. label.placed = true;
  4951. label.alignAttr = {
  4952. x: labelX,
  4953. y: labelY + labelMovement
  4954. };
  4955. };
  4956. /**
  4957. * Get the label which takes up the most space.
  4958. *
  4959. * @private
  4960. * @function Highcharts.BubbleLegend#getMaxLabelSize
  4961. * @return {Highcharts.BBoxObject}
  4962. */
  4963. BubbleLegend.prototype.getMaxLabelSize = function () {
  4964. var labels = this.symbols.labels,
  4965. maxLabel,
  4966. labelSize;
  4967. labels.forEach(function (label) {
  4968. labelSize = label.getBBox(true);
  4969. if (maxLabel) {
  4970. maxLabel = labelSize.width > maxLabel.width ?
  4971. labelSize : maxLabel;
  4972. }
  4973. else {
  4974. maxLabel = labelSize;
  4975. }
  4976. });
  4977. return maxLabel || {};
  4978. };
  4979. /**
  4980. * Get formatted label for range.
  4981. *
  4982. * @private
  4983. * @function Highcharts.BubbleLegend#formatLabel
  4984. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  4985. * Range options
  4986. * @return {string}
  4987. * Range label text
  4988. */
  4989. BubbleLegend.prototype.formatLabel = function (range) {
  4990. var options = this.options,
  4991. formatter = options.labels.formatter,
  4992. format = options.labels.format;
  4993. var numberFormatter = this.chart.numberFormatter;
  4994. return format ? U.format(format, range) :
  4995. formatter ? formatter.call(range) :
  4996. numberFormatter(range.value, 1);
  4997. };
  4998. /**
  4999. * By using default chart 'hideOverlappingLabels' method, hide or show
  5000. * labels and connectors.
  5001. *
  5002. * @private
  5003. * @function Highcharts.BubbleLegend#hideOverlappingLabels
  5004. * @return {void}
  5005. */
  5006. BubbleLegend.prototype.hideOverlappingLabels = function () {
  5007. var chart = this.chart,
  5008. allowOverlap = this.options.labels.allowOverlap,
  5009. symbols = this.symbols;
  5010. if (!allowOverlap && symbols) {
  5011. chart.hideOverlappingLabels(symbols.labels);
  5012. // Hide or show connectors
  5013. symbols.labels.forEach(function (label, index) {
  5014. if (!label.newOpacity) {
  5015. symbols.connectors[index].hide();
  5016. }
  5017. else if (label.newOpacity !== label.oldOpacity) {
  5018. symbols.connectors[index].show();
  5019. }
  5020. });
  5021. }
  5022. };
  5023. /**
  5024. * Calculate ranges from created series.
  5025. *
  5026. * @private
  5027. * @function Highcharts.BubbleLegend#getRanges
  5028. * @return {Array<Highcharts.LegendBubbleLegendRangesOptions>}
  5029. * Array of range objects
  5030. */
  5031. BubbleLegend.prototype.getRanges = function () {
  5032. var bubbleLegend = this.legend.bubbleLegend,
  5033. series = bubbleLegend.chart.series,
  5034. ranges,
  5035. rangesOptions = bubbleLegend.options.ranges,
  5036. zData,
  5037. minZ = Number.MAX_VALUE,
  5038. maxZ = -Number.MAX_VALUE;
  5039. series.forEach(function (s) {
  5040. // Find the min and max Z, like in bubble series
  5041. if (s.isBubble && !s.ignoreSeries) {
  5042. zData = s.zData.filter(isNumber);
  5043. if (zData.length) {
  5044. minZ = pick(s.options.zMin, Math.min(minZ, Math.max(arrayMin(zData), s.options.displayNegative === false ?
  5045. s.options.zThreshold :
  5046. -Number.MAX_VALUE)));
  5047. maxZ = pick(s.options.zMax, Math.max(maxZ, arrayMax(zData)));
  5048. }
  5049. }
  5050. });
  5051. // Set values for ranges
  5052. if (minZ === maxZ) {
  5053. // Only one range if min and max values are the same.
  5054. ranges = [{ value: maxZ }];
  5055. }
  5056. else {
  5057. ranges = [
  5058. { value: minZ },
  5059. { value: (minZ + maxZ) / 2 },
  5060. { value: maxZ, autoRanges: true }
  5061. ];
  5062. }
  5063. // Prevent reverse order of ranges after redraw
  5064. if (rangesOptions.length && rangesOptions[0].radius) {
  5065. ranges.reverse();
  5066. }
  5067. // Merge ranges values with user options
  5068. ranges.forEach(function (range, i) {
  5069. if (rangesOptions && rangesOptions[i]) {
  5070. ranges[i] = merge(false, rangesOptions[i], range);
  5071. }
  5072. });
  5073. return ranges;
  5074. };
  5075. /**
  5076. * Calculate bubble legend sizes from rendered series.
  5077. *
  5078. * @private
  5079. * @function Highcharts.BubbleLegend#predictBubbleSizes
  5080. * @return {Array<number,number>}
  5081. * Calculated min and max bubble sizes
  5082. */
  5083. BubbleLegend.prototype.predictBubbleSizes = function () {
  5084. var chart = this.chart,
  5085. fontMetrics = this.fontMetrics,
  5086. legendOptions = chart.legend.options,
  5087. floating = legendOptions.floating,
  5088. horizontal = legendOptions.layout === 'horizontal',
  5089. lastLineHeight = horizontal ? chart.legend.lastLineHeight : 0,
  5090. plotSizeX = chart.plotSizeX,
  5091. plotSizeY = chart.plotSizeY,
  5092. bubbleSeries = chart.series[this.options.seriesIndex],
  5093. minSize = Math.ceil(bubbleSeries.minPxSize),
  5094. maxPxSize = Math.ceil(bubbleSeries.maxPxSize),
  5095. maxSize = bubbleSeries.options.maxSize,
  5096. plotSize = Math.min(plotSizeY,
  5097. plotSizeX),
  5098. calculatedSize;
  5099. // Calculate prediceted max size of bubble
  5100. if (floating || !(/%$/.test(maxSize))) {
  5101. calculatedSize = maxPxSize;
  5102. }
  5103. else {
  5104. maxSize = parseFloat(maxSize);
  5105. calculatedSize = ((plotSize + lastLineHeight -
  5106. fontMetrics.h / 2) * maxSize / 100) / (maxSize / 100 + 1);
  5107. // Get maxPxSize from bubble series if calculated bubble legend
  5108. // size will not affect to bubbles series.
  5109. if ((horizontal && plotSizeY - calculatedSize >=
  5110. plotSizeX) || (!horizontal && plotSizeX -
  5111. calculatedSize >= plotSizeY)) {
  5112. calculatedSize = maxPxSize;
  5113. }
  5114. }
  5115. return [minSize, Math.ceil(calculatedSize)];
  5116. };
  5117. /**
  5118. * Correct ranges with calculated sizes.
  5119. *
  5120. * @private
  5121. * @function Highcharts.BubbleLegend#updateRanges
  5122. * @param {number} min
  5123. * @param {number} max
  5124. * @return {void}
  5125. */
  5126. BubbleLegend.prototype.updateRanges = function (min, max) {
  5127. var bubbleLegendOptions = this.legend.options.bubbleLegend;
  5128. bubbleLegendOptions.minSize = min;
  5129. bubbleLegendOptions.maxSize = max;
  5130. bubbleLegendOptions.ranges = this.getRanges();
  5131. };
  5132. /**
  5133. * Because of the possibility of creating another legend line, predicted
  5134. * bubble legend sizes may differ by a few pixels, so it is necessary to
  5135. * correct them.
  5136. *
  5137. * @private
  5138. * @function Highcharts.BubbleLegend#correctSizes
  5139. * @return {void}
  5140. */
  5141. BubbleLegend.prototype.correctSizes = function () {
  5142. var legend = this.legend,
  5143. chart = this.chart,
  5144. bubbleSeries = chart.series[this.options.seriesIndex],
  5145. bubbleSeriesSize = bubbleSeries.maxPxSize,
  5146. bubbleLegendSize = this.options.maxSize;
  5147. if (Math.abs(Math.ceil(bubbleSeriesSize) - bubbleLegendSize) >
  5148. 1) {
  5149. this.updateRanges(this.options.minSize, bubbleSeries.maxPxSize);
  5150. legend.render();
  5151. }
  5152. };
  5153. return BubbleLegend;
  5154. }());
  5155. // Start the bubble legend creation process.
  5156. addEvent(Legend, 'afterGetAllItems', function (e) {
  5157. var legend = this,
  5158. bubbleLegend = legend.bubbleLegend,
  5159. legendOptions = legend.options,
  5160. options = legendOptions.bubbleLegend,
  5161. bubbleSeriesIndex = legend.chart.getVisibleBubbleSeriesIndex();
  5162. // Remove unnecessary element
  5163. if (bubbleLegend && bubbleLegend.ranges && bubbleLegend.ranges.length) {
  5164. // Allow change the way of calculating ranges in update
  5165. if (options.ranges.length) {
  5166. options.autoRanges =
  5167. !!options.ranges[0].autoRanges;
  5168. }
  5169. // Update bubbleLegend dimensions in each redraw
  5170. legend.destroyItem(bubbleLegend);
  5171. }
  5172. // Create bubble legend
  5173. if (bubbleSeriesIndex >= 0 &&
  5174. legendOptions.enabled &&
  5175. options.enabled) {
  5176. options.seriesIndex = bubbleSeriesIndex;
  5177. legend.bubbleLegend = new H.BubbleLegend(options, legend);
  5178. legend.bubbleLegend.addToLegend(e.allItems);
  5179. }
  5180. });
  5181. /**
  5182. * Check if there is at least one visible bubble series.
  5183. *
  5184. * @private
  5185. * @function Highcharts.Chart#getVisibleBubbleSeriesIndex
  5186. * @return {number}
  5187. * First visible bubble series index
  5188. */
  5189. Chart.prototype.getVisibleBubbleSeriesIndex = function () {
  5190. var series = this.series,
  5191. i = 0;
  5192. while (i < series.length) {
  5193. if (series[i] &&
  5194. series[i].isBubble &&
  5195. series[i].visible &&
  5196. series[i].zData.length) {
  5197. return i;
  5198. }
  5199. i++;
  5200. }
  5201. return -1;
  5202. };
  5203. /**
  5204. * Calculate height for each row in legend.
  5205. *
  5206. * @private
  5207. * @function Highcharts.Legend#getLinesHeights
  5208. * @return {Array<Highcharts.Dictionary<number>>}
  5209. * Informations about line height and items amount
  5210. */
  5211. Legend.prototype.getLinesHeights = function () {
  5212. var items = this.allItems,
  5213. lines = [],
  5214. lastLine,
  5215. length = items.length,
  5216. i = 0,
  5217. j = 0;
  5218. for (i = 0; i < length; i++) {
  5219. if (items[i].legendItemHeight) {
  5220. // for bubbleLegend
  5221. items[i].itemHeight = items[i].legendItemHeight;
  5222. }
  5223. if ( // Line break
  5224. items[i] === items[length - 1] ||
  5225. items[i + 1] &&
  5226. items[i]._legendItemPos[1] !==
  5227. items[i + 1]._legendItemPos[1]) {
  5228. lines.push({ height: 0 });
  5229. lastLine = lines[lines.length - 1];
  5230. // Find the highest item in line
  5231. for (j; j <= i; j++) {
  5232. if (items[j].itemHeight > lastLine.height) {
  5233. lastLine.height = items[j].itemHeight;
  5234. }
  5235. }
  5236. lastLine.step = i;
  5237. }
  5238. }
  5239. return lines;
  5240. };
  5241. /**
  5242. * Correct legend items translation in case of different elements heights.
  5243. *
  5244. * @private
  5245. * @function Highcharts.Legend#retranslateItems
  5246. * @param {Array<Highcharts.Dictionary<number>>} lines
  5247. * Informations about line height and items amount
  5248. * @return {void}
  5249. */
  5250. Legend.prototype.retranslateItems = function (lines) {
  5251. var items = this.allItems,
  5252. orgTranslateX,
  5253. orgTranslateY,
  5254. movementX,
  5255. rtl = this.options.rtl,
  5256. actualLine = 0;
  5257. items.forEach(function (item, index) {
  5258. orgTranslateX = item.legendGroup.translateX;
  5259. orgTranslateY = item._legendItemPos[1];
  5260. movementX = item.movementX;
  5261. if (movementX || (rtl && item.ranges)) {
  5262. movementX = rtl ?
  5263. orgTranslateX - item.options.maxSize / 2 :
  5264. orgTranslateX + movementX;
  5265. item.legendGroup.attr({ translateX: movementX });
  5266. }
  5267. if (index > lines[actualLine].step) {
  5268. actualLine++;
  5269. }
  5270. item.legendGroup.attr({
  5271. translateY: Math.round(orgTranslateY + lines[actualLine].height / 2)
  5272. });
  5273. item._legendItemPos[1] = orgTranslateY +
  5274. lines[actualLine].height / 2;
  5275. });
  5276. };
  5277. // Toggle bubble legend depending on the visible status of bubble series.
  5278. addEvent(Series, 'legendItemClick', function () {
  5279. var series = this,
  5280. chart = series.chart,
  5281. visible = series.visible,
  5282. legend = series.chart.legend,
  5283. status;
  5284. if (legend && legend.bubbleLegend) {
  5285. // Temporary correct 'visible' property
  5286. series.visible = !visible;
  5287. // Save future status for getRanges method
  5288. series.ignoreSeries = visible;
  5289. // Check if at lest one bubble series is visible
  5290. status = chart.getVisibleBubbleSeriesIndex() >= 0;
  5291. // Hide bubble legend if all bubble series are disabled
  5292. if (legend.bubbleLegend.visible !== status) {
  5293. // Show or hide bubble legend
  5294. legend.update({
  5295. bubbleLegend: { enabled: status }
  5296. });
  5297. legend.bubbleLegend.visible = status; // Restore default status
  5298. }
  5299. series.visible = visible;
  5300. }
  5301. });
  5302. // If ranges are not specified, determine ranges from rendered bubble series
  5303. // and render legend again.
  5304. wrap(Chart.prototype, 'drawChartBox', function (proceed, options, callback) {
  5305. var chart = this,
  5306. legend = chart.legend,
  5307. bubbleSeries = chart.getVisibleBubbleSeriesIndex() >= 0,
  5308. bubbleLegendOptions,
  5309. bubbleSizes;
  5310. if (legend && legend.options.enabled && legend.bubbleLegend &&
  5311. legend.options.bubbleLegend.autoRanges && bubbleSeries) {
  5312. bubbleLegendOptions = legend.bubbleLegend.options;
  5313. bubbleSizes = legend.bubbleLegend.predictBubbleSizes();
  5314. legend.bubbleLegend.updateRanges(bubbleSizes[0], bubbleSizes[1]);
  5315. // Disable animation on init
  5316. if (!bubbleLegendOptions.placed) {
  5317. legend.group.placed = false;
  5318. legend.allItems.forEach(function (item) {
  5319. item.legendGroup.translateY = null;
  5320. });
  5321. }
  5322. // Create legend with bubbleLegend
  5323. legend.render();
  5324. chart.getMargins();
  5325. chart.axes.forEach(function (axis) {
  5326. if (axis.visible) { // #11448
  5327. axis.render();
  5328. }
  5329. if (!bubbleLegendOptions.placed) {
  5330. axis.setScale();
  5331. axis.updateNames();
  5332. // Disable axis animation on init
  5333. objectEach(axis.ticks, function (tick) {
  5334. tick.isNew = true;
  5335. tick.isNewLabel = true;
  5336. });
  5337. }
  5338. });
  5339. bubbleLegendOptions.placed = true;
  5340. // After recalculate axes, calculate margins again.
  5341. chart.getMargins();
  5342. // Call default 'drawChartBox' method.
  5343. proceed.call(chart, options, callback);
  5344. // Check bubble legend sizes and correct them if necessary.
  5345. legend.bubbleLegend.correctSizes();
  5346. // Correct items positions with different dimensions in legend.
  5347. legend.retranslateItems(legend.getLinesHeights());
  5348. }
  5349. else {
  5350. proceed.call(chart, options, callback);
  5351. // Allow color change on static bubble legend after click on legend
  5352. if (legend && legend.options.enabled && legend.bubbleLegend) {
  5353. legend.render();
  5354. legend.retranslateItems(legend.getLinesHeights());
  5355. }
  5356. }
  5357. });
  5358. H.BubbleLegend = BubbleLegend;
  5359. return H.BubbleLegend;
  5360. });
  5361. _registerModule(_modules, 'Series/Bubble/BubbleSeries.js', [_modules['Core/Axis/Axis.js'], _modules['Series/Bubble/BubblePoint.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Axis, BubblePoint, Color, H, Series, SeriesRegistry, U) {
  5362. /* *
  5363. *
  5364. * (c) 2010-2021 Torstein Honsi
  5365. *
  5366. * License: www.highcharts.com/license
  5367. *
  5368. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5369. *
  5370. * */
  5371. var __extends = (this && this.__extends) || (function () {
  5372. var extendStatics = function (d,
  5373. b) {
  5374. extendStatics = Object.setPrototypeOf ||
  5375. ({ __proto__: [] } instanceof Array && function (d,
  5376. b) { d.__proto__ = b; }) ||
  5377. function (d,
  5378. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5379. return extendStatics(d, b);
  5380. };
  5381. return function (d, b) {
  5382. extendStatics(d, b);
  5383. function __() { this.constructor = d; }
  5384. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5385. };
  5386. })();
  5387. var color = Color.parse;
  5388. var noop = H.noop;
  5389. var _a = SeriesRegistry.seriesTypes,
  5390. ColumnSeries = _a.column,
  5391. ScatterSeries = _a.scatter;
  5392. var arrayMax = U.arrayMax,
  5393. arrayMin = U.arrayMin,
  5394. clamp = U.clamp,
  5395. extend = U.extend,
  5396. isNumber = U.isNumber,
  5397. merge = U.merge,
  5398. pick = U.pick,
  5399. pInt = U.pInt;
  5400. /* *
  5401. *
  5402. * Class
  5403. *
  5404. * */
  5405. var BubbleSeries = /** @class */ (function (_super) {
  5406. __extends(BubbleSeries, _super);
  5407. function BubbleSeries() {
  5408. /* *
  5409. *
  5410. * Static Properties
  5411. *
  5412. * */
  5413. var _this = _super !== null && _super.apply(this,
  5414. arguments) || this;
  5415. /* *
  5416. *
  5417. * Properties
  5418. *
  5419. * */
  5420. _this.data = void 0;
  5421. _this.maxPxSize = void 0;
  5422. _this.minPxSize = void 0;
  5423. _this.options = void 0;
  5424. _this.points = void 0;
  5425. _this.radii = void 0;
  5426. _this.yData = void 0;
  5427. _this.zData = void 0;
  5428. return _this;
  5429. /* eslint-enable valid-jsdoc */
  5430. }
  5431. /* *
  5432. *
  5433. * Functions
  5434. *
  5435. * */
  5436. /* eslint-disable valid-jsdoc */
  5437. /**
  5438. * Perform animation on the bubbles
  5439. * @private
  5440. */
  5441. BubbleSeries.prototype.animate = function (init) {
  5442. if (!init &&
  5443. this.points.length < this.options.animationLimit // #8099
  5444. ) {
  5445. this.points.forEach(function (point) {
  5446. var graphic = point.graphic;
  5447. if (graphic && graphic.width) { // URL symbols don't have width
  5448. // Start values
  5449. if (!this.hasRendered) {
  5450. graphic.attr({
  5451. x: point.plotX,
  5452. y: point.plotY,
  5453. width: 1,
  5454. height: 1
  5455. });
  5456. }
  5457. // Run animation
  5458. graphic.animate(this.markerAttribs(point), this.options.animation);
  5459. }
  5460. }, this);
  5461. }
  5462. };
  5463. /**
  5464. * Get the radius for each point based on the minSize, maxSize and each
  5465. * point's Z value. This must be done prior to Series.translate because
  5466. * the axis needs to add padding in accordance with the point sizes.
  5467. * @private
  5468. */
  5469. BubbleSeries.prototype.getRadii = function (zMin, zMax, series) {
  5470. var len,
  5471. i,
  5472. zData = this.zData,
  5473. yData = this.yData,
  5474. minSize = series.minPxSize,
  5475. maxSize = series.maxPxSize,
  5476. radii = [],
  5477. value;
  5478. // Set the shape type and arguments to be picked up in drawPoints
  5479. for (i = 0, len = zData.length; i < len; i++) {
  5480. value = zData[i];
  5481. // Separate method to get individual radius for bubbleLegend
  5482. radii.push(this.getRadius(zMin, zMax, minSize, maxSize, value, yData[i]));
  5483. }
  5484. this.radii = radii;
  5485. };
  5486. /**
  5487. * Get the individual radius for one point.
  5488. * @private
  5489. */
  5490. BubbleSeries.prototype.getRadius = function (zMin, zMax, minSize, maxSize, value, yValue) {
  5491. var options = this.options,
  5492. sizeByArea = options.sizeBy !== 'width',
  5493. zThreshold = options.zThreshold,
  5494. zRange = zMax - zMin,
  5495. pos = 0.5;
  5496. // #8608 - bubble should be visible when z is undefined
  5497. if (yValue === null || value === null) {
  5498. return null;
  5499. }
  5500. if (isNumber(value)) {
  5501. // When sizing by threshold, the absolute value of z determines
  5502. // the size of the bubble.
  5503. if (options.sizeByAbsoluteValue) {
  5504. value = Math.abs(value - zThreshold);
  5505. zMax = zRange = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
  5506. zMin = 0;
  5507. }
  5508. // Issue #4419 - if value is less than zMin, push a radius that's
  5509. // always smaller than the minimum size
  5510. if (value < zMin) {
  5511. return minSize / 2 - 1;
  5512. }
  5513. // Relative size, a number between 0 and 1
  5514. if (zRange > 0) {
  5515. pos = (value - zMin) / zRange;
  5516. }
  5517. }
  5518. if (sizeByArea && pos >= 0) {
  5519. pos = Math.sqrt(pos);
  5520. }
  5521. return Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
  5522. };
  5523. /**
  5524. * Define hasData function for non-cartesian series.
  5525. * Returns true if the series has points at all.
  5526. * @private
  5527. */
  5528. BubbleSeries.prototype.hasData = function () {
  5529. return !!this.processedXData.length; // != 0
  5530. };
  5531. /**
  5532. * @private
  5533. */
  5534. BubbleSeries.prototype.pointAttribs = function (point, state) {
  5535. var markerOptions = this.options.marker,
  5536. fillOpacity = markerOptions.fillOpacity,
  5537. attr = Series.prototype.pointAttribs.call(this,
  5538. point,
  5539. state);
  5540. if (fillOpacity !== 1) {
  5541. attr.fill = color(attr.fill)
  5542. .setOpacity(fillOpacity)
  5543. .get('rgba');
  5544. }
  5545. return attr;
  5546. };
  5547. /**
  5548. * Extend the base translate method to handle bubble size
  5549. * @private
  5550. */
  5551. BubbleSeries.prototype.translate = function () {
  5552. var i,
  5553. data = this.data,
  5554. point,
  5555. radius,
  5556. radii = this.radii;
  5557. // Run the parent method
  5558. _super.prototype.translate.call(this);
  5559. // Set the shape type and arguments to be picked up in drawPoints
  5560. i = data.length;
  5561. while (i--) {
  5562. point = data[i];
  5563. radius = radii ? radii[i] : 0; // #1737
  5564. if (isNumber(radius) && radius >= this.minPxSize / 2) {
  5565. // Shape arguments
  5566. point.marker = extend(point.marker, {
  5567. radius: radius,
  5568. width: 2 * radius,
  5569. height: 2 * radius
  5570. });
  5571. // Alignment box for the data label
  5572. point.dlBox = {
  5573. x: point.plotX - radius,
  5574. y: point.plotY - radius,
  5575. width: 2 * radius,
  5576. height: 2 * radius
  5577. };
  5578. }
  5579. else { // below zThreshold
  5580. // #1691
  5581. point.shapeArgs = point.plotY = point.dlBox = void 0;
  5582. }
  5583. }
  5584. };
  5585. /**
  5586. * A bubble series is a three dimensional series type where each point
  5587. * renders an X, Y and Z value. Each points is drawn as a bubble where the
  5588. * position along the X and Y axes mark the X and Y values, and the size of
  5589. * the bubble relates to the Z value.
  5590. *
  5591. * @sample {highcharts} highcharts/demo/bubble/
  5592. * Bubble chart
  5593. *
  5594. * @extends plotOptions.scatter
  5595. * @excluding cluster
  5596. * @product highcharts highstock
  5597. * @requires highcharts-more
  5598. * @optionparent plotOptions.bubble
  5599. */
  5600. BubbleSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  5601. dataLabels: {
  5602. formatter: function () {
  5603. return this.point.z;
  5604. },
  5605. inside: true,
  5606. verticalAlign: 'middle'
  5607. },
  5608. /**
  5609. * If there are more points in the series than the `animationLimit`, the
  5610. * animation won't run. Animation affects overall performance and
  5611. * doesn't work well with heavy data series.
  5612. *
  5613. * @since 6.1.0
  5614. */
  5615. animationLimit: 250,
  5616. /**
  5617. * Whether to display negative sized bubbles. The threshold is given
  5618. * by the [zThreshold](#plotOptions.bubble.zThreshold) option, and negative
  5619. * bubbles can be visualized by setting
  5620. * [negativeColor](#plotOptions.bubble.negativeColor).
  5621. *
  5622. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  5623. * Negative bubbles
  5624. *
  5625. * @type {boolean}
  5626. * @default true
  5627. * @since 3.0
  5628. * @apioption plotOptions.bubble.displayNegative
  5629. */
  5630. /**
  5631. * @extends plotOptions.series.marker
  5632. * @excluding enabled, enabledThreshold, height, radius, width
  5633. */
  5634. marker: {
  5635. lineColor: null,
  5636. lineWidth: 1,
  5637. /**
  5638. * The fill opacity of the bubble markers.
  5639. */
  5640. fillOpacity: 0.5,
  5641. /**
  5642. * In bubble charts, the radius is overridden and determined based
  5643. * on the point's data value.
  5644. *
  5645. * @ignore-option
  5646. */
  5647. radius: null,
  5648. states: {
  5649. hover: {
  5650. radiusPlus: 0
  5651. }
  5652. },
  5653. /**
  5654. * A predefined shape or symbol for the marker. Possible values are
  5655. * "circle", "square", "diamond", "triangle" and "triangle-down".
  5656. *
  5657. * Additionally, the URL to a graphic can be given on the form
  5658. * `url(graphic.png)`. Note that for the image to be applied to
  5659. * exported charts, its URL needs to be accessible by the export
  5660. * server.
  5661. *
  5662. * Custom callbacks for symbol path generation can also be added to
  5663. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  5664. * used by its method name, as shown in the demo.
  5665. *
  5666. * @sample {highcharts} highcharts/plotoptions/bubble-symbol/
  5667. * Bubble chart with various symbols
  5668. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  5669. * General chart with predefined, graphic and custom markers
  5670. *
  5671. * @type {Highcharts.SymbolKeyValue|string}
  5672. * @since 5.0.11
  5673. */
  5674. symbol: 'circle'
  5675. },
  5676. /**
  5677. * Minimum bubble size. Bubbles will automatically size between the
  5678. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  5679. * Can be either pixels (when no unit is given), or a percentage of
  5680. * the smallest one of the plot width and height.
  5681. *
  5682. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  5683. * Bubble size
  5684. *
  5685. * @type {number|string}
  5686. * @since 3.0
  5687. * @product highcharts highstock
  5688. */
  5689. minSize: 8,
  5690. /**
  5691. * Maximum bubble size. Bubbles will automatically size between the
  5692. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  5693. * Can be either pixels (when no unit is given), or a percentage of
  5694. * the smallest one of the plot width and height.
  5695. *
  5696. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  5697. * Bubble size
  5698. *
  5699. * @type {number|string}
  5700. * @since 3.0
  5701. * @product highcharts highstock
  5702. */
  5703. maxSize: '20%',
  5704. /**
  5705. * When a point's Z value is below the
  5706. * [zThreshold](#plotOptions.bubble.zThreshold)
  5707. * setting, this color is used.
  5708. *
  5709. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  5710. * Negative bubbles
  5711. *
  5712. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5713. * @since 3.0
  5714. * @product highcharts
  5715. * @apioption plotOptions.bubble.negativeColor
  5716. */
  5717. /**
  5718. * Whether the bubble's value should be represented by the area or the
  5719. * width of the bubble. The default, `area`, corresponds best to the
  5720. * human perception of the size of each bubble.
  5721. *
  5722. * @sample {highcharts} highcharts/plotoptions/bubble-sizeby/
  5723. * Comparison of area and size
  5724. *
  5725. * @type {Highcharts.BubbleSizeByValue}
  5726. * @default area
  5727. * @since 3.0.7
  5728. * @apioption plotOptions.bubble.sizeBy
  5729. */
  5730. /**
  5731. * When this is true, the absolute value of z determines the size of
  5732. * the bubble. This means that with the default `zThreshold` of 0, a
  5733. * bubble of value -1 will have the same size as a bubble of value 1,
  5734. * while a bubble of value 0 will have a smaller size according to
  5735. * `minSize`.
  5736. *
  5737. * @sample {highcharts} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  5738. * Size by absolute value, various thresholds
  5739. *
  5740. * @type {boolean}
  5741. * @default false
  5742. * @since 4.1.9
  5743. * @product highcharts
  5744. * @apioption plotOptions.bubble.sizeByAbsoluteValue
  5745. */
  5746. /**
  5747. * When this is true, the series will not cause the Y axis to cross
  5748. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  5749. * unless the data actually crosses the plane.
  5750. *
  5751. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  5752. * 3 will make the Y axis show negative values according to the
  5753. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  5754. * at 0.
  5755. *
  5756. * @since 4.1.9
  5757. * @product highcharts
  5758. */
  5759. softThreshold: false,
  5760. states: {
  5761. hover: {
  5762. halo: {
  5763. size: 5
  5764. }
  5765. }
  5766. },
  5767. tooltip: {
  5768. pointFormat: '({point.x}, {point.y}), Size: {point.z}'
  5769. },
  5770. turboThreshold: 0,
  5771. /**
  5772. * The minimum for the Z value range. Defaults to the highest Z value
  5773. * in the data.
  5774. *
  5775. * @see [zMin](#plotOptions.bubble.zMin)
  5776. *
  5777. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  5778. * Z has a possible range of 0-100
  5779. *
  5780. * @type {number}
  5781. * @since 4.0.3
  5782. * @product highcharts
  5783. * @apioption plotOptions.bubble.zMax
  5784. */
  5785. /**
  5786. * @default z
  5787. * @apioption plotOptions.bubble.colorKey
  5788. */
  5789. /**
  5790. * The minimum for the Z value range. Defaults to the lowest Z value
  5791. * in the data.
  5792. *
  5793. * @see [zMax](#plotOptions.bubble.zMax)
  5794. *
  5795. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  5796. * Z has a possible range of 0-100
  5797. *
  5798. * @type {number}
  5799. * @since 4.0.3
  5800. * @product highcharts
  5801. * @apioption plotOptions.bubble.zMin
  5802. */
  5803. /**
  5804. * When [displayNegative](#plotOptions.bubble.displayNegative) is `false`,
  5805. * bubbles with lower Z values are skipped. When `displayNegative`
  5806. * is `true` and a [negativeColor](#plotOptions.bubble.negativeColor)
  5807. * is given, points with lower Z is colored.
  5808. *
  5809. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  5810. * Negative bubbles
  5811. *
  5812. * @since 3.0
  5813. * @product highcharts
  5814. */
  5815. zThreshold: 0,
  5816. zoneAxis: 'z'
  5817. });
  5818. return BubbleSeries;
  5819. }(ScatterSeries));
  5820. extend(BubbleSeries.prototype, {
  5821. alignDataLabel: ColumnSeries.prototype.alignDataLabel,
  5822. applyZones: noop,
  5823. bubblePadding: true,
  5824. buildKDTree: noop,
  5825. directTouch: true,
  5826. isBubble: true,
  5827. pointArrayMap: ['y', 'z'],
  5828. pointClass: BubblePoint,
  5829. parallelArrays: ['x', 'y', 'z'],
  5830. trackerGroups: ['group', 'dataLabelsGroup'],
  5831. specialGroup: 'group',
  5832. zoneAxis: 'z'
  5833. });
  5834. /* *
  5835. *
  5836. * Axis ?
  5837. *
  5838. * */
  5839. // Add logic to pad each axis with the amount of pixels necessary to avoid the
  5840. // bubbles to overflow.
  5841. Axis.prototype.beforePadding = function () {
  5842. var axis = this,
  5843. axisLength = this.len,
  5844. chart = this.chart,
  5845. pxMin = 0,
  5846. pxMax = axisLength,
  5847. isXAxis = this.isXAxis,
  5848. dataKey = isXAxis ? 'xData' : 'yData',
  5849. min = this.min,
  5850. extremes = {},
  5851. smallestSize = Math.min(chart.plotWidth,
  5852. chart.plotHeight),
  5853. zMin = Number.MAX_VALUE,
  5854. zMax = -Number.MAX_VALUE,
  5855. range = this.max - min,
  5856. transA = axisLength / range,
  5857. activeSeries = [];
  5858. // Handle padding on the second pass, or on redraw
  5859. this.series.forEach(function (series) {
  5860. var seriesOptions = series.options,
  5861. zData;
  5862. if (series.bubblePadding &&
  5863. (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
  5864. // Correction for #1673
  5865. axis.allowZoomOutside = true;
  5866. // Cache it
  5867. activeSeries.push(series);
  5868. if (isXAxis) { // because X axis is evaluated first
  5869. // For each series, translate the size extremes to pixel values
  5870. ['minSize', 'maxSize'].forEach(function (prop) {
  5871. var length = seriesOptions[prop],
  5872. isPercent = /%$/.test(length);
  5873. length = pInt(length);
  5874. extremes[prop] = isPercent ?
  5875. smallestSize * length / 100 :
  5876. length;
  5877. });
  5878. series.minPxSize = extremes.minSize;
  5879. // Prioritize min size if conflict to make sure bubbles are
  5880. // always visible. #5873
  5881. series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
  5882. // Find the min and max Z
  5883. zData = series.zData.filter(isNumber);
  5884. if (zData.length) { // #1735
  5885. zMin = pick(seriesOptions.zMin, clamp(arrayMin(zData), seriesOptions.displayNegative === false ?
  5886. seriesOptions.zThreshold :
  5887. -Number.MAX_VALUE, zMin));
  5888. zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
  5889. }
  5890. }
  5891. }
  5892. });
  5893. activeSeries.forEach(function (series) {
  5894. var data = series[dataKey],
  5895. i = data.length,
  5896. radius;
  5897. if (isXAxis) {
  5898. series.getRadii(zMin, zMax, series);
  5899. }
  5900. if (range > 0) {
  5901. while (i--) {
  5902. if (isNumber(data[i]) &&
  5903. axis.dataMin <= data[i] &&
  5904. data[i] <= axis.max) {
  5905. radius = series.radii ? series.radii[i] : 0;
  5906. pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
  5907. pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
  5908. }
  5909. }
  5910. }
  5911. });
  5912. // Apply the padding to the min and max properties
  5913. if (activeSeries.length && range > 0 && !this.logarithmic) {
  5914. pxMax -= axisLength;
  5915. transA *= (axisLength +
  5916. Math.max(0, pxMin) - // #8901
  5917. Math.min(pxMax, axisLength)) / axisLength;
  5918. [
  5919. ['min', 'userMin', pxMin],
  5920. ['max', 'userMax', pxMax]
  5921. ].forEach(function (keys) {
  5922. if (typeof pick(axis.options[keys[0]], axis[keys[1]]) === 'undefined') {
  5923. axis[keys[0]] += keys[2] / transA;
  5924. }
  5925. });
  5926. }
  5927. /* eslint-enable valid-jsdoc */
  5928. };
  5929. SeriesRegistry.registerSeriesType('bubble', BubbleSeries);
  5930. /* *
  5931. *
  5932. * Default Export
  5933. *
  5934. * */
  5935. /* *
  5936. *
  5937. * API Declarations
  5938. *
  5939. * */
  5940. /**
  5941. * @typedef {"area"|"width"} Highcharts.BubbleSizeByValue
  5942. */
  5943. ''; // detach doclets above
  5944. /* *
  5945. *
  5946. * API Options
  5947. *
  5948. * */
  5949. /**
  5950. * A `bubble` series. If the [type](#series.bubble.type) option is
  5951. * not specified, it is inherited from [chart.type](#chart.type).
  5952. *
  5953. * @extends series,plotOptions.bubble
  5954. * @excluding dataParser, dataURL, stack
  5955. * @product highcharts highstock
  5956. * @requires highcharts-more
  5957. * @apioption series.bubble
  5958. */
  5959. /**
  5960. * An array of data points for the series. For the `bubble` series type,
  5961. * points can be given in the following ways:
  5962. *
  5963. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  5964. * to `x,y,z`. If the first value is a string, it is applied as the name of
  5965. * the point, and the `x` value is inferred. The `x` value can also be
  5966. * omitted, in which case the inner arrays should be of length 2\. Then the
  5967. * `x` value is automatically calculated, either starting at 0 and
  5968. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  5969. * series options.
  5970. * ```js
  5971. * data: [
  5972. * [0, 1, 2],
  5973. * [1, 5, 5],
  5974. * [2, 0, 2]
  5975. * ]
  5976. * ```
  5977. *
  5978. * 2. An array of objects with named values. The following snippet shows only a
  5979. * few settings, see the complete options set below. If the total number of
  5980. * data points exceeds the series'
  5981. * [turboThreshold](#series.bubble.turboThreshold), this option is not
  5982. * available.
  5983. * ```js
  5984. * data: [{
  5985. * x: 1,
  5986. * y: 1,
  5987. * z: 1,
  5988. * name: "Point2",
  5989. * color: "#00FF00"
  5990. * }, {
  5991. * x: 1,
  5992. * y: 5,
  5993. * z: 4,
  5994. * name: "Point1",
  5995. * color: "#FF00FF"
  5996. * }]
  5997. * ```
  5998. *
  5999. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  6000. * Arrays of numeric x and y
  6001. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  6002. * Arrays of datetime x and y
  6003. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  6004. * Arrays of point.name and y
  6005. * @sample {highcharts} highcharts/series/data-array-of-objects/
  6006. * Config objects
  6007. *
  6008. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  6009. * @extends series.line.data
  6010. * @product highcharts
  6011. * @apioption series.bubble.data
  6012. */
  6013. /**
  6014. * @extends series.line.data.marker
  6015. * @excluding enabledThreshold, height, radius, width
  6016. * @product highcharts
  6017. * @apioption series.bubble.data.marker
  6018. */
  6019. /**
  6020. * The size value for each bubble. The bubbles' diameters are computed
  6021. * based on the `z`, and controlled by series options like `minSize`,
  6022. * `maxSize`, `sizeBy`, `zMin` and `zMax`.
  6023. *
  6024. * @type {number|null}
  6025. * @product highcharts
  6026. * @apioption series.bubble.data.z
  6027. */
  6028. /**
  6029. * @excluding enabled, enabledThreshold, height, radius, width
  6030. * @apioption series.bubble.marker
  6031. */
  6032. ''; // adds doclets above to transpiled file
  6033. return BubbleSeries;
  6034. });
  6035. _registerModule(_modules, 'Series/MapBubble/MapBubblePoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  6036. /* *
  6037. *
  6038. * (c) 2010-2021 Torstein Honsi
  6039. *
  6040. * License: www.highcharts.com/license
  6041. *
  6042. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6043. *
  6044. * */
  6045. var __extends = (this && this.__extends) || (function () {
  6046. var extendStatics = function (d,
  6047. b) {
  6048. extendStatics = Object.setPrototypeOf ||
  6049. ({ __proto__: [] } instanceof Array && function (d,
  6050. b) { d.__proto__ = b; }) ||
  6051. function (d,
  6052. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6053. return extendStatics(d, b);
  6054. };
  6055. return function (d, b) {
  6056. extendStatics(d, b);
  6057. function __() { this.constructor = d; }
  6058. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6059. };
  6060. })();
  6061. var _a = SeriesRegistry.seriesTypes,
  6062. BubbleSeries = _a.bubble,
  6063. MapSeries = _a.map;
  6064. var extend = U.extend,
  6065. merge = U.merge;
  6066. /* *
  6067. *
  6068. * Class
  6069. *
  6070. * */
  6071. var MapBubblePoint = /** @class */ (function (_super) {
  6072. __extends(MapBubblePoint, _super);
  6073. function MapBubblePoint() {
  6074. return _super !== null && _super.apply(this, arguments) || this;
  6075. }
  6076. /* *
  6077. *
  6078. * Functions
  6079. *
  6080. * */
  6081. /* eslint-disable valid-jsdoc */
  6082. /**
  6083. * @private
  6084. */
  6085. MapBubblePoint.prototype.applyOptions = function (options, x) {
  6086. var point;
  6087. if (options &&
  6088. typeof options.lat !== 'undefined' &&
  6089. typeof options.lon !== 'undefined') {
  6090. point = _super.prototype.applyOptions.call(this, merge(options, this.series.chart.fromLatLonToPoint(options)), x);
  6091. }
  6092. else {
  6093. point = MapSeries.prototype.pointClass.prototype
  6094. .applyOptions.call(this, options, x);
  6095. }
  6096. return point;
  6097. };
  6098. /**
  6099. * @private
  6100. */
  6101. MapBubblePoint.prototype.isValid = function () {
  6102. return typeof this.z === 'number';
  6103. };
  6104. return MapBubblePoint;
  6105. }(BubbleSeries.prototype.pointClass));
  6106. extend(MapBubblePoint.prototype, {
  6107. ttBelow: false
  6108. });
  6109. /* *
  6110. *
  6111. * Default Export
  6112. *
  6113. * */
  6114. return MapBubblePoint;
  6115. });
  6116. _registerModule(_modules, 'Series/MapBubble/MapBubbleSeries.js', [_modules['Series/Bubble/BubbleSeries.js'], _modules['Series/MapBubble/MapBubblePoint.js'], _modules['Series/Map/MapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (BubbleSeries, MapBubblePoint, MapSeries, SeriesRegistry, U) {
  6117. /* *
  6118. *
  6119. * (c) 2010-2021 Torstein Honsi
  6120. *
  6121. * License: www.highcharts.com/license
  6122. *
  6123. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6124. *
  6125. * */
  6126. var __extends = (this && this.__extends) || (function () {
  6127. var extendStatics = function (d,
  6128. b) {
  6129. extendStatics = Object.setPrototypeOf ||
  6130. ({ __proto__: [] } instanceof Array && function (d,
  6131. b) { d.__proto__ = b; }) ||
  6132. function (d,
  6133. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6134. return extendStatics(d, b);
  6135. };
  6136. return function (d, b) {
  6137. extendStatics(d, b);
  6138. function __() { this.constructor = d; }
  6139. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6140. };
  6141. })();
  6142. var extend = U.extend,
  6143. merge = U.merge;
  6144. /* *
  6145. *
  6146. * Class
  6147. *
  6148. * */
  6149. /**
  6150. * @private
  6151. * @class
  6152. * @name Highcharts.seriesTypes.mapbubble
  6153. *
  6154. * @augments Highcharts.Series
  6155. */
  6156. var MapBubbleSeries = /** @class */ (function (_super) {
  6157. __extends(MapBubbleSeries, _super);
  6158. function MapBubbleSeries() {
  6159. /* *
  6160. *
  6161. * Static Properties
  6162. *
  6163. * */
  6164. var _this = _super !== null && _super.apply(this,
  6165. arguments) || this;
  6166. /* *
  6167. *
  6168. * Properties
  6169. *
  6170. * */
  6171. _this.data = void 0;
  6172. _this.options = void 0;
  6173. _this.points = void 0;
  6174. return _this;
  6175. }
  6176. /**
  6177. * A map bubble series is a bubble series laid out on top of a map
  6178. * series, where each bubble is tied to a specific map area.
  6179. *
  6180. * @sample maps/demo/map-bubble/
  6181. * Map bubble chart
  6182. *
  6183. * @extends plotOptions.bubble
  6184. * @product highmaps
  6185. * @optionparent plotOptions.mapbubble
  6186. */
  6187. MapBubbleSeries.defaultOptions = merge(BubbleSeries.defaultOptions, {
  6188. /**
  6189. * The main color of the series. This color affects both the fill
  6190. * and the stroke of the bubble. For enhanced control, use `marker`
  6191. * options.
  6192. *
  6193. * @sample {highmaps} maps/plotoptions/mapbubble-color/
  6194. * Pink bubbles
  6195. *
  6196. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6197. * @apioption plotOptions.mapbubble.color
  6198. */
  6199. /**
  6200. * Whether to display negative sized bubbles. The threshold is
  6201. * given by the [zThreshold](#plotOptions.mapbubble.zThreshold)
  6202. * option, and negative bubbles can be visualized by setting
  6203. * [negativeColor](#plotOptions.bubble.negativeColor).
  6204. *
  6205. * @type {boolean}
  6206. * @default true
  6207. * @apioption plotOptions.mapbubble.displayNegative
  6208. */
  6209. /**
  6210. * @sample {highmaps} maps/demo/map-bubble/
  6211. * Bubble size
  6212. *
  6213. * @apioption plotOptions.mapbubble.maxSize
  6214. */
  6215. /**
  6216. * @sample {highmaps} maps/demo/map-bubble/
  6217. * Bubble size
  6218. *
  6219. * @apioption plotOptions.mapbubble.minSize
  6220. */
  6221. /**
  6222. * When a point's Z value is below the
  6223. * [zThreshold](#plotOptions.mapbubble.zThreshold) setting, this
  6224. * color is used.
  6225. *
  6226. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  6227. * Negative color below a threshold
  6228. *
  6229. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6230. * @apioption plotOptions.mapbubble.negativeColor
  6231. */
  6232. /**
  6233. * Whether the bubble's value should be represented by the area or
  6234. * the width of the bubble. The default, `area`, corresponds best to
  6235. * the human perception of the size of each bubble.
  6236. *
  6237. * @type {Highcharts.BubbleSizeByValue}
  6238. * @default area
  6239. * @apioption plotOptions.mapbubble.sizeBy
  6240. */
  6241. /**
  6242. * When this is true, the absolute value of z determines the size
  6243. * of the bubble. This means that with the default `zThreshold` of
  6244. * 0, a bubble of value -1 will have the same size as a bubble of
  6245. * value 1, while a bubble of value 0 will have a smaller size
  6246. * according to `minSize`.
  6247. *
  6248. * @sample {highmaps} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  6249. * Size by absolute value, various thresholds
  6250. *
  6251. * @type {boolean}
  6252. * @default false
  6253. * @since 1.1.9
  6254. * @apioption plotOptions.mapbubble.sizeByAbsoluteValue
  6255. */
  6256. /**
  6257. * The minimum for the Z value range. Defaults to the highest Z
  6258. * value in the data.
  6259. *
  6260. * @see [zMax](#plotOptions.mapbubble.zMin)
  6261. *
  6262. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  6263. * Z has a possible range of 0-100
  6264. *
  6265. * @type {number}
  6266. * @since 1.0.3
  6267. * @apioption plotOptions.mapbubble.zMax
  6268. */
  6269. /**
  6270. * The minimum for the Z value range. Defaults to the lowest Z value
  6271. * in the data.
  6272. *
  6273. * @see [zMax](#plotOptions.mapbubble.zMax)
  6274. *
  6275. * @sample {highmaps} highcharts/plotoptions/bubble-zmin-zmax/
  6276. * Z has a possible range of 0-100
  6277. *
  6278. * @type {number}
  6279. * @since 1.0.3
  6280. * @apioption plotOptions.mapbubble.zMin
  6281. */
  6282. /**
  6283. * When [displayNegative](#plotOptions.mapbubble.displayNegative)
  6284. * is `false`, bubbles with lower Z values are skipped. When
  6285. * `displayNegative` is `true` and a
  6286. * [negativeColor](#plotOptions.mapbubble.negativeColor) is given,
  6287. * points with lower Z is colored.
  6288. *
  6289. * @sample {highmaps} maps/plotoptions/mapbubble-negativecolor/
  6290. * Negative color below a threshold
  6291. *
  6292. * @type {number}
  6293. * @default 0
  6294. * @apioption plotOptions.mapbubble.zThreshold
  6295. */
  6296. animationLimit: 500,
  6297. tooltip: {
  6298. pointFormat: '{point.name}: {point.z}'
  6299. }
  6300. });
  6301. return MapBubbleSeries;
  6302. }(BubbleSeries));
  6303. extend(MapBubbleSeries.prototype, {
  6304. type: 'mapbubble',
  6305. getBox: MapSeries.prototype.getBox,
  6306. // If one single value is passed, it is interpreted as z
  6307. pointArrayMap: ['z'],
  6308. pointClass: MapBubblePoint,
  6309. setData: MapSeries.prototype.setData,
  6310. setOptions: MapSeries.prototype.setOptions,
  6311. xyFromShape: true
  6312. });
  6313. SeriesRegistry.registerSeriesType('mapbubble', MapBubbleSeries);
  6314. /* *
  6315. *
  6316. * Default Export
  6317. *
  6318. * */
  6319. /* *
  6320. *
  6321. * API Options
  6322. *
  6323. * */
  6324. /**
  6325. * A `mapbubble` series. If the [type](#series.mapbubble.type) option
  6326. * is not specified, it is inherited from [chart.type](#chart.type).
  6327. *
  6328. * @extends series,plotOptions.mapbubble
  6329. * @excluding dataParser, dataURL
  6330. * @product highmaps
  6331. * @apioption series.mapbubble
  6332. */
  6333. /**
  6334. * An array of data points for the series. For the `mapbubble` series
  6335. * type, points can be given in the following ways:
  6336. *
  6337. * 1. An array of numerical values. In this case, the numerical values
  6338. * will be interpreted as `z` options. Example:
  6339. *
  6340. * ```js
  6341. * data: [0, 5, 3, 5]
  6342. * ```
  6343. *
  6344. * 2. An array of objects with named values. The following snippet shows only a
  6345. * few settings, see the complete options set below. If the total number of
  6346. * data points exceeds the series'
  6347. * [turboThreshold](#series.mapbubble.turboThreshold),
  6348. * this option is not available.
  6349. *
  6350. * ```js
  6351. * data: [{
  6352. * z: 9,
  6353. * name: "Point2",
  6354. * color: "#00FF00"
  6355. * }, {
  6356. * z: 10,
  6357. * name: "Point1",
  6358. * color: "#FF00FF"
  6359. * }]
  6360. * ```
  6361. *
  6362. * @type {Array<number|null|*>}
  6363. * @extends series.mappoint.data
  6364. * @excluding labelrank, middleX, middleY, path, value, x, y, lat, lon
  6365. * @product highmaps
  6366. * @apioption series.mapbubble.data
  6367. */
  6368. /**
  6369. * While the `x` and `y` values of the bubble are determined by the
  6370. * underlying map, the `z` indicates the actual value that gives the
  6371. * size of the bubble.
  6372. *
  6373. * @sample {highmaps} maps/demo/map-bubble/
  6374. * Bubble
  6375. *
  6376. * @type {number|null}
  6377. * @product highmaps
  6378. * @apioption series.mapbubble.data.z
  6379. */
  6380. /**
  6381. * @excluding enabled, enabledThreshold, height, radius, width
  6382. * @apioption series.mapbubble.marker
  6383. */
  6384. ''; // adds doclets above to transpiled file
  6385. return MapBubbleSeries;
  6386. });
  6387. _registerModule(_modules, 'Series/Heatmap/HeatmapPoint.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, SeriesRegistry, U) {
  6388. /* *
  6389. *
  6390. * (c) 2010-2021 Torstein Honsi
  6391. *
  6392. * License: www.highcharts.com/license
  6393. *
  6394. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6395. *
  6396. * */
  6397. var __extends = (this && this.__extends) || (function () {
  6398. var extendStatics = function (d,
  6399. b) {
  6400. extendStatics = Object.setPrototypeOf ||
  6401. ({ __proto__: [] } instanceof Array && function (d,
  6402. b) { d.__proto__ = b; }) ||
  6403. function (d,
  6404. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6405. return extendStatics(d, b);
  6406. };
  6407. return function (d, b) {
  6408. extendStatics(d, b);
  6409. function __() { this.constructor = d; }
  6410. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6411. };
  6412. })();
  6413. var colorMapPointMixin = ColorMapMixin.colorMapPointMixin;
  6414. var ScatterPoint = SeriesRegistry.seriesTypes.scatter.prototype.pointClass;
  6415. var clamp = U.clamp,
  6416. extend = U.extend,
  6417. pick = U.pick;
  6418. /* *
  6419. *
  6420. * Class
  6421. *
  6422. * */
  6423. var HeatmapPoint = /** @class */ (function (_super) {
  6424. __extends(HeatmapPoint, _super);
  6425. function HeatmapPoint() {
  6426. /* *
  6427. *
  6428. * Properties
  6429. *
  6430. * */
  6431. var _this = _super !== null && _super.apply(this,
  6432. arguments) || this;
  6433. _this.options = void 0;
  6434. _this.series = void 0;
  6435. _this.value = void 0;
  6436. _this.x = void 0;
  6437. _this.y = void 0;
  6438. return _this;
  6439. /* eslint-enable valid-jsdoc */
  6440. }
  6441. /* *
  6442. *
  6443. * Functions
  6444. *
  6445. * */
  6446. /* eslint-disable valid-jsdoc */
  6447. /**
  6448. * @private
  6449. */
  6450. HeatmapPoint.prototype.applyOptions = function (options, x) {
  6451. var point = _super.prototype.applyOptions.call(this,
  6452. options,
  6453. x);
  6454. point.formatPrefix = point.isNull || point.value === null ? 'null' : 'point';
  6455. return point;
  6456. };
  6457. HeatmapPoint.prototype.getCellAttributes = function () {
  6458. var point = this,
  6459. series = point.series,
  6460. seriesOptions = series.options,
  6461. xPad = (seriesOptions.colsize || 1) / 2,
  6462. yPad = (seriesOptions.rowsize || 1) / 2,
  6463. xAxis = series.xAxis,
  6464. yAxis = series.yAxis,
  6465. markerOptions = point.options.marker || series.options.marker,
  6466. pointPlacement = series.pointPlacementToXValue(), // #7860
  6467. pointPadding = pick(point.pointPadding,
  6468. seriesOptions.pointPadding, 0),
  6469. cellAttr = {
  6470. x1: clamp(Math.round(xAxis.len -
  6471. (xAxis.translate(point.x - xPad,
  6472. false,
  6473. true,
  6474. false,
  6475. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  6476. x2: clamp(Math.round(xAxis.len -
  6477. (xAxis.translate(point.x + xPad,
  6478. false,
  6479. true,
  6480. false,
  6481. true, -pointPlacement) || 0)), -xAxis.len, 2 * xAxis.len),
  6482. y1: clamp(Math.round((yAxis.translate(point.y - yPad,
  6483. false,
  6484. true,
  6485. false,
  6486. true) || 0)), -yAxis.len, 2 * yAxis.len),
  6487. y2: clamp(Math.round((yAxis.translate(point.y + yPad,
  6488. false,
  6489. true,
  6490. false,
  6491. true) || 0)), -yAxis.len, 2 * yAxis.len)
  6492. };
  6493. // Handle marker's fixed width, and height values including border
  6494. // and pointPadding while calculating cell attributes.
  6495. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  6496. var prop = dimension[0],
  6497. direction = dimension[1];
  6498. var start = direction + '1', end = direction + '2';
  6499. var side = Math.abs(cellAttr[start] - cellAttr[end]),
  6500. borderWidth = markerOptions &&
  6501. markerOptions.lineWidth || 0,
  6502. plotPos = Math.abs(cellAttr[start] + cellAttr[end]) / 2;
  6503. if (markerOptions[prop] &&
  6504. markerOptions[prop] < side) {
  6505. cellAttr[start] = plotPos - (markerOptions[prop] / 2) -
  6506. (borderWidth / 2);
  6507. cellAttr[end] = plotPos + (markerOptions[prop] / 2) +
  6508. (borderWidth / 2);
  6509. }
  6510. // Handle pointPadding
  6511. if (pointPadding) {
  6512. if (direction === 'y') {
  6513. start = end;
  6514. end = direction + '1';
  6515. }
  6516. cellAttr[start] += pointPadding;
  6517. cellAttr[end] -= pointPadding;
  6518. }
  6519. });
  6520. return cellAttr;
  6521. };
  6522. /**
  6523. * @private
  6524. */
  6525. HeatmapPoint.prototype.haloPath = function (size) {
  6526. if (!size) {
  6527. return [];
  6528. }
  6529. var rect = this.shapeArgs;
  6530. return [
  6531. 'M',
  6532. rect.x - size,
  6533. rect.y - size,
  6534. 'L',
  6535. rect.x - size,
  6536. rect.y + rect.height + size,
  6537. rect.x + rect.width + size,
  6538. rect.y + rect.height + size,
  6539. rect.x + rect.width + size,
  6540. rect.y - size,
  6541. 'Z'
  6542. ];
  6543. };
  6544. /**
  6545. * Color points have a value option that determines whether or not it is
  6546. * a null point
  6547. * @private
  6548. */
  6549. HeatmapPoint.prototype.isValid = function () {
  6550. // undefined is allowed
  6551. return (this.value !== Infinity &&
  6552. this.value !== -Infinity);
  6553. };
  6554. return HeatmapPoint;
  6555. }(ScatterPoint));
  6556. extend(HeatmapPoint.prototype, {
  6557. dataLabelOnNull: colorMapPointMixin.dataLabelOnNull,
  6558. setState: colorMapPointMixin.setState
  6559. });
  6560. /* *
  6561. *
  6562. * Default Export
  6563. *
  6564. * */
  6565. return HeatmapPoint;
  6566. });
  6567. _registerModule(_modules, 'Series/Heatmap/HeatmapSeries.js', [_modules['Mixins/ColorMapSeries.js'], _modules['Core/Globals.js'], _modules['Series/Heatmap/HeatmapPoint.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (ColorMapMixin, H, HeatmapPoint, LegendSymbolMixin, palette, SeriesRegistry, SVGRenderer, U) {
  6568. /* *
  6569. *
  6570. * (c) 2010-2021 Torstein Honsi
  6571. *
  6572. * License: www.highcharts.com/license
  6573. *
  6574. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6575. *
  6576. * */
  6577. var __extends = (this && this.__extends) || (function () {
  6578. var extendStatics = function (d,
  6579. b) {
  6580. extendStatics = Object.setPrototypeOf ||
  6581. ({ __proto__: [] } instanceof Array && function (d,
  6582. b) { d.__proto__ = b; }) ||
  6583. function (d,
  6584. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6585. return extendStatics(d, b);
  6586. };
  6587. return function (d, b) {
  6588. extendStatics(d, b);
  6589. function __() { this.constructor = d; }
  6590. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6591. };
  6592. })();
  6593. var colorMapSeriesMixin = ColorMapMixin.colorMapSeriesMixin;
  6594. var noop = H.noop;
  6595. var Series = SeriesRegistry.series,
  6596. _a = SeriesRegistry.seriesTypes,
  6597. ColumnSeries = _a.column,
  6598. ScatterSeries = _a.scatter;
  6599. var symbols = SVGRenderer.prototype.symbols;
  6600. var extend = U.extend,
  6601. fireEvent = U.fireEvent,
  6602. isNumber = U.isNumber,
  6603. merge = U.merge,
  6604. pick = U.pick;
  6605. /* *
  6606. *
  6607. * Class
  6608. *
  6609. * */
  6610. /**
  6611. * @private
  6612. * @class
  6613. * @name Highcharts.seriesTypes.heatmap
  6614. *
  6615. * @augments Highcharts.Series
  6616. */
  6617. var HeatmapSeries = /** @class */ (function (_super) {
  6618. __extends(HeatmapSeries, _super);
  6619. function HeatmapSeries() {
  6620. /* *
  6621. *
  6622. * Static Properties
  6623. *
  6624. * */
  6625. var _this = _super !== null && _super.apply(this,
  6626. arguments) || this;
  6627. /* *
  6628. *
  6629. * Properties
  6630. *
  6631. * */
  6632. _this.colorAxis = void 0;
  6633. _this.data = void 0;
  6634. _this.options = void 0;
  6635. _this.points = void 0;
  6636. _this.valueMax = NaN;
  6637. _this.valueMin = NaN;
  6638. return _this;
  6639. /* eslint-enable valid-jsdoc */
  6640. }
  6641. /* *
  6642. *
  6643. * Functions
  6644. *
  6645. * */
  6646. /* eslint-disable valid-jsdoc */
  6647. /**
  6648. * @private
  6649. */
  6650. HeatmapSeries.prototype.drawPoints = function () {
  6651. var _this = this;
  6652. // In styled mode, use CSS, otherwise the fill used in the style
  6653. // sheet will take precedence over the fill attribute.
  6654. var seriesMarkerOptions = this.options.marker || {};
  6655. if (seriesMarkerOptions.enabled || this._hasPointMarkers) {
  6656. Series.prototype.drawPoints.call(this);
  6657. this.points.forEach(function (point) {
  6658. point.graphic &&
  6659. point.graphic[_this.chart.styledMode ? 'css' : 'animate'](_this.colorAttribs(point));
  6660. });
  6661. }
  6662. };
  6663. /**
  6664. * @private
  6665. */
  6666. HeatmapSeries.prototype.getExtremes = function () {
  6667. // Get the extremes from the value data
  6668. var _a = Series.prototype.getExtremes
  6669. .call(this,
  6670. this.valueData),
  6671. dataMin = _a.dataMin,
  6672. dataMax = _a.dataMax;
  6673. if (isNumber(dataMin)) {
  6674. this.valueMin = dataMin;
  6675. }
  6676. if (isNumber(dataMax)) {
  6677. this.valueMax = dataMax;
  6678. }
  6679. // Get the extremes from the y data
  6680. return Series.prototype.getExtremes.call(this);
  6681. };
  6682. /**
  6683. * Override to also allow null points, used when building the k-d-tree for
  6684. * tooltips in boost mode.
  6685. * @private
  6686. */
  6687. HeatmapSeries.prototype.getValidPoints = function (points, insideOnly) {
  6688. return Series.prototype.getValidPoints.call(this, points, insideOnly, true);
  6689. };
  6690. /**
  6691. * Define hasData function for non-cartesian series. Returns true if the
  6692. * series has points at all.
  6693. * @private
  6694. */
  6695. HeatmapSeries.prototype.hasData = function () {
  6696. return !!this.processedXData.length; // != 0
  6697. };
  6698. /**
  6699. * Override the init method to add point ranges on both axes.
  6700. * @private
  6701. */
  6702. HeatmapSeries.prototype.init = function () {
  6703. var options;
  6704. Series.prototype.init.apply(this, arguments);
  6705. options = this.options;
  6706. // #3758, prevent resetting in setData
  6707. options.pointRange = pick(options.pointRange, options.colsize || 1);
  6708. // general point range
  6709. this.yAxis.axisPointRange = options.rowsize || 1;
  6710. // Bind new symbol names
  6711. extend(symbols, {
  6712. ellipse: symbols.circle,
  6713. rect: symbols.square
  6714. });
  6715. };
  6716. /**
  6717. * @private
  6718. */
  6719. HeatmapSeries.prototype.markerAttribs = function (point, state) {
  6720. var pointMarkerOptions = point.marker || {},
  6721. seriesMarkerOptions = this.options.marker || {},
  6722. seriesStateOptions,
  6723. pointStateOptions,
  6724. shapeArgs = point.shapeArgs || {},
  6725. hasImage = point.hasImage,
  6726. attribs = {};
  6727. if (hasImage) {
  6728. return {
  6729. x: point.plotX,
  6730. y: point.plotY
  6731. };
  6732. }
  6733. // Setting width and height attributes on image does not affect
  6734. // on its dimensions.
  6735. if (state) {
  6736. seriesStateOptions = seriesMarkerOptions.states[state] || {};
  6737. pointStateOptions = pointMarkerOptions.states &&
  6738. pointMarkerOptions.states[state] || {};
  6739. [['width', 'x'], ['height', 'y']].forEach(function (dimension) {
  6740. // Set new width and height basing on state options.
  6741. attribs[dimension[0]] = (pointStateOptions[dimension[0]] ||
  6742. seriesStateOptions[dimension[0]] ||
  6743. shapeArgs[dimension[0]]) + (pointStateOptions[dimension[0] + 'Plus'] ||
  6744. seriesStateOptions[dimension[0] + 'Plus'] || 0);
  6745. // Align marker by a new size.
  6746. attribs[dimension[1]] = shapeArgs[dimension[1]] +
  6747. (shapeArgs[dimension[0]] - attribs[dimension[0]]) / 2;
  6748. });
  6749. }
  6750. return state ? attribs : shapeArgs;
  6751. };
  6752. /**
  6753. * @private
  6754. */
  6755. HeatmapSeries.prototype.pointAttribs = function (point, state) {
  6756. var series = this,
  6757. attr = Series.prototype.pointAttribs.call(series,
  6758. point,
  6759. state),
  6760. seriesOptions = series.options || {},
  6761. plotOptions = series.chart.options.plotOptions || {},
  6762. seriesPlotOptions = plotOptions.series || {},
  6763. heatmapPlotOptions = plotOptions.heatmap || {},
  6764. stateOptions,
  6765. brightness,
  6766. // Get old properties in order to keep backward compatibility
  6767. borderColor = seriesOptions.borderColor ||
  6768. heatmapPlotOptions.borderColor ||
  6769. seriesPlotOptions.borderColor,
  6770. borderWidth = seriesOptions.borderWidth ||
  6771. heatmapPlotOptions.borderWidth ||
  6772. seriesPlotOptions.borderWidth ||
  6773. attr['stroke-width'];
  6774. // Apply lineColor, or set it to default series color.
  6775. attr.stroke = ((point && point.marker && point.marker.lineColor) ||
  6776. (seriesOptions.marker && seriesOptions.marker.lineColor) ||
  6777. borderColor ||
  6778. this.color);
  6779. // Apply old borderWidth property if exists.
  6780. attr['stroke-width'] = borderWidth;
  6781. if (state) {
  6782. stateOptions =
  6783. merge(seriesOptions.states[state], seriesOptions.marker &&
  6784. seriesOptions.marker.states[state], point &&
  6785. point.options.states &&
  6786. point.options.states[state] || {});
  6787. brightness = stateOptions.brightness;
  6788. attr.fill =
  6789. stateOptions.color ||
  6790. H.color(attr.fill).brighten(brightness || 0).get();
  6791. attr.stroke = stateOptions.lineColor;
  6792. }
  6793. return attr;
  6794. };
  6795. /**
  6796. * @private
  6797. */
  6798. HeatmapSeries.prototype.setClip = function (animation) {
  6799. var series = this,
  6800. chart = series.chart;
  6801. Series.prototype.setClip.apply(series, arguments);
  6802. if (series.options.clip !== false || animation) {
  6803. series.markerGroup
  6804. .clip((animation || series.clipBox) && series.sharedClipKey ?
  6805. chart[series.sharedClipKey] :
  6806. chart.clipRect);
  6807. }
  6808. };
  6809. /**
  6810. * @private
  6811. */
  6812. HeatmapSeries.prototype.translate = function () {
  6813. var series = this, options = series.options, symbol = options.marker && options.marker.symbol || '', shape = symbols[symbol] ? symbol : 'rect', options = series.options, hasRegularShape = ['circle', 'square'].indexOf(shape) !== -1;
  6814. series.generatePoints();
  6815. series.points.forEach(function (point) {
  6816. var pointAttr,
  6817. sizeDiff,
  6818. hasImage,
  6819. cellAttr = point.getCellAttributes(),
  6820. shapeArgs = {
  6821. x: Math.min(cellAttr.x1,
  6822. cellAttr.x2),
  6823. y: Math.min(cellAttr.y1,
  6824. cellAttr.y2),
  6825. width: Math.max(Math.abs(cellAttr.x2 - cellAttr.x1), 0),
  6826. height: Math.max(Math.abs(cellAttr.y2 - cellAttr.y1), 0)
  6827. };
  6828. hasImage = point.hasImage =
  6829. (point.marker && point.marker.symbol || symbol || '')
  6830. .indexOf('url') === 0;
  6831. // If marker shape is regular (symetric), find shorter
  6832. // cell's side.
  6833. if (hasRegularShape) {
  6834. sizeDiff = Math.abs(shapeArgs.width - shapeArgs.height);
  6835. shapeArgs.x = Math.min(cellAttr.x1, cellAttr.x2) +
  6836. (shapeArgs.width < shapeArgs.height ? 0 : sizeDiff / 2);
  6837. shapeArgs.y = Math.min(cellAttr.y1, cellAttr.y2) +
  6838. (shapeArgs.width < shapeArgs.height ? sizeDiff / 2 : 0);
  6839. shapeArgs.width = shapeArgs.height =
  6840. Math.min(shapeArgs.width, shapeArgs.height);
  6841. }
  6842. pointAttr = {
  6843. plotX: (cellAttr.x1 + cellAttr.x2) / 2,
  6844. plotY: (cellAttr.y1 + cellAttr.y2) / 2,
  6845. clientX: (cellAttr.x1 + cellAttr.x2) / 2,
  6846. shapeType: 'path',
  6847. shapeArgs: merge(true, shapeArgs, {
  6848. d: symbols[shape](shapeArgs.x, shapeArgs.y, shapeArgs.width, shapeArgs.height)
  6849. })
  6850. };
  6851. if (hasImage) {
  6852. point.marker = {
  6853. width: shapeArgs.width,
  6854. height: shapeArgs.height
  6855. };
  6856. }
  6857. extend(point, pointAttr);
  6858. });
  6859. fireEvent(series, 'afterTranslate');
  6860. };
  6861. /**
  6862. * A heatmap is a graphical representation of data where the individual
  6863. * values contained in a matrix are represented as colors.
  6864. *
  6865. * @productdesc {highcharts}
  6866. * Requires `modules/heatmap`.
  6867. *
  6868. * @sample highcharts/demo/heatmap/
  6869. * Simple heatmap
  6870. * @sample highcharts/demo/heatmap-canvas/
  6871. * Heavy heatmap
  6872. *
  6873. * @extends plotOptions.scatter
  6874. * @excluding animationLimit, connectEnds, connectNulls, cropThreshold,
  6875. * dashStyle, findNearestPointBy, getExtremesFromAll, jitter,
  6876. * linecap, lineWidth, pointInterval, pointIntervalUnit,
  6877. * pointRange, pointStart, shadow, softThreshold, stacking,
  6878. * step, threshold, cluster
  6879. * @product highcharts highmaps
  6880. * @optionparent plotOptions.heatmap
  6881. */
  6882. HeatmapSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  6883. /**
  6884. * Animation is disabled by default on the heatmap series.
  6885. */
  6886. animation: false,
  6887. /**
  6888. * The border width for each heat map item.
  6889. */
  6890. borderWidth: 0,
  6891. /**
  6892. * Padding between the points in the heatmap.
  6893. *
  6894. * @type {number}
  6895. * @default 0
  6896. * @since 6.0
  6897. * @apioption plotOptions.heatmap.pointPadding
  6898. */
  6899. /**
  6900. * @default value
  6901. * @apioption plotOptions.heatmap.colorKey
  6902. */
  6903. /**
  6904. * The main color of the series. In heat maps this color is rarely used,
  6905. * as we mostly use the color to denote the value of each point. Unless
  6906. * options are set in the [colorAxis](#colorAxis), the default value
  6907. * is pulled from the [options.colors](#colors) array.
  6908. *
  6909. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6910. * @since 4.0
  6911. * @product highcharts
  6912. * @apioption plotOptions.heatmap.color
  6913. */
  6914. /**
  6915. * The column size - how many X axis units each column in the heatmap
  6916. * should span.
  6917. *
  6918. * @sample {highcharts} maps/demo/heatmap/
  6919. * One day
  6920. * @sample {highmaps} maps/demo/heatmap/
  6921. * One day
  6922. *
  6923. * @type {number}
  6924. * @default 1
  6925. * @since 4.0
  6926. * @product highcharts highmaps
  6927. * @apioption plotOptions.heatmap.colsize
  6928. */
  6929. /**
  6930. * The row size - how many Y axis units each heatmap row should span.
  6931. *
  6932. * @sample {highcharts} maps/demo/heatmap/
  6933. * 1 by default
  6934. * @sample {highmaps} maps/demo/heatmap/
  6935. * 1 by default
  6936. *
  6937. * @type {number}
  6938. * @default 1
  6939. * @since 4.0
  6940. * @product highcharts highmaps
  6941. * @apioption plotOptions.heatmap.rowsize
  6942. */
  6943. /**
  6944. * The color applied to null points. In styled mode, a general CSS class
  6945. * is applied instead.
  6946. *
  6947. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6948. */
  6949. nullColor: palette.neutralColor3,
  6950. dataLabels: {
  6951. formatter: function () {
  6952. return this.point.value;
  6953. },
  6954. inside: true,
  6955. verticalAlign: 'middle',
  6956. crop: false,
  6957. overflow: false,
  6958. padding: 0 // #3837
  6959. },
  6960. /**
  6961. * @excluding radius, enabledThreshold
  6962. * @since 8.1
  6963. */
  6964. marker: {
  6965. /**
  6966. * A predefined shape or symbol for the marker. When undefined, the
  6967. * symbol is pulled from options.symbols. Other possible values are
  6968. * `'circle'`, `'square'`,`'diamond'`, `'triangle'`,
  6969. * `'triangle-down'`, `'rect'`, and `'ellipse'`.
  6970. *
  6971. * Additionally, the URL to a graphic can be given on this form:
  6972. * `'url(graphic.png)'`. Note that for the image to be applied to
  6973. * exported charts, its URL needs to be accessible by the export
  6974. * server.
  6975. *
  6976. * Custom callbacks for symbol path generation can also be added to
  6977. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  6978. * used by its method name, as shown in the demo.
  6979. *
  6980. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  6981. * Predefined, graphic and custom markers
  6982. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  6983. * Predefined, graphic and custom markers
  6984. */
  6985. symbol: 'rect',
  6986. /** @ignore-option */
  6987. radius: 0,
  6988. lineColor: void 0,
  6989. states: {
  6990. /**
  6991. * @excluding radius, radiusPlus
  6992. */
  6993. hover: {
  6994. /**
  6995. * Set the marker's fixed width on hover state.
  6996. *
  6997. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  6998. * 70px fixed marker's width and height on hover
  6999. *
  7000. * @type {number|undefined}
  7001. * @default undefined
  7002. * @product highcharts highmaps
  7003. * @apioption plotOptions.heatmap.marker.states.hover.width
  7004. */
  7005. /**
  7006. * Set the marker's fixed height on hover state.
  7007. *
  7008. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7009. * 70px fixed marker's width and height on hover
  7010. *
  7011. * @type {number|undefined}
  7012. * @default undefined
  7013. * @product highcharts highmaps
  7014. * @apioption plotOptions.heatmap.marker.states.hover.height
  7015. */
  7016. /**
  7017. * The number of pixels to increase the width of the
  7018. * selected point.
  7019. *
  7020. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7021. * 20px greater width and height on hover
  7022. *
  7023. * @type {number|undefined}
  7024. * @default undefined
  7025. * @product highcharts highmaps
  7026. * @apioption plotOptions.heatmap.marker.states.hover.widthPlus
  7027. */
  7028. /**
  7029. * The number of pixels to increase the height of the
  7030. * selected point.
  7031. *
  7032. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7033. * 20px greater width and height on hover
  7034. *
  7035. * @type {number|undefined}
  7036. * @default undefined
  7037. * @product highcharts highmaps
  7038. * @apioption plotOptions.heatmap.marker.states.hover.heightPlus
  7039. */
  7040. /**
  7041. * The additional line width for a hovered point.
  7042. *
  7043. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  7044. * 5 pixels wider lineWidth on hover
  7045. * @sample {highmaps} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  7046. * 5 pixels wider lineWidth on hover
  7047. */
  7048. lineWidthPlus: 0
  7049. },
  7050. /**
  7051. * @excluding radius
  7052. */
  7053. select: {
  7054. /**
  7055. * Set the marker's fixed width on select state.
  7056. *
  7057. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7058. * 70px fixed marker's width and height on hover
  7059. *
  7060. * @type {number|undefined}
  7061. * @default undefined
  7062. * @product highcharts highmaps
  7063. * @apioption plotOptions.heatmap.marker.states.select.width
  7064. */
  7065. /**
  7066. * Set the marker's fixed height on select state.
  7067. *
  7068. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7069. * 70px fixed marker's width and height on hover
  7070. *
  7071. * @type {number|undefined}
  7072. * @default undefined
  7073. * @product highcharts highmaps
  7074. * @apioption plotOptions.heatmap.marker.states.select.height
  7075. */
  7076. /**
  7077. * The number of pixels to increase the width of the
  7078. * selected point.
  7079. *
  7080. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7081. * 20px greater width and height on hover
  7082. *
  7083. * @type {number|undefined}
  7084. * @default undefined
  7085. * @product highcharts highmaps
  7086. * @apioption plotOptions.heatmap.marker.states.select.widthPlus
  7087. */
  7088. /**
  7089. * The number of pixels to increase the height of the
  7090. * selected point.
  7091. *
  7092. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7093. * 20px greater width and height on hover
  7094. *
  7095. * @type {number|undefined}
  7096. * @default undefined
  7097. * @product highcharts highmaps
  7098. * @apioption plotOptions.heatmap.marker.states.select.heightPlus
  7099. */
  7100. }
  7101. }
  7102. },
  7103. clip: true,
  7104. /** @ignore-option */
  7105. pointRange: null,
  7106. tooltip: {
  7107. pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
  7108. },
  7109. states: {
  7110. hover: {
  7111. /** @ignore-option */
  7112. halo: false,
  7113. /**
  7114. * How much to brighten the point on interaction. Requires the
  7115. * main color to be defined in hex or rgb(a) format.
  7116. *
  7117. * In styled mode, the hover brightening is by default replaced
  7118. * with a fill-opacity set in the `.highcharts-point:hover`
  7119. * rule.
  7120. */
  7121. brightness: 0.2
  7122. }
  7123. }
  7124. });
  7125. return HeatmapSeries;
  7126. }(ScatterSeries));
  7127. extend(HeatmapSeries.prototype, {
  7128. /**
  7129. * @private
  7130. */
  7131. alignDataLabel: ColumnSeries.prototype.alignDataLabel,
  7132. axisTypes: colorMapSeriesMixin.axisTypes,
  7133. colorAttribs: colorMapSeriesMixin.colorAttribs,
  7134. colorKey: colorMapSeriesMixin.colorKey,
  7135. directTouch: true,
  7136. /**
  7137. * @private
  7138. */
  7139. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  7140. /**
  7141. * @ignore
  7142. * @deprecated
  7143. */
  7144. getBox: noop,
  7145. getExtremesFromAll: true,
  7146. getSymbol: Series.prototype.getSymbol,
  7147. hasPointSpecificOptions: true,
  7148. parallelArrays: colorMapSeriesMixin.parallelArrays,
  7149. pointArrayMap: ['y', 'value'],
  7150. pointClass: HeatmapPoint,
  7151. trackerGroups: colorMapSeriesMixin.trackerGroups
  7152. });
  7153. SeriesRegistry.registerSeriesType('heatmap', HeatmapSeries);
  7154. /* *
  7155. *
  7156. * Default Export
  7157. *
  7158. * */
  7159. /* *
  7160. *
  7161. * API Declarations
  7162. *
  7163. * */
  7164. /**
  7165. * Heatmap series only. Padding between the points in the heatmap.
  7166. * @name Highcharts.Point#pointPadding
  7167. * @type {number|undefined}
  7168. */
  7169. /**
  7170. * Heatmap series only. The value of the point, resulting in a color
  7171. * controled by options as set in the colorAxis configuration.
  7172. * @name Highcharts.Point#value
  7173. * @type {number|null|undefined}
  7174. */
  7175. /* *
  7176. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  7177. */ /**
  7178. * Heatmap series only. Point padding for a single point.
  7179. * @name Highcharts.PointOptionsObject#pointPadding
  7180. * @type {number|undefined}
  7181. */ /**
  7182. * Heatmap series only. The value of the point, resulting in a color controled
  7183. * by options as set in the colorAxis configuration.
  7184. * @name Highcharts.PointOptionsObject#value
  7185. * @type {number|null|undefined}
  7186. */
  7187. ''; // detach doclets above
  7188. /* *
  7189. *
  7190. * API Options
  7191. *
  7192. * */
  7193. /**
  7194. * A `heatmap` series. If the [type](#series.heatmap.type) option is
  7195. * not specified, it is inherited from [chart.type](#chart.type).
  7196. *
  7197. * @productdesc {highcharts}
  7198. * Requires `modules/heatmap`.
  7199. *
  7200. * @extends series,plotOptions.heatmap
  7201. * @excluding cropThreshold, dataParser, dataURL, pointRange, stack,
  7202. * @product highcharts highmaps
  7203. * @apioption series.heatmap
  7204. */
  7205. /**
  7206. * An array of data points for the series. For the `heatmap` series
  7207. * type, points can be given in the following ways:
  7208. *
  7209. * 1. An array of arrays with 3 or 2 values. In this case, the values
  7210. * correspond to `x,y,value`. If the first value is a string, it is
  7211. * applied as the name of the point, and the `x` value is inferred.
  7212. * The `x` value can also be omitted, in which case the inner arrays
  7213. * should be of length 2\. Then the `x` value is automatically calculated,
  7214. * either starting at 0 and incremented by 1, or from `pointStart`
  7215. * and `pointInterval` given in the series options.
  7216. *
  7217. * ```js
  7218. * data: [
  7219. * [0, 9, 7],
  7220. * [1, 10, 4],
  7221. * [2, 6, 3]
  7222. * ]
  7223. * ```
  7224. *
  7225. * 2. An array of objects with named values. The following snippet shows only a
  7226. * few settings, see the complete options set below. If the total number of data
  7227. * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
  7228. * this option is not available.
  7229. *
  7230. * ```js
  7231. * data: [{
  7232. * x: 1,
  7233. * y: 3,
  7234. * value: 10,
  7235. * name: "Point2",
  7236. * color: "#00FF00"
  7237. * }, {
  7238. * x: 1,
  7239. * y: 7,
  7240. * value: 10,
  7241. * name: "Point1",
  7242. * color: "#FF00FF"
  7243. * }]
  7244. * ```
  7245. *
  7246. * @sample {highcharts} highcharts/chart/reflow-true/
  7247. * Numerical values
  7248. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  7249. * Arrays of numeric x and y
  7250. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  7251. * Arrays of datetime x and y
  7252. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  7253. * Arrays of point.name and y
  7254. * @sample {highcharts} highcharts/series/data-array-of-objects/
  7255. * Config objects
  7256. *
  7257. * @type {Array<Array<number>|*>}
  7258. * @extends series.line.data
  7259. * @product highcharts highmaps
  7260. * @apioption series.heatmap.data
  7261. */
  7262. /**
  7263. * The color of the point. In heat maps the point color is rarely set
  7264. * explicitly, as we use the color to denote the `value`. Options for
  7265. * this are set in the [colorAxis](#colorAxis) configuration.
  7266. *
  7267. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  7268. * @product highcharts highmaps
  7269. * @apioption series.heatmap.data.color
  7270. */
  7271. /**
  7272. * The value of the point, resulting in a color controled by options
  7273. * as set in the [colorAxis](#colorAxis) configuration.
  7274. *
  7275. * @type {number}
  7276. * @product highcharts highmaps
  7277. * @apioption series.heatmap.data.value
  7278. */
  7279. /**
  7280. * The x value of the point. For datetime axes,
  7281. * the X value is the timestamp in milliseconds since 1970.
  7282. *
  7283. * @type {number}
  7284. * @product highcharts highmaps
  7285. * @apioption series.heatmap.data.x
  7286. */
  7287. /**
  7288. * The y value of the point.
  7289. *
  7290. * @type {number}
  7291. * @product highcharts highmaps
  7292. * @apioption series.heatmap.data.y
  7293. */
  7294. /**
  7295. * Point padding for a single point.
  7296. *
  7297. * @sample maps/plotoptions/tilemap-pointpadding
  7298. * Point padding on tiles
  7299. *
  7300. * @type {number}
  7301. * @product highcharts highmaps
  7302. * @apioption series.heatmap.data.pointPadding
  7303. */
  7304. /**
  7305. * @excluding radius, enabledThreshold
  7306. * @product highcharts highmaps
  7307. * @since 8.1
  7308. * @apioption series.heatmap.data.marker
  7309. */
  7310. /**
  7311. * @excluding radius, enabledThreshold
  7312. * @product highcharts highmaps
  7313. * @since 8.1
  7314. * @apioption series.heatmap.marker
  7315. */
  7316. /**
  7317. * @excluding radius, radiusPlus
  7318. * @product highcharts highmaps
  7319. * @apioption series.heatmap.marker.states.hover
  7320. */
  7321. /**
  7322. * @excluding radius
  7323. * @product highcharts highmaps
  7324. * @apioption series.heatmap.marker.states.select
  7325. */
  7326. /**
  7327. * @excluding radius, radiusPlus
  7328. * @product highcharts highmaps
  7329. * @apioption series.heatmap.data.marker.states.hover
  7330. */
  7331. /**
  7332. * @excluding radius
  7333. * @product highcharts highmaps
  7334. * @apioption series.heatmap.data.marker.states.select
  7335. */
  7336. /**
  7337. * Set the marker's fixed width on hover state.
  7338. *
  7339. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  7340. * 5 pixels wider lineWidth on hover
  7341. *
  7342. * @type {number|undefined}
  7343. * @default 0
  7344. * @product highcharts highmaps
  7345. * @apioption series.heatmap.marker.states.hover.lineWidthPlus
  7346. */
  7347. /**
  7348. * Set the marker's fixed width on hover state.
  7349. *
  7350. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7351. * 70px fixed marker's width and height on hover
  7352. *
  7353. * @type {number|undefined}
  7354. * @default undefined
  7355. * @product highcharts highmaps
  7356. * @apioption series.heatmap.marker.states.hover.width
  7357. */
  7358. /**
  7359. * Set the marker's fixed height on hover state.
  7360. *
  7361. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7362. * 70px fixed marker's width and height on hover
  7363. *
  7364. * @type {number|undefined}
  7365. * @default undefined
  7366. * @product highcharts highmaps
  7367. * @apioption series.heatmap.marker.states.hover.height
  7368. */
  7369. /**
  7370. * The number of pixels to increase the width of the
  7371. * hovered point.
  7372. *
  7373. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7374. * One day
  7375. *
  7376. * @type {number|undefined}
  7377. * @default undefined
  7378. * @product highcharts highmaps
  7379. * @apioption series.heatmap.marker.states.hover.widthPlus
  7380. */
  7381. /**
  7382. * The number of pixels to increase the height of the
  7383. * hovered point.
  7384. *
  7385. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7386. * One day
  7387. *
  7388. * @type {number|undefined}
  7389. * @default undefined
  7390. * @product highcharts highmaps
  7391. * @apioption series.heatmap.marker.states.hover.heightPlus
  7392. */
  7393. /**
  7394. * The number of pixels to increase the width of the
  7395. * hovered point.
  7396. *
  7397. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7398. * One day
  7399. *
  7400. * @type {number|undefined}
  7401. * @default undefined
  7402. * @product highcharts highmaps
  7403. * @apioption series.heatmap.marker.states.select.widthPlus
  7404. */
  7405. /**
  7406. * The number of pixels to increase the height of the
  7407. * hovered point.
  7408. *
  7409. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7410. * One day
  7411. *
  7412. * @type {number|undefined}
  7413. * @default undefined
  7414. * @product highcharts highmaps
  7415. * @apioption series.heatmap.marker.states.select.heightPlus
  7416. */
  7417. /**
  7418. * Set the marker's fixed width on hover state.
  7419. *
  7420. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-linewidthplus
  7421. * 5 pixels wider lineWidth on hover
  7422. *
  7423. * @type {number|undefined}
  7424. * @default 0
  7425. * @product highcharts highmaps
  7426. * @apioption series.heatmap.data.marker.states.hover.lineWidthPlus
  7427. */
  7428. /**
  7429. * Set the marker's fixed width on hover state.
  7430. *
  7431. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7432. * 70px fixed marker's width and height on hover
  7433. *
  7434. * @type {number|undefined}
  7435. * @default undefined
  7436. * @product highcharts highmaps
  7437. * @apioption series.heatmap.data.marker.states.hover.width
  7438. */
  7439. /**
  7440. * Set the marker's fixed height on hover state.
  7441. *
  7442. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7443. * 70px fixed marker's width and height on hover
  7444. *
  7445. * @type {number|undefined}
  7446. * @default undefined
  7447. * @product highcharts highmaps
  7448. * @apioption series.heatmap.data.marker.states.hover.height
  7449. */
  7450. /**
  7451. * The number of pixels to increase the width of the
  7452. * hovered point.
  7453. *
  7454. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7455. * One day
  7456. *
  7457. * @type {number|undefined}
  7458. * @default undefined
  7459. * @product highcharts highstock
  7460. * @apioption series.heatmap.data.marker.states.hover.widthPlus
  7461. */
  7462. /**
  7463. * The number of pixels to increase the height of the
  7464. * hovered point.
  7465. *
  7466. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7467. * One day
  7468. *
  7469. * @type {number|undefined}
  7470. * @default undefined
  7471. * @product highcharts highstock
  7472. * @apioption series.heatmap.data.marker.states.hover.heightPlus
  7473. */
  7474. /**
  7475. * Set the marker's fixed width on select state.
  7476. *
  7477. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7478. * 70px fixed marker's width and height on hover
  7479. *
  7480. * @type {number|undefined}
  7481. * @default undefined
  7482. * @product highcharts highmaps
  7483. * @apioption series.heatmap.data.marker.states.select.width
  7484. */
  7485. /**
  7486. * Set the marker's fixed height on select state.
  7487. *
  7488. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-width
  7489. * 70px fixed marker's width and height on hover
  7490. *
  7491. * @type {number|undefined}
  7492. * @default undefined
  7493. * @product highcharts highmaps
  7494. * @apioption series.heatmap.data.marker.states.select.height
  7495. */
  7496. /**
  7497. * The number of pixels to increase the width of the
  7498. * hovered point.
  7499. *
  7500. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7501. * One day
  7502. *
  7503. * @type {number|undefined}
  7504. * @default undefined
  7505. * @product highcharts highstock
  7506. * @apioption series.heatmap.data.marker.states.select.widthPlus
  7507. */
  7508. /**
  7509. * The number of pixels to increase the height of the
  7510. * hovered point.
  7511. *
  7512. * @sample {highcharts} maps/plotoptions/heatmap-marker-states-hover-widthplus
  7513. * One day
  7514. *
  7515. * @type {number|undefined}
  7516. * @default undefined
  7517. * @product highcharts highstock
  7518. * @apioption series.heatmap.data.marker.states.select.heightPlus
  7519. */
  7520. ''; // adds doclets above to transpiled file
  7521. return HeatmapSeries;
  7522. });
  7523. _registerModule(_modules, 'Extensions/GeoJSON.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, H, U) {
  7524. /* *
  7525. *
  7526. * (c) 2010-2021 Torstein Honsi
  7527. *
  7528. * License: www.highcharts.com/license
  7529. *
  7530. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7531. *
  7532. * */
  7533. var win = H.win;
  7534. var error = U.error,
  7535. extend = U.extend,
  7536. format = U.format,
  7537. merge = U.merge,
  7538. wrap = U.wrap;
  7539. /**
  7540. * Represents the loose structure of a geographic JSON file.
  7541. *
  7542. * @interface Highcharts.GeoJSON
  7543. */ /**
  7544. * Full copyright note of the geographic data.
  7545. * @name Highcharts.GeoJSON#copyright
  7546. * @type {string|undefined}
  7547. */ /**
  7548. * Short copyright note of the geographic data suitable for watermarks.
  7549. * @name Highcharts.GeoJSON#copyrightShort
  7550. * @type {string|undefined}
  7551. */ /**
  7552. * Additional meta information based on the coordinate reference system.
  7553. * @name Highcharts.GeoJSON#crs
  7554. * @type {Highcharts.Dictionary<any>|undefined}
  7555. */ /**
  7556. * Data sets of geographic features.
  7557. * @name Highcharts.GeoJSON#features
  7558. * @type {Array<Highcharts.GeoJSONFeature>}
  7559. */ /**
  7560. * Map projections and transformations to be used when calculating between
  7561. * lat/lon and chart values. Required for lat/lon support on maps. Allows
  7562. * resizing, rotating, and moving portions of a map within its projected
  7563. * coordinate system while still retaining lat/lon support. If using lat/lon
  7564. * on a portion of the map that does not match a `hitZone`, the definition with
  7565. * the key `default` is used.
  7566. * @name Highcharts.GeoJSON#hc-transform
  7567. * @type {Highcharts.Dictionary<Highcharts.GeoJSONTranslation>|undefined}
  7568. */ /**
  7569. * Title of the geographic data.
  7570. * @name Highcharts.GeoJSON#title
  7571. * @type {string|undefined}
  7572. */ /**
  7573. * Type of the geographic data. Type of an optimized map collection is
  7574. * `FeatureCollection`.
  7575. * @name Highcharts.GeoJSON#type
  7576. * @type {string|undefined}
  7577. */ /**
  7578. * Version of the geographic data.
  7579. * @name Highcharts.GeoJSON#version
  7580. * @type {string|undefined}
  7581. */
  7582. /**
  7583. * Data set of a geographic feature.
  7584. * @interface Highcharts.GeoJSONFeature
  7585. * @extends Highcharts.Dictionary<*>
  7586. */ /**
  7587. * Data type of the geographic feature.
  7588. * @name Highcharts.GeoJSONFeature#type
  7589. * @type {string}
  7590. */
  7591. /**
  7592. * Describes the map projection and transformations applied to a portion of
  7593. * a map.
  7594. * @interface Highcharts.GeoJSONTranslation
  7595. */ /**
  7596. * The coordinate reference system used to generate this portion of the map.
  7597. * @name Highcharts.GeoJSONTranslation#crs
  7598. * @type {string}
  7599. */ /**
  7600. * Define the portion of the map that this defintion applies to. Defined as a
  7601. * GeoJSON polygon feature object, with `type` and `coordinates` properties.
  7602. * @name Highcharts.GeoJSONTranslation#hitZone
  7603. * @type {Highcharts.Dictionary<*>|undefined}
  7604. */ /**
  7605. * Property for internal use for maps generated by Highsoft.
  7606. * @name Highcharts.GeoJSONTranslation#jsonmarginX
  7607. * @type {number|undefined}
  7608. */ /**
  7609. * Property for internal use for maps generated by Highsoft.
  7610. * @name Highcharts.GeoJSONTranslation#jsonmarginY
  7611. * @type {number|undefined}
  7612. */ /**
  7613. * Property for internal use for maps generated by Highsoft.
  7614. * @name Highcharts.GeoJSONTranslation#jsonres
  7615. * @type {number|undefined}
  7616. */ /**
  7617. * Specifies clockwise rotation of the coordinates after the projection, but
  7618. * before scaling and panning. Defined in radians, relative to the coordinate
  7619. * system origin.
  7620. * @name Highcharts.GeoJSONTranslation#rotation
  7621. * @type {number|undefined}
  7622. */ /**
  7623. * The scaling factor applied to the projected coordinates.
  7624. * @name Highcharts.GeoJSONTranslation#scale
  7625. * @type {number|undefined}
  7626. */ /**
  7627. * Property for internal use for maps generated by Highsoft.
  7628. * @name Highcharts.GeoJSONTranslation#xoffset
  7629. * @type {number|undefined}
  7630. */ /**
  7631. * X offset of projected coordinates after scaling.
  7632. * @name Highcharts.GeoJSONTranslation#xpan
  7633. * @type {number|undefined}
  7634. */ /**
  7635. * Property for internal use for maps generated by Highsoft.
  7636. * @name Highcharts.GeoJSONTranslation#yoffset
  7637. * @type {number|undefined}
  7638. */ /**
  7639. * Y offset of projected coordinates after scaling.
  7640. * @name Highcharts.GeoJSONTranslation#ypan
  7641. * @type {number|undefined}
  7642. */
  7643. /**
  7644. * Result object of a map transformation.
  7645. *
  7646. * @interface Highcharts.MapCoordinateObject
  7647. */ /**
  7648. * X coordinate on the map.
  7649. * @name Highcharts.MapCoordinateObject#x
  7650. * @type {number}
  7651. */ /**
  7652. * Y coordinate on the map.
  7653. * @name Highcharts.MapCoordinateObject#y
  7654. * @type {number|null}
  7655. */
  7656. /**
  7657. * A latitude/longitude object.
  7658. *
  7659. * @interface Highcharts.MapLatLonObject
  7660. */ /**
  7661. * The latitude.
  7662. * @name Highcharts.MapLatLonObject#lat
  7663. * @type {number}
  7664. */ /**
  7665. * The longitude.
  7666. * @name Highcharts.MapLatLonObject#lon
  7667. * @type {number}
  7668. */
  7669. ''; // detach doclets above
  7670. /* eslint-disable no-invalid-this, valid-jsdoc */
  7671. /**
  7672. * Test for point in polygon. Polygon defined as array of [x,y] points.
  7673. * @private
  7674. */
  7675. function pointInPolygon(point, polygon) {
  7676. var i,
  7677. j,
  7678. rel1,
  7679. rel2,
  7680. c = false,
  7681. x = point.x,
  7682. y = point.y;
  7683. for (i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
  7684. rel1 = polygon[i][1] > y;
  7685. rel2 = polygon[j][1] > y;
  7686. if (rel1 !== rel2 &&
  7687. (x < (polygon[j][0] -
  7688. polygon[i][0]) * (y - polygon[i][1]) /
  7689. (polygon[j][1] - polygon[i][1]) +
  7690. polygon[i][0])) {
  7691. c = !c;
  7692. }
  7693. }
  7694. return c;
  7695. }
  7696. /**
  7697. * Highmaps only. Get point from latitude and longitude using specified
  7698. * transform definition.
  7699. *
  7700. * @requires modules/map
  7701. *
  7702. * @sample maps/series/latlon-transform/
  7703. * Use specific transformation for lat/lon
  7704. *
  7705. * @function Highcharts.Chart#transformFromLatLon
  7706. *
  7707. * @param {Highcharts.MapLatLonObject} latLon
  7708. * A latitude/longitude object.
  7709. *
  7710. * @param {*} transform
  7711. * The transform definition to use as explained in the
  7712. * {@link https://www.highcharts.com/docs/maps/latlon|documentation}.
  7713. *
  7714. * @return {Highcharts.MapCoordinateObject}
  7715. * An object with `x` and `y` properties.
  7716. */
  7717. Chart.prototype.transformFromLatLon = function (latLon, transform) {
  7718. /**
  7719. * Allows to manually load the proj4 library from Highcharts options
  7720. * instead of the `window`.
  7721. * In case of loading the library from a `script` tag,
  7722. * this option is not needed, it will be loaded from there by default.
  7723. *
  7724. * @type {function}
  7725. * @product highmaps
  7726. * @apioption chart.proj4
  7727. */
  7728. var _a;
  7729. var proj4 = (((_a = this.userOptions.chart) === null || _a === void 0 ? void 0 : _a.proj4) || win.proj4);
  7730. if (!proj4) {
  7731. error(21, false, this);
  7732. return {
  7733. x: 0,
  7734. y: null
  7735. };
  7736. }
  7737. var projected = proj4(transform.crs,
  7738. [latLon.lon,
  7739. latLon.lat]),
  7740. cosAngle = transform.cosAngle ||
  7741. (transform.rotation && Math.cos(transform.rotation)),
  7742. sinAngle = transform.sinAngle ||
  7743. (transform.rotation && Math.sin(transform.rotation)),
  7744. rotated = transform.rotation ? [
  7745. projected[0] * cosAngle + projected[1] * sinAngle,
  7746. -projected[0] * sinAngle + projected[1] * cosAngle
  7747. ] : projected;
  7748. return {
  7749. x: ((rotated[0] - (transform.xoffset || 0)) * (transform.scale || 1) +
  7750. (transform.xpan || 0)) * (transform.jsonres || 1) +
  7751. (transform.jsonmarginX || 0),
  7752. y: (((transform.yoffset || 0) - rotated[1]) * (transform.scale || 1) +
  7753. (transform.ypan || 0)) * (transform.jsonres || 1) -
  7754. (transform.jsonmarginY || 0)
  7755. };
  7756. };
  7757. /**
  7758. * Highmaps only. Get latLon from point using specified transform definition.
  7759. * The method returns an object with the numeric properties `lat` and `lon`.
  7760. *
  7761. * @requires modules/map
  7762. *
  7763. * @sample maps/series/latlon-transform/
  7764. * Use specific transformation for lat/lon
  7765. *
  7766. * @function Highcharts.Chart#transformToLatLon
  7767. *
  7768. * @param {Highcharts.Point|Highcharts.MapCoordinateObject} point
  7769. * A `Point` instance, or any object containing the properties `x` and
  7770. * `y` with numeric values.
  7771. *
  7772. * @param {*} transform
  7773. * The transform definition to use as explained in the
  7774. * {@link https://www.highcharts.com/docs/maps/latlon|documentation}.
  7775. *
  7776. * @return {Highcharts.MapLatLonObject|undefined}
  7777. * An object with `lat` and `lon` properties.
  7778. */
  7779. Chart.prototype.transformToLatLon = function (point, transform) {
  7780. if (typeof win.proj4 === 'undefined') {
  7781. error(21, false, this);
  7782. return;
  7783. }
  7784. var normalized = {
  7785. x: ((point.x -
  7786. (transform.jsonmarginX || 0)) / (transform.jsonres || 1) -
  7787. (transform.xpan || 0)) / (transform.scale || 1) +
  7788. (transform.xoffset || 0),
  7789. y: ((-point.y - (transform.jsonmarginY || 0)) / (transform.jsonres || 1) +
  7790. (transform.ypan || 0)) / (transform.scale || 1) +
  7791. (transform.yoffset || 0)
  7792. },
  7793. cosAngle = transform.cosAngle ||
  7794. (transform.rotation && Math.cos(transform.rotation)),
  7795. sinAngle = transform.sinAngle ||
  7796. (transform.rotation && Math.sin(transform.rotation)),
  7797. // Note: Inverted sinAngle to reverse rotation direction
  7798. projected = win.proj4(transform.crs, 'WGS84',
  7799. transform.rotation ? {
  7800. x: normalized.x * cosAngle + normalized.y * -sinAngle,
  7801. y: normalized.x * sinAngle + normalized.y * cosAngle
  7802. } : normalized);
  7803. return { lat: projected.y, lon: projected.x };
  7804. };
  7805. /**
  7806. * Highmaps only. Calculate latitude/longitude values for a point. Returns an
  7807. * object with the numeric properties `lat` and `lon`.
  7808. *
  7809. * @requires modules/map
  7810. *
  7811. * @sample maps/demo/latlon-advanced/
  7812. * Advanced lat/lon demo
  7813. *
  7814. * @function Highcharts.Chart#fromPointToLatLon
  7815. *
  7816. * @param {Highcharts.Point|Highcharts.MapCoordinateObject} point
  7817. * A `Point` instance or anything containing `x` and `y` properties with
  7818. * numeric values.
  7819. *
  7820. * @return {Highcharts.MapLatLonObject|undefined}
  7821. * An object with `lat` and `lon` properties.
  7822. */
  7823. Chart.prototype.fromPointToLatLon = function (point) {
  7824. var transforms = this.mapTransforms,
  7825. transform;
  7826. if (!transforms) {
  7827. error(22, false, this);
  7828. return;
  7829. }
  7830. for (transform in transforms) {
  7831. if (Object.hasOwnProperty.call(transforms, transform) &&
  7832. transforms[transform].hitZone &&
  7833. pointInPolygon({ x: point.x, y: -point.y }, transforms[transform].hitZone.coordinates[0])) {
  7834. return this.transformToLatLon(point, transforms[transform]);
  7835. }
  7836. }
  7837. return this.transformToLatLon(point, transforms['default'] // eslint-disable-line dot-notation
  7838. );
  7839. };
  7840. /**
  7841. * Highmaps only. Get chart coordinates from latitude/longitude. Returns an
  7842. * object with x and y values corresponding to the `xAxis` and `yAxis`.
  7843. *
  7844. * @requires modules/map
  7845. *
  7846. * @sample maps/series/latlon-to-point/
  7847. * Find a point from lat/lon
  7848. *
  7849. * @function Highcharts.Chart#fromLatLonToPoint
  7850. *
  7851. * @param {Highcharts.MapLatLonObject} latLon
  7852. * Coordinates.
  7853. *
  7854. * @return {Highcharts.MapCoordinateObject}
  7855. * X and Y coordinates in terms of chart axis values.
  7856. */
  7857. Chart.prototype.fromLatLonToPoint = function (latLon) {
  7858. var transforms = this.mapTransforms,
  7859. transform,
  7860. coords;
  7861. if (!transforms) {
  7862. error(22, false, this);
  7863. return {
  7864. x: 0,
  7865. y: null
  7866. };
  7867. }
  7868. for (transform in transforms) {
  7869. if (Object.hasOwnProperty.call(transforms, transform) &&
  7870. transforms[transform].hitZone) {
  7871. coords = this.transformFromLatLon(latLon, transforms[transform]);
  7872. if (pointInPolygon({ x: coords.x, y: -coords.y }, transforms[transform].hitZone.coordinates[0])) {
  7873. return coords;
  7874. }
  7875. }
  7876. }
  7877. return this.transformFromLatLon(latLon, transforms['default'] // eslint-disable-line dot-notation
  7878. );
  7879. };
  7880. /**
  7881. * Highmaps only. Restructure a GeoJSON object in preparation to be read
  7882. * directly by the
  7883. * {@link https://api.highcharts.com/highmaps/plotOptions.series.mapData|series.mapData}
  7884. * option. The GeoJSON will be broken down to fit a specific Highcharts type,
  7885. * either `map`, `mapline` or `mappoint`. Meta data in GeoJSON's properties
  7886. * object will be copied directly over to {@link Point.properties} in Highmaps.
  7887. *
  7888. * @requires modules/map
  7889. *
  7890. * @sample maps/demo/geojson/
  7891. * Simple areas
  7892. * @sample maps/demo/geojson-multiple-types/
  7893. * Multiple types
  7894. *
  7895. * @function Highcharts.geojson
  7896. *
  7897. * @param {Highcharts.GeoJSON} geojson
  7898. * The GeoJSON structure to parse, represented as a JavaScript object
  7899. * rather than a JSON string.
  7900. *
  7901. * @param {string} [hType=map]
  7902. * The Highmaps series type to prepare for. Setting "map" will return
  7903. * GeoJSON polygons and multipolygons. Setting "mapline" will return
  7904. * GeoJSON linestrings and multilinestrings. Setting "mappoint" will
  7905. * return GeoJSON points and multipoints.
  7906. *
  7907. * @return {Array<*>}
  7908. * An object ready for the `mapData` option.
  7909. */
  7910. H.geojson = function (geojson, hType, series) {
  7911. var mapData = [],
  7912. path = [],
  7913. polygonToPath = function (polygon) {
  7914. polygon.forEach(function (point,
  7915. i) {
  7916. if (i === 0) {
  7917. path.push(['M',
  7918. point[0], -point[1]]);
  7919. }
  7920. else {
  7921. path.push(['L', point[0], -point[1]]);
  7922. }
  7923. });
  7924. };
  7925. hType = hType || 'map';
  7926. geojson.features.forEach(function (feature) {
  7927. var geometry = feature.geometry,
  7928. type = geometry.type,
  7929. coordinates = geometry.coordinates,
  7930. properties = feature.properties,
  7931. point;
  7932. path = [];
  7933. if (hType === 'map' || hType === 'mapbubble') {
  7934. if (type === 'Polygon') {
  7935. coordinates.forEach(polygonToPath);
  7936. path.push(['Z']);
  7937. }
  7938. else if (type === 'MultiPolygon') {
  7939. coordinates.forEach(function (items) {
  7940. items.forEach(polygonToPath);
  7941. });
  7942. path.push(['Z']);
  7943. }
  7944. if (path.length) {
  7945. point = { path: path };
  7946. }
  7947. }
  7948. else if (hType === 'mapline') {
  7949. if (type === 'LineString') {
  7950. polygonToPath(coordinates);
  7951. }
  7952. else if (type === 'MultiLineString') {
  7953. coordinates.forEach(polygonToPath);
  7954. }
  7955. if (path.length) {
  7956. point = { path: path };
  7957. }
  7958. }
  7959. else if (hType === 'mappoint') {
  7960. if (type === 'Point') {
  7961. point = {
  7962. x: coordinates[0],
  7963. y: -coordinates[1]
  7964. };
  7965. }
  7966. }
  7967. if (point) {
  7968. mapData.push(extend(point, {
  7969. name: properties.name || properties.NAME,
  7970. /**
  7971. * In Highmaps, when data is loaded from GeoJSON, the GeoJSON
  7972. * item's properies are copied over here.
  7973. *
  7974. * @requires modules/map
  7975. * @name Highcharts.Point#properties
  7976. * @type {*}
  7977. */
  7978. properties: properties
  7979. }));
  7980. }
  7981. });
  7982. // Create a credits text that includes map source, to be picked up in
  7983. // Chart.addCredits
  7984. if (series && geojson.copyrightShort) {
  7985. series.chart.mapCredits = format(series.chart.options.credits.mapText, { geojson: geojson });
  7986. series.chart.mapCreditsFull = format(series.chart.options.credits.mapTextFull, { geojson: geojson });
  7987. }
  7988. return mapData;
  7989. };
  7990. // Override addCredits to include map source by default
  7991. wrap(Chart.prototype, 'addCredits', function (proceed, credits) {
  7992. credits = merge(true, this.options.credits, credits);
  7993. // Disable credits link if map credits enabled. This to allow for in-text
  7994. // anchors.
  7995. if (this.mapCredits) {
  7996. credits.href = null;
  7997. }
  7998. proceed.call(this, credits);
  7999. // Add full map credits to hover
  8000. if (this.credits && this.mapCreditsFull) {
  8001. this.credits.attr({
  8002. title: this.mapCreditsFull
  8003. });
  8004. }
  8005. });
  8006. });
  8007. _registerModule(_modules, 'masters/modules/map.src.js', [], function () {
  8008. });
  8009. }));