map.src.js 338 KB

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