map.src.js 304 KB

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