map.src.js 338 KB

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