highcharts-more.src.js 455 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572
  1. /**
  2. * @license Highcharts JS v8.2.2 (2020-10-22)
  3. *
  4. * (c) 2009-2018 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = factory;
  13. } else if (typeof define === 'function' && define.amd) {
  14. define('highcharts/highcharts-more', ['highcharts'], function (Highcharts) {
  15. factory(Highcharts);
  16. factory.Highcharts = Highcharts;
  17. return factory;
  18. });
  19. } else {
  20. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  21. }
  22. }(function (Highcharts) {
  23. var _modules = Highcharts ? Highcharts._modules : {};
  24. function _registerModule(obj, path, args, fn) {
  25. if (!obj.hasOwnProperty(path)) {
  26. obj[path] = fn.apply(null, args);
  27. }
  28. }
  29. _registerModule(_modules, 'Extensions/Pane.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js'], _modules['Mixins/CenteredSeries.js']], function (Chart, H, Pointer, U, centeredSeriesMixin) {
  30. /* *
  31. *
  32. * (c) 2010-2020 Torstein Honsi
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var addEvent = U.addEvent,
  40. extend = U.extend,
  41. merge = U.merge,
  42. pick = U.pick,
  43. splat = U.splat;
  44. /**
  45. * @typedef {"arc"|"circle"|"solid"} Highcharts.PaneBackgroundShapeValue
  46. */
  47. /* eslint-disable no-invalid-this, valid-jsdoc */
  48. Chart.prototype.collectionsWithUpdate.push('pane');
  49. /**
  50. * The Pane object allows options that are common to a set of X and Y axes.
  51. *
  52. * In the future, this can be extended to basic Highcharts and Highstock.
  53. *
  54. * @private
  55. * @class
  56. * @name Highcharts.Pane
  57. * @param {Highcharts.PaneOptions} options
  58. * @param {Highcharts.Chart} chart
  59. */
  60. var Pane = /** @class */ (function () {
  61. function Pane(options, chart) {
  62. this.background = void 0;
  63. this.center = void 0;
  64. this.chart = void 0;
  65. this.options = void 0;
  66. this.coll = 'pane'; // Member of chart.pane
  67. /**
  68. * The pane serves as a container for axes and backgrounds for circular
  69. * gauges and polar charts.
  70. *
  71. * @since 2.3.0
  72. * @product highcharts
  73. * @requires highcharts-more
  74. * @optionparent pane
  75. */
  76. this.defaultOptions = {
  77. /**
  78. * The end angle of the polar X axis or gauge value axis, given in
  79. * degrees where 0 is north. Defaults to [startAngle](#pane.startAngle)
  80. * + 360.
  81. *
  82. * @sample {highcharts} highcharts/demo/gauge-vu-meter/
  83. * VU-meter with custom start and end angle
  84. *
  85. * @type {number}
  86. * @since 2.3.0
  87. * @product highcharts
  88. * @apioption pane.endAngle
  89. */
  90. /**
  91. * The center of a polar chart or angular gauge, given as an array
  92. * of [x, y] positions. Positions can be given as integers that
  93. * transform to pixels, or as percentages of the plot area size.
  94. *
  95. * @sample {highcharts} highcharts/demo/gauge-vu-meter/
  96. * Two gauges with different center
  97. *
  98. * @type {Array<string|number>}
  99. * @default ["50%", "50%"]
  100. * @since 2.3.0
  101. * @product highcharts
  102. */
  103. center: ['50%', '50%'],
  104. /**
  105. * The size of the pane, either as a number defining pixels, or a
  106. * percentage defining a percentage of the available plot area (the
  107. * smallest of the plot height or plot width).
  108. *
  109. * @sample {highcharts} highcharts/demo/gauge-vu-meter/
  110. * Smaller size
  111. *
  112. * @type {number|string}
  113. * @product highcharts
  114. */
  115. size: '85%',
  116. /**
  117. * The inner size of the pane, either as a number defining pixels, or a
  118. * percentage defining a percentage of the pane's size.
  119. *
  120. * @sample {highcharts} highcharts/series-polar/column-inverted-inner
  121. * The inner size set to 20%
  122. *
  123. * @type {number|string}
  124. * @product highcharts
  125. */
  126. innerSize: '0%',
  127. /**
  128. * The start angle of the polar X axis or gauge axis, given in degrees
  129. * where 0 is north. Defaults to 0.
  130. *
  131. * @sample {highcharts} highcharts/demo/gauge-vu-meter/
  132. * VU-meter with custom start and end angle
  133. *
  134. * @since 2.3.0
  135. * @product highcharts
  136. */
  137. startAngle: 0
  138. };
  139. /**
  140. * An array of background items for the pane.
  141. *
  142. * @sample {highcharts} highcharts/demo/gauge-speedometer/
  143. * Speedometer gauge with multiple backgrounds
  144. *
  145. * @type {Array<*>}
  146. * @optionparent pane.background
  147. */
  148. this.defaultBackgroundOptions = {
  149. /**
  150. * The class name for this background.
  151. *
  152. * @sample {highcharts} highcharts/css/pane/
  153. * Panes styled by CSS
  154. * @sample {highstock} highcharts/css/pane/
  155. * Panes styled by CSS
  156. * @sample {highmaps} highcharts/css/pane/
  157. * Panes styled by CSS
  158. *
  159. * @type {string}
  160. * @default highcharts-pane
  161. * @since 5.0.0
  162. * @apioption pane.background.className
  163. */
  164. /**
  165. * The shape of the pane background. When `solid`, the background
  166. * is circular. When `arc`, the background extends only from the min
  167. * to the max of the value axis.
  168. *
  169. * @type {Highcharts.PaneBackgroundShapeValue}
  170. * @since 2.3.0
  171. * @product highcharts
  172. */
  173. shape: 'circle',
  174. /**
  175. * The pixel border width of the pane background.
  176. *
  177. * @since 2.3.0
  178. * @product highcharts
  179. */
  180. borderWidth: 1,
  181. /**
  182. * The pane background border color.
  183. *
  184. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  185. * @since 2.3.0
  186. * @product highcharts
  187. */
  188. borderColor: '#cccccc',
  189. /**
  190. * The background color or gradient for the pane.
  191. *
  192. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  193. * @default { linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 }, stops: [[0, #ffffff], [1, #e6e6e6]] }
  194. * @since 2.3.0
  195. * @product highcharts
  196. */
  197. backgroundColor: {
  198. /** @ignore-option */
  199. linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
  200. /** @ignore-option */
  201. stops: [
  202. [0, '#ffffff'],
  203. [1, '#e6e6e6']
  204. ]
  205. },
  206. /** @ignore-option */
  207. from: -Number.MAX_VALUE,
  208. /**
  209. * The inner radius of the pane background. Can be either numeric
  210. * (pixels) or a percentage string.
  211. *
  212. * @type {number|string}
  213. * @since 2.3.0
  214. * @product highcharts
  215. */
  216. innerRadius: 0,
  217. /** @ignore-option */
  218. to: Number.MAX_VALUE,
  219. /**
  220. * The outer radius of the circular pane background. Can be either
  221. * numeric (pixels) or a percentage string.
  222. *
  223. * @type {number|string}
  224. * @since 2.3.0
  225. * @product highcharts
  226. */
  227. outerRadius: '105%'
  228. };
  229. this.init(options, chart);
  230. }
  231. /**
  232. * Initialize the Pane object
  233. *
  234. * @private
  235. * @function Highcharts.Pane#init
  236. *
  237. * @param {Highcharts.PaneOptions} options
  238. *
  239. * @param {Highcharts.Chart} chart
  240. */
  241. Pane.prototype.init = function (options, chart) {
  242. this.chart = chart;
  243. this.background = [];
  244. chart.pane.push(this);
  245. this.setOptions(options);
  246. };
  247. /**
  248. * @private
  249. * @function Highcharts.Pane#setOptions
  250. *
  251. * @param {Highcharts.PaneOptions} options
  252. */
  253. Pane.prototype.setOptions = function (options) {
  254. // Set options. Angular charts have a default background (#3318)
  255. this.options = options = merge(this.defaultOptions, this.chart.angular ? { background: {} } : void 0, options);
  256. };
  257. /**
  258. * Render the pane with its backgrounds.
  259. *
  260. * @private
  261. * @function Highcharts.Pane#render
  262. */
  263. Pane.prototype.render = function () {
  264. var options = this.options,
  265. backgroundOption = this.options.background,
  266. renderer = this.chart.renderer,
  267. len,
  268. i;
  269. if (!this.group) {
  270. this.group = renderer.g('pane-group')
  271. .attr({ zIndex: options.zIndex || 0 })
  272. .add();
  273. }
  274. this.updateCenter();
  275. // Render the backgrounds
  276. if (backgroundOption) {
  277. backgroundOption = splat(backgroundOption);
  278. len = Math.max(backgroundOption.length, this.background.length || 0);
  279. for (i = 0; i < len; i++) {
  280. // #6641 - if axis exists, chart is circular and apply
  281. // background
  282. if (backgroundOption[i] && this.axis) {
  283. this.renderBackground(merge(this.defaultBackgroundOptions, backgroundOption[i]), i);
  284. }
  285. else if (this.background[i]) {
  286. this.background[i] = this.background[i].destroy();
  287. this.background.splice(i, 1);
  288. }
  289. }
  290. }
  291. };
  292. /**
  293. * Render an individual pane background.
  294. *
  295. * @private
  296. * @function Highcharts.Pane#renderBackground
  297. *
  298. * @param {Highcharts.PaneBackgroundOptions} backgroundOptions
  299. * Background options
  300. *
  301. * @param {number} i
  302. * The index of the background in this.backgrounds
  303. */
  304. Pane.prototype.renderBackground = function (backgroundOptions, i) {
  305. var method = 'animate',
  306. attribs = {
  307. 'class': 'highcharts-pane ' + (backgroundOptions.className || '')
  308. };
  309. if (!this.chart.styledMode) {
  310. extend(attribs, {
  311. 'fill': backgroundOptions.backgroundColor,
  312. 'stroke': backgroundOptions.borderColor,
  313. 'stroke-width': backgroundOptions.borderWidth
  314. });
  315. }
  316. if (!this.background[i]) {
  317. this.background[i] = this.chart.renderer
  318. .path()
  319. .add(this.group);
  320. method = 'attr';
  321. }
  322. this.background[i][method]({
  323. 'd': this.axis.getPlotBandPath(backgroundOptions.from, backgroundOptions.to, backgroundOptions)
  324. }).attr(attribs);
  325. };
  326. /**
  327. * Gets the center for the pane and its axis.
  328. *
  329. * @private
  330. * @function Highcharts.Pane#updateCenter
  331. * @param {Highcharts.Axis} [axis]
  332. * @return {void}
  333. */
  334. Pane.prototype.updateCenter = function (axis) {
  335. this.center = (axis ||
  336. this.axis ||
  337. {}).center = centeredSeriesMixin.getCenter.call(this);
  338. };
  339. /**
  340. * Destroy the pane item
  341. *
  342. * @ignore
  343. * @private
  344. * @function Highcharts.Pane#destroy
  345. * /
  346. destroy: function () {
  347. erase(this.chart.pane, this);
  348. this.background.forEach(function (background) {
  349. background.destroy();
  350. });
  351. this.background.length = 0;
  352. this.group = this.group.destroy();
  353. },
  354. */
  355. /**
  356. * Update the pane item with new options
  357. *
  358. * @private
  359. * @function Highcharts.Pane#update
  360. * @param {Highcharts.PaneOptions} options
  361. * New pane options
  362. * @param {boolean} [redraw]
  363. * @return {void}
  364. */
  365. Pane.prototype.update = function (options, redraw) {
  366. merge(true, this.options, options);
  367. merge(true, this.chart.options.pane, options); // #9917
  368. this.setOptions(this.options);
  369. this.render();
  370. this.chart.axes.forEach(function (axis) {
  371. if (axis.pane === this) {
  372. axis.pane = null;
  373. axis.update({}, redraw);
  374. }
  375. }, this);
  376. };
  377. return Pane;
  378. }());
  379. /**
  380. * Check whether element is inside or outside pane.
  381. * @private
  382. * @param {number} x Element's x coordinate
  383. * @param {number} y Element's y coordinate
  384. * @param {Array<number>} center Pane's center (x, y) and diameter
  385. * @return {boolean}
  386. */
  387. function isInsidePane(x, y, center) {
  388. return Math.sqrt(Math.pow(x - center[0], 2) + Math.pow(y - center[1], 2)) <= center[2] / 2;
  389. }
  390. Chart.prototype.getHoverPane = function (eventArgs) {
  391. var chart = this;
  392. var hoverPane;
  393. if (eventArgs) {
  394. chart.pane.forEach(function (pane) {
  395. var plotX = eventArgs.chartX - chart.plotLeft,
  396. plotY = eventArgs.chartY - chart.plotTop,
  397. x = chart.inverted ? plotY : plotX,
  398. y = chart.inverted ? plotX : plotY;
  399. if (isInsidePane(x, y, pane.center)) {
  400. hoverPane = pane;
  401. }
  402. });
  403. }
  404. return hoverPane;
  405. };
  406. addEvent(Chart, 'afterIsInsidePlot', function (e) {
  407. var chart = this;
  408. if (chart.polar) {
  409. e.isInsidePlot = chart.pane.some(function (pane) { return isInsidePane(e.x, e.y, pane.center); });
  410. }
  411. });
  412. addEvent(Pointer, 'beforeGetHoverData', function (eventArgs) {
  413. var chart = this.chart;
  414. if (chart.polar) {
  415. // Find pane we are currently hovering over.
  416. chart.hoverPane = chart.getHoverPane(eventArgs);
  417. // Edit filter method to handle polar
  418. eventArgs.filter = function (s) {
  419. return (s.visible &&
  420. !(!eventArgs.shared && s.directTouch) && // #3821
  421. pick(s.options.enableMouseTracking, true) &&
  422. (!chart.hoverPane || s.xAxis.pane === chart.hoverPane));
  423. };
  424. }
  425. });
  426. addEvent(Pointer, 'afterGetHoverData', function (eventArgs) {
  427. var chart = this.chart;
  428. if (eventArgs.hoverPoint &&
  429. eventArgs.hoverPoint.plotX &&
  430. eventArgs.hoverPoint.plotY &&
  431. chart.hoverPane &&
  432. !isInsidePane(eventArgs.hoverPoint.plotX, eventArgs.hoverPoint.plotY, chart.hoverPane.center)) {
  433. eventArgs.hoverPoint = void 0;
  434. }
  435. });
  436. H.Pane = Pane;
  437. return H.Pane;
  438. });
  439. _registerModule(_modules, 'Core/Axis/HiddenAxis.js', [], function () {
  440. /* *
  441. *
  442. * (c) 2010-2020 Torstein Honsi
  443. *
  444. * License: www.highcharts.com/license
  445. *
  446. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  447. *
  448. * */
  449. /**
  450. * @private
  451. * @class
  452. */
  453. var HiddenAxis = /** @class */ (function () {
  454. function HiddenAxis() {
  455. }
  456. /**
  457. * Augments methods for the x axis in order to hide it completely. Used for
  458. * the X axis in gauges
  459. *
  460. * @private
  461. *
  462. * @param {Highcharts.Axis} axis
  463. * Radial axis to augment.
  464. */
  465. HiddenAxis.init = function (axis) {
  466. axis.getOffset = function () { };
  467. axis.redraw = function () {
  468. this.isDirty = false; // prevent setting Y axis dirty
  469. };
  470. axis.render = function () {
  471. this.isDirty = false; // prevent setting Y axis dirty
  472. };
  473. axis.createLabelCollector = function () {
  474. return function () {
  475. return;
  476. };
  477. };
  478. axis.setScale = function () { };
  479. axis.setCategories = function () { };
  480. axis.setTitle = function () { };
  481. axis.isHidden = true;
  482. };
  483. return HiddenAxis;
  484. }());
  485. return HiddenAxis;
  486. });
  487. _registerModule(_modules, 'Core/Axis/RadialAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Axis/HiddenAxis.js'], _modules['Core/Utilities.js']], function (Axis, Tick, HiddenAxis, U) {
  488. /* *
  489. *
  490. * (c) 2010-2020 Torstein Honsi
  491. *
  492. * License: www.highcharts.com/license
  493. *
  494. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  495. *
  496. * */
  497. var addEvent = U.addEvent,
  498. correctFloat = U.correctFloat,
  499. defined = U.defined,
  500. extend = U.extend,
  501. fireEvent = U.fireEvent,
  502. isNumber = U.isNumber,
  503. merge = U.merge,
  504. pick = U.pick,
  505. pInt = U.pInt,
  506. relativeLength = U.relativeLength,
  507. wrap = U.wrap;
  508. /**
  509. * @private
  510. * @class
  511. */
  512. var RadialAxis = /** @class */ (function () {
  513. function RadialAxis() {
  514. }
  515. /* *
  516. *
  517. * Static Functions
  518. *
  519. * */
  520. RadialAxis.init = function (axis) {
  521. var axisProto = Axis.prototype;
  522. // Merge and set options.
  523. axis.setOptions = function (userOptions) {
  524. var options = this.options = merge(axis.constructor.defaultOptions,
  525. this.defaultPolarOptions,
  526. userOptions);
  527. // Make sure the plotBands array is instanciated for each Axis
  528. // (#2649)
  529. if (!options.plotBands) {
  530. options.plotBands = [];
  531. }
  532. fireEvent(this, 'afterSetOptions');
  533. };
  534. // Wrap the getOffset method to return zero offset for title or labels
  535. // in a radial axis.
  536. axis.getOffset = function () {
  537. // Call the Axis prototype method (the method we're in now is on the
  538. // instance)
  539. axisProto.getOffset.call(this);
  540. // Title or label offsets are not counted
  541. this.chart.axisOffset[this.side] = 0;
  542. };
  543. /**
  544. * Get the path for the axis line. This method is also referenced in the
  545. * getPlotLinePath method.
  546. *
  547. * @private
  548. *
  549. * @param {number} _lineWidth
  550. * Line width is not used.
  551. *
  552. * @param {number} [radius]
  553. * Radius of radial path.
  554. *
  555. * @param {number} [innerRadius]
  556. * Inner radius of radial path.
  557. *
  558. * @return {RadialAxisPath}
  559. */
  560. axis.getLinePath = function (_lineWidth, radius, innerRadius) {
  561. var center = this.pane.center,
  562. end,
  563. chart = this.chart,
  564. r = pick(radius,
  565. center[2] / 2 - this.offset),
  566. path;
  567. if (typeof innerRadius === 'undefined') {
  568. innerRadius = this.horiz ? 0 : this.center && -this.center[3] / 2;
  569. }
  570. // In case when innerSize of pane is set, it must be included
  571. if (innerRadius) {
  572. r += innerRadius;
  573. }
  574. if (this.isCircular || typeof radius !== 'undefined') {
  575. path = this.chart.renderer.symbols.arc(this.left + center[0], this.top + center[1], r, r, {
  576. start: this.startAngleRad,
  577. end: this.endAngleRad,
  578. open: true,
  579. innerR: 0
  580. });
  581. // Bounds used to position the plotLine label next to the line
  582. // (#7117)
  583. path.xBounds = [this.left + center[0]];
  584. path.yBounds = [this.top + center[1] - r];
  585. }
  586. else {
  587. end = this.postTranslate(this.angleRad, r);
  588. path = [
  589. ['M', this.center[0] + chart.plotLeft, this.center[1] + chart.plotTop],
  590. ['L', end.x, end.y]
  591. ];
  592. }
  593. return path;
  594. };
  595. /**
  596. * Override setAxisTranslation by setting the translation to the
  597. * difference in rotation. This allows the translate method to return
  598. * angle for any given value.
  599. *
  600. * @private
  601. */
  602. axis.setAxisTranslation = function () {
  603. // Call uber method
  604. axisProto.setAxisTranslation.call(this);
  605. // Set transA and minPixelPadding
  606. if (this.center) { // it's not defined the first time
  607. if (this.isCircular) {
  608. this.transA = (this.endAngleRad - this.startAngleRad) /
  609. ((this.max - this.min) || 1);
  610. }
  611. else {
  612. // The transA here is the length of the axis, so in case
  613. // of inner radius, the length must be decreased by it
  614. this.transA = ((this.center[2] - this.center[3]) / 2) /
  615. ((this.max - this.min) || 1);
  616. }
  617. if (this.isXAxis) {
  618. this.minPixelPadding = this.transA * this.minPointOffset;
  619. }
  620. else {
  621. // This is a workaround for regression #2593, but categories
  622. // still don't position correctly.
  623. this.minPixelPadding = 0;
  624. }
  625. }
  626. };
  627. /**
  628. * In case of auto connect, add one closestPointRange to the max value
  629. * right before tickPositions are computed, so that ticks will extend
  630. * passed the real max.
  631. * @private
  632. */
  633. axis.beforeSetTickPositions = function () {
  634. // If autoConnect is true, polygonal grid lines are connected, and
  635. // one closestPointRange is added to the X axis to prevent the last
  636. // point from overlapping the first.
  637. this.autoConnect = (this.isCircular &&
  638. typeof pick(this.userMax, this.options.max) === 'undefined' &&
  639. correctFloat(this.endAngleRad - this.startAngleRad) ===
  640. correctFloat(2 * Math.PI));
  641. // This will lead to add an extra tick to xAxis in order to display
  642. // a correct range on inverted polar
  643. if (!this.isCircular && this.chart.inverted) {
  644. this.max++;
  645. }
  646. if (this.autoConnect) {
  647. this.max += ((this.categories && 1) ||
  648. this.pointRange ||
  649. this.closestPointRange ||
  650. 0); // #1197, #2260
  651. }
  652. };
  653. /**
  654. * Override the setAxisSize method to use the arc's circumference as
  655. * length. This allows tickPixelInterval to apply to pixel lengths along
  656. * the perimeter.
  657. * @private
  658. */
  659. axis.setAxisSize = function () {
  660. var center,
  661. start;
  662. axisProto.setAxisSize.call(this);
  663. if (this.isRadial) {
  664. // Set the center array
  665. this.pane.updateCenter(this);
  666. // In case when the innerSize is set in a polar chart, the axis'
  667. // center cannot be a reference to pane's center
  668. center = this.center = extend([], this.pane.center);
  669. // The sector is used in Axis.translate to compute the
  670. // translation of reversed axis points (#2570)
  671. if (this.isCircular) {
  672. this.sector = this.endAngleRad - this.startAngleRad;
  673. }
  674. else {
  675. // When the pane's startAngle or the axis' angle is set then
  676. // new x and y values for vertical axis' center must be
  677. // calulated
  678. start = this.postTranslate(this.angleRad, center[3] / 2);
  679. center[0] = start.x - this.chart.plotLeft;
  680. center[1] = start.y - this.chart.plotTop;
  681. }
  682. // Axis len is used to lay out the ticks
  683. this.len = this.width = this.height =
  684. (center[2] - center[3]) * pick(this.sector, 1) / 2;
  685. }
  686. };
  687. /**
  688. * Returns the x, y coordinate of a point given by a value and a pixel
  689. * distance from center.
  690. *
  691. * @private
  692. *
  693. * @param {number} value
  694. * Point value.
  695. *
  696. * @param {number} [length]
  697. * Distance from center.
  698. *
  699. * @return {Highcharts.PositionObject}
  700. */
  701. axis.getPosition = function (value, length) {
  702. var translatedVal = this.translate(value);
  703. return this.postTranslate(this.isCircular ? translatedVal : this.angleRad, // #2848
  704. // In case when translatedVal is negative, the 0 value must be
  705. // used instead, in order to deal with lines and labels that
  706. // fall out of the visible range near the center of a pane
  707. pick(this.isCircular ?
  708. length :
  709. (translatedVal < 0 ? 0 : translatedVal), this.center[2] / 2) - this.offset);
  710. };
  711. /**
  712. * Translate from intermediate plotX (angle), plotY (axis.len - radius)
  713. * to final chart coordinates.
  714. *
  715. * @private
  716. *
  717. * @param {number} angle
  718. * Translation angle.
  719. *
  720. * @param {number} radius
  721. * Translation radius.
  722. *
  723. * @return {Highcharts.PositionObject}
  724. */
  725. axis.postTranslate = function (angle, radius) {
  726. var chart = this.chart,
  727. center = this.center;
  728. angle = this.startAngleRad + angle;
  729. return {
  730. x: chart.plotLeft + center[0] + Math.cos(angle) * radius,
  731. y: chart.plotTop + center[1] + Math.sin(angle) * radius
  732. };
  733. };
  734. /**
  735. * Find the path for plot bands along the radial axis.
  736. *
  737. * @private
  738. *
  739. * @param {number} from
  740. * From value.
  741. *
  742. * @param {number} to
  743. * To value.
  744. *
  745. * @param {Highcharts.AxisPlotBandsOptions} options
  746. * Band options.
  747. *
  748. * @return {RadialAxisPath}
  749. */
  750. axis.getPlotBandPath = function (from, to, options) {
  751. var radiusToPixels = function (radius) {
  752. if (typeof radius === 'string') {
  753. var r = parseInt(radius, 10);
  754. if (percentRegex.test(radius)) {
  755. r = (r * fullRadius) / 100;
  756. }
  757. return r;
  758. }
  759. return radius;
  760. };
  761. var center = this.center,
  762. startAngleRad = this.startAngleRad,
  763. fullRadius = center[2] / 2,
  764. offset = Math.min(this.offset, 0),
  765. percentRegex = /%$/,
  766. start,
  767. end,
  768. angle,
  769. xOnPerimeter,
  770. open,
  771. isCircular = this.isCircular, // X axis in a polar chart
  772. path,
  773. outerRadius = pick(radiusToPixels(options.outerRadius),
  774. fullRadius),
  775. innerRadius = radiusToPixels(options.innerRadius),
  776. thickness = pick(radiusToPixels(options.thickness), 10);
  777. // Polygonal plot bands
  778. if (this.options.gridLineInterpolation === 'polygon') {
  779. path = this.getPlotLinePath({ value: from }).concat(this.getPlotLinePath({ value: to, reverse: true }));
  780. // Circular grid bands
  781. }
  782. else {
  783. // Keep within bounds
  784. from = Math.max(from, this.min);
  785. to = Math.min(to, this.max);
  786. var transFrom = this.translate(from);
  787. var transTo = this.translate(to);
  788. // Plot bands on Y axis (radial axis) - inner and outer
  789. // radius depend on to and from
  790. if (!isCircular) {
  791. outerRadius = transFrom || 0;
  792. innerRadius = transTo || 0;
  793. }
  794. // Handle full circle
  795. if (options.shape === 'circle' || !isCircular) {
  796. start = -Math.PI / 2;
  797. end = Math.PI * 1.5;
  798. open = true;
  799. }
  800. else {
  801. start = startAngleRad + (transFrom || 0);
  802. end = startAngleRad + (transTo || 0);
  803. }
  804. outerRadius -= offset; // #5283
  805. thickness -= offset; // #5283
  806. path = this.chart.renderer.symbols.arc(this.left + center[0], this.top + center[1], outerRadius, outerRadius, {
  807. // Math is for reversed yAxis (#3606)
  808. start: Math.min(start, end),
  809. end: Math.max(start, end),
  810. innerR: pick(innerRadius, outerRadius - thickness),
  811. open: open
  812. });
  813. // Provide positioning boxes for the label (#6406)
  814. if (isCircular) {
  815. angle = (end + start) / 2;
  816. xOnPerimeter = (this.left +
  817. center[0] +
  818. (center[2] / 2) * Math.cos(angle));
  819. path.xBounds = angle > -Math.PI / 2 && angle < Math.PI / 2 ?
  820. // Right hemisphere
  821. [xOnPerimeter, this.chart.plotWidth] :
  822. // Left hemisphere
  823. [0, xOnPerimeter];
  824. path.yBounds = [
  825. this.top + center[1] + (center[2] / 2) * Math.sin(angle)
  826. ];
  827. // Shift up or down to get the label clear of the perimeter
  828. path.yBounds[0] += ((angle > -Math.PI && angle < 0) ||
  829. (angle > Math.PI)) ? -10 : 10;
  830. }
  831. }
  832. return path;
  833. };
  834. // Find the correct end values of crosshair in polar.
  835. axis.getCrosshairPosition = function (options, x1, y1) {
  836. var axis = this,
  837. value = options.value,
  838. center = axis.pane.center,
  839. shapeArgs,
  840. end,
  841. x2,
  842. y2;
  843. if (axis.isCircular) {
  844. if (!defined(value)) {
  845. // When the snap is set to false
  846. x2 = options.chartX || 0;
  847. y2 = options.chartY || 0;
  848. value = axis.translate(Math.atan2(y2 - y1, x2 - x1) - axis.startAngleRad, true);
  849. }
  850. else if (options.point) {
  851. // When the snap is set to true
  852. shapeArgs = options.point.shapeArgs || {};
  853. if (shapeArgs.start) {
  854. // Find a true value of the point based on the
  855. // angle
  856. value = axis.chart.inverted ?
  857. axis.translate(options.point.rectPlotY, true) :
  858. options.point.x;
  859. }
  860. }
  861. end = axis.getPosition(value);
  862. x2 = end.x;
  863. y2 = end.y;
  864. }
  865. else {
  866. if (!defined(value)) {
  867. x2 = options.chartX;
  868. y2 = options.chartY;
  869. }
  870. if (defined(x2) && defined(y2)) {
  871. // Calculate radius of non-circular axis' crosshair
  872. y1 = center[1] + axis.chart.plotTop;
  873. value = axis.translate(Math.min(Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), center[2] / 2) - center[3] / 2, true);
  874. }
  875. }
  876. return [value, x2 || 0, y2 || 0];
  877. };
  878. // Find the path for plot lines perpendicular to the radial axis.
  879. axis.getPlotLinePath = function (options) {
  880. var axis = this, center = axis.pane.center, chart = axis.chart, inverted = chart.inverted, value = options.value, reverse = options.reverse, end = axis.getPosition(value), background = axis.pane.options.background ?
  881. (axis.pane.options.background[0] ||
  882. axis.pane.options.background) :
  883. {}, innerRadius = background.innerRadius || '0%', outerRadius = background.outerRadius || '100%', x1 = center[0] + chart.plotLeft, y1 = center[1] + chart.plotTop, x2 = end.x, y2 = end.y, height = axis.height, isCrosshair = options.isCrosshair, paneInnerR = center[3] / 2, innerRatio, distance, a, b, otherAxis, xy, tickPositions, crossPos, path;
  884. // Crosshair logic
  885. if (isCrosshair) {
  886. // Find crosshair's position and perform destructuring
  887. // assignment
  888. crossPos = this.getCrosshairPosition(options, x1, y1);
  889. value = crossPos[0];
  890. x2 = crossPos[1];
  891. y2 = crossPos[2];
  892. }
  893. // Spokes
  894. if (axis.isCircular) {
  895. distance =
  896. Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
  897. a = (typeof innerRadius === 'string') ?
  898. relativeLength(innerRadius, 1) : (innerRadius / distance);
  899. b = (typeof outerRadius === 'string') ?
  900. relativeLength(outerRadius, 1) : (outerRadius / distance);
  901. // To ensure that gridlines won't be displayed in area
  902. // defined by innerSize in case of custom radiuses of pane's
  903. // background
  904. if (center && paneInnerR) {
  905. innerRatio = paneInnerR / distance;
  906. if (a < innerRatio) {
  907. a = innerRatio;
  908. }
  909. if (b < innerRatio) {
  910. b = innerRatio;
  911. }
  912. }
  913. path = [
  914. ['M', x1 + a * (x2 - x1), y1 - a * (y1 - y2)],
  915. ['L', x2 - (1 - b) * (x2 - x1), y2 + (1 - b) * (y1 - y2)]
  916. ];
  917. // Concentric circles
  918. }
  919. else {
  920. // Pick the right values depending if it is grid line or
  921. // crosshair
  922. value = axis.translate(value);
  923. // This is required in case when xAxis is non-circular to
  924. // prevent grid lines (or crosshairs, if enabled) from
  925. // rendering above the center after they supposed to be
  926. // displayed below the center point
  927. if (value) {
  928. if (value < 0 || value > height) {
  929. value = 0;
  930. }
  931. }
  932. if (axis.options.gridLineInterpolation === 'circle') {
  933. // A value of 0 is in the center, so it won't be
  934. // visible, but draw it anyway for update and animation
  935. // (#2366)
  936. path = axis.getLinePath(0, value, paneInnerR);
  937. // Concentric polygons
  938. }
  939. else {
  940. path = [];
  941. // Find the other axis (a circular one) in the same pane
  942. chart[inverted ? 'yAxis' : 'xAxis'].forEach(function (a) {
  943. if (a.pane === axis.pane) {
  944. otherAxis = a;
  945. }
  946. });
  947. if (otherAxis) {
  948. tickPositions = otherAxis.tickPositions;
  949. if (otherAxis.autoConnect) {
  950. tickPositions =
  951. tickPositions.concat([tickPositions[0]]);
  952. }
  953. // Reverse the positions for concatenation of polygonal
  954. // plot bands
  955. if (reverse) {
  956. tickPositions = tickPositions.slice().reverse();
  957. }
  958. if (value) {
  959. value += paneInnerR;
  960. }
  961. for (var i = 0; i < tickPositions.length; i++) {
  962. xy = otherAxis.getPosition(tickPositions[i], value);
  963. path.push(i ? ['L', xy.x, xy.y] : ['M', xy.x, xy.y]);
  964. }
  965. }
  966. }
  967. }
  968. return path;
  969. };
  970. // Find the position for the axis title, by default inside the gauge.
  971. axis.getTitlePosition = function () {
  972. var center = this.center,
  973. chart = this.chart,
  974. titleOptions = this.options.title;
  975. return {
  976. x: chart.plotLeft + center[0] + (titleOptions.x || 0),
  977. y: (chart.plotTop +
  978. center[1] -
  979. ({
  980. high: 0.5,
  981. middle: 0.25,
  982. low: 0
  983. }[titleOptions.align] *
  984. center[2]) +
  985. (titleOptions.y || 0))
  986. };
  987. };
  988. /**
  989. * Attach and return collecting function for labels in radial axis for
  990. * anti-collision.
  991. *
  992. * @private
  993. *
  994. * @return {Highcharts.ChartLabelCollectorFunction}
  995. */
  996. axis.createLabelCollector = function () {
  997. var axis = this;
  998. return function () {
  999. if (axis.isRadial &&
  1000. axis.tickPositions &&
  1001. // undocumented option for now, but working
  1002. axis.options.labels.allowOverlap !== true) {
  1003. return axis.tickPositions
  1004. .map(function (pos) {
  1005. return axis.ticks[pos] && axis.ticks[pos].label;
  1006. })
  1007. .filter(function (label) {
  1008. return Boolean(label);
  1009. });
  1010. }
  1011. };
  1012. };
  1013. };
  1014. /**
  1015. * Augments methods for the value axis.
  1016. *
  1017. * @private
  1018. *
  1019. * @param {Highcharts.Axis} AxisClass
  1020. * Axis class to extend.
  1021. *
  1022. * @param {Highcharts.Tick} TickClass
  1023. * Tick class to use.
  1024. */
  1025. RadialAxis.compose = function (AxisClass, TickClass) {
  1026. /* eslint-disable no-invalid-this */
  1027. // Actions before axis init.
  1028. addEvent(AxisClass, 'init', function (e) {
  1029. var axis = this;
  1030. var chart = axis.chart;
  1031. var inverted = chart.inverted,
  1032. angular = chart.angular,
  1033. polar = chart.polar,
  1034. isX = axis.isXAxis,
  1035. coll = axis.coll,
  1036. isHidden = angular && isX,
  1037. isCircular,
  1038. chartOptions = chart.options,
  1039. paneIndex = e.userOptions.pane || 0,
  1040. pane = this.pane =
  1041. chart.pane && chart.pane[paneIndex];
  1042. // Prevent changes for colorAxis
  1043. if (coll === 'colorAxis') {
  1044. this.isRadial = false;
  1045. return;
  1046. }
  1047. // Before prototype.init
  1048. if (angular) {
  1049. if (isHidden) {
  1050. HiddenAxis.init(axis);
  1051. }
  1052. else {
  1053. RadialAxis.init(axis);
  1054. }
  1055. isCircular = !isX;
  1056. if (isCircular) {
  1057. axis.defaultPolarOptions = RadialAxis.defaultRadialGaugeOptions;
  1058. }
  1059. }
  1060. else if (polar) {
  1061. RadialAxis.init(axis);
  1062. // Check which axis is circular
  1063. isCircular = axis.horiz;
  1064. axis.defaultPolarOptions = isCircular ?
  1065. RadialAxis.defaultCircularOptions :
  1066. merge(coll === 'xAxis' ?
  1067. AxisClass.defaultOptions :
  1068. AxisClass.defaultYAxisOptions, RadialAxis.defaultRadialOptions);
  1069. // Apply the stack labels for yAxis in case of inverted chart
  1070. if (inverted && coll === 'yAxis') {
  1071. axis.defaultPolarOptions.stackLabels = AxisClass.defaultYAxisOptions.stackLabels;
  1072. }
  1073. }
  1074. // Disable certain features on angular and polar axes
  1075. if (angular || polar) {
  1076. axis.isRadial = true;
  1077. chartOptions.chart.zoomType = null;
  1078. if (!axis.labelCollector) {
  1079. axis.labelCollector = axis.createLabelCollector();
  1080. }
  1081. if (axis.labelCollector) {
  1082. // Prevent overlapping axis labels (#9761)
  1083. chart.labelCollectors.push(axis.labelCollector);
  1084. }
  1085. }
  1086. else {
  1087. this.isRadial = false;
  1088. }
  1089. // A pointer back to this axis to borrow geometry
  1090. if (pane && isCircular) {
  1091. pane.axis = axis;
  1092. }
  1093. axis.isCircular = isCircular;
  1094. });
  1095. addEvent(AxisClass, 'afterInit', function () {
  1096. var axis = this;
  1097. var chart = axis.chart,
  1098. options = axis.options,
  1099. isHidden = chart.angular && axis.isXAxis,
  1100. pane = axis.pane,
  1101. paneOptions = pane && pane.options;
  1102. if (!isHidden && pane && (chart.angular || chart.polar)) {
  1103. // Start and end angle options are given in degrees relative to
  1104. // top, while internal computations are in radians relative to
  1105. // right (like SVG).
  1106. // Y axis in polar charts
  1107. axis.angleRad = (options.angle || 0) * Math.PI / 180;
  1108. // Gauges
  1109. axis.startAngleRad =
  1110. (paneOptions.startAngle - 90) * Math.PI / 180;
  1111. axis.endAngleRad = (pick(paneOptions.endAngle, paneOptions.startAngle + 360) - 90) * Math.PI / 180; // Gauges
  1112. axis.offset = options.offset || 0;
  1113. }
  1114. });
  1115. // Wrap auto label align to avoid setting axis-wide rotation on radial
  1116. // axes. (#4920)
  1117. addEvent(AxisClass, 'autoLabelAlign', function (e) {
  1118. if (this.isRadial) {
  1119. e.align = void 0;
  1120. e.preventDefault();
  1121. }
  1122. });
  1123. // Remove label collector function on axis remove/update
  1124. addEvent(AxisClass, 'destroy', function () {
  1125. var axis = this;
  1126. if (axis.chart &&
  1127. axis.chart.labelCollectors) {
  1128. var index = (axis.labelCollector ?
  1129. axis.chart.labelCollectors.indexOf(axis.labelCollector) :
  1130. -1);
  1131. if (index >= 0) {
  1132. axis.chart.labelCollectors.splice(index, 1);
  1133. }
  1134. }
  1135. });
  1136. addEvent(AxisClass, 'initialAxisTranslation', function () {
  1137. var axis = this;
  1138. if (axis.isRadial) {
  1139. axis.beforeSetTickPositions();
  1140. }
  1141. });
  1142. // Add special cases within the Tick class' methods for radial axes.
  1143. addEvent(TickClass, 'afterGetPosition', function (e) {
  1144. var tick = this;
  1145. if (tick.axis.getPosition) {
  1146. extend(e.pos, tick.axis.getPosition(this.pos));
  1147. }
  1148. });
  1149. // Find the center position of the label based on the distance option.
  1150. addEvent(TickClass, 'afterGetLabelPosition', function (e) {
  1151. var tick = this;
  1152. var axis = tick.axis;
  1153. var label = tick.label;
  1154. if (!label) {
  1155. return;
  1156. }
  1157. var labelBBox = label.getBBox(), labelOptions = axis.options.labels, optionsY = labelOptions.y, ret, centerSlot = 20, // 20 degrees to each side at the top and bottom
  1158. align = labelOptions.align, angle = ((axis.translate(this.pos) + axis.startAngleRad +
  1159. Math.PI / 2) / Math.PI * 180) % 360, correctAngle = Math.round(angle), labelDir = 'end', // Direction of the label 'start' or 'end'
  1160. reducedAngle1 = correctAngle < 0 ?
  1161. correctAngle + 360 : correctAngle, reducedAngle2 = reducedAngle1, translateY = 0, translateX = 0, labelYPosCorrection = labelOptions.y === null ? -labelBBox.height * 0.3 : 0;
  1162. if (axis.isRadial) { // Both X and Y axes in a polar chart
  1163. ret = axis.getPosition(this.pos, (axis.center[2] / 2) +
  1164. relativeLength(pick(labelOptions.distance, -25), axis.center[2] / 2, -axis.center[2] / 2));
  1165. // Automatically rotated
  1166. if (labelOptions.rotation === 'auto') {
  1167. label.attr({
  1168. rotation: angle
  1169. });
  1170. // Vertically centered
  1171. }
  1172. else if (optionsY === null) {
  1173. optionsY = (axis.chart.renderer
  1174. .fontMetrics(label.styles && label.styles.fontSize).b -
  1175. labelBBox.height / 2);
  1176. }
  1177. // Automatic alignment
  1178. if (align === null) {
  1179. if (axis.isCircular) { // Y axis
  1180. if (labelBBox.width >
  1181. axis.len * axis.tickInterval / (axis.max - axis.min)) { // #3506
  1182. centerSlot = 0;
  1183. }
  1184. if (angle > centerSlot && angle < 180 - centerSlot) {
  1185. align = 'left'; // right hemisphere
  1186. }
  1187. else if (angle > 180 + centerSlot &&
  1188. angle < 360 - centerSlot) {
  1189. align = 'right'; // left hemisphere
  1190. }
  1191. else {
  1192. align = 'center'; // top or bottom
  1193. }
  1194. }
  1195. else {
  1196. align = 'center';
  1197. }
  1198. label.attr({
  1199. align: align
  1200. });
  1201. }
  1202. // Auto alignment for solid-gauges with two labels (#10635)
  1203. if (align === 'auto' &&
  1204. axis.tickPositions.length === 2 &&
  1205. axis.isCircular) {
  1206. // Angles reduced to 0 - 90 or 180 - 270
  1207. if (reducedAngle1 > 90 && reducedAngle1 < 180) {
  1208. reducedAngle1 = 180 - reducedAngle1;
  1209. }
  1210. else if (reducedAngle1 > 270 && reducedAngle1 <= 360) {
  1211. reducedAngle1 = 540 - reducedAngle1;
  1212. }
  1213. // Angles reduced to 0 - 180
  1214. if (reducedAngle2 > 180 && reducedAngle2 <= 360) {
  1215. reducedAngle2 = 360 - reducedAngle2;
  1216. }
  1217. if ((axis.pane.options.startAngle === correctAngle) ||
  1218. (axis.pane.options.startAngle === correctAngle + 360) ||
  1219. (axis.pane.options.startAngle === correctAngle - 360)) {
  1220. labelDir = 'start';
  1221. }
  1222. if ((correctAngle >= -90 && correctAngle <= 90) ||
  1223. (correctAngle >= -360 && correctAngle <= -270) ||
  1224. (correctAngle >= 270 && correctAngle <= 360)) {
  1225. align = (labelDir === 'start') ? 'right' : 'left';
  1226. }
  1227. else {
  1228. align = (labelDir === 'start') ? 'left' : 'right';
  1229. }
  1230. // For angles beetwen (90 + n * 180) +- 20
  1231. if (reducedAngle2 > 70 && reducedAngle2 < 110) {
  1232. align = 'center';
  1233. }
  1234. // auto Y translation
  1235. if (reducedAngle1 < 15 ||
  1236. (reducedAngle1 >= 180 && reducedAngle1 < 195)) {
  1237. translateY = labelBBox.height * 0.3;
  1238. }
  1239. else if (reducedAngle1 >= 15 && reducedAngle1 <= 35) {
  1240. translateY = labelDir === 'start' ?
  1241. 0 : labelBBox.height * 0.75;
  1242. }
  1243. else if (reducedAngle1 >= 195 && reducedAngle1 <= 215) {
  1244. translateY = labelDir === 'start' ?
  1245. labelBBox.height * 0.75 : 0;
  1246. }
  1247. else if (reducedAngle1 > 35 && reducedAngle1 <= 90) {
  1248. translateY = labelDir === 'start' ?
  1249. -labelBBox.height * 0.25 : labelBBox.height;
  1250. }
  1251. else if (reducedAngle1 > 215 && reducedAngle1 <= 270) {
  1252. translateY = labelDir === 'start' ?
  1253. labelBBox.height : -labelBBox.height * 0.25;
  1254. }
  1255. // auto X translation
  1256. if (reducedAngle2 < 15) {
  1257. translateX = labelDir === 'start' ?
  1258. -labelBBox.height * 0.15 : labelBBox.height * 0.15;
  1259. }
  1260. else if (reducedAngle2 > 165 && reducedAngle2 <= 180) {
  1261. translateX = labelDir === 'start' ?
  1262. labelBBox.height * 0.15 : -labelBBox.height * 0.15;
  1263. }
  1264. label.attr({ align: align });
  1265. label.translate(translateX, translateY + labelYPosCorrection);
  1266. }
  1267. e.pos.x = ret.x + labelOptions.x;
  1268. e.pos.y = ret.y + optionsY;
  1269. }
  1270. });
  1271. // Wrap the getMarkPath function to return the path of the radial marker
  1272. wrap(TickClass.prototype, 'getMarkPath', function (proceed, x, y, tickLength, tickWidth, horiz, renderer) {
  1273. var tick = this;
  1274. var axis = tick.axis;
  1275. var endPoint,
  1276. ret;
  1277. if (axis.isRadial) {
  1278. endPoint = axis.getPosition(this.pos, axis.center[2] / 2 + tickLength);
  1279. ret = [
  1280. 'M',
  1281. x,
  1282. y,
  1283. 'L',
  1284. endPoint.x,
  1285. endPoint.y
  1286. ];
  1287. }
  1288. else {
  1289. ret = proceed.call(this, x, y, tickLength, tickWidth, horiz, renderer);
  1290. }
  1291. return ret;
  1292. });
  1293. };
  1294. /* *
  1295. *
  1296. * Static Properties
  1297. *
  1298. * */
  1299. /**
  1300. * Circular axis around the perimeter of a polar chart.
  1301. * @private
  1302. */
  1303. RadialAxis.defaultCircularOptions = {
  1304. gridLineWidth: 1,
  1305. labels: {
  1306. align: null,
  1307. distance: 15,
  1308. x: 0,
  1309. y: null,
  1310. style: {
  1311. textOverflow: 'none' // wrap lines by default (#7248)
  1312. }
  1313. },
  1314. maxPadding: 0,
  1315. minPadding: 0,
  1316. showLastLabel: false,
  1317. tickLength: 0
  1318. };
  1319. /**
  1320. * The default options extend defaultYAxisOptions.
  1321. * @private
  1322. */
  1323. RadialAxis.defaultRadialGaugeOptions = {
  1324. labels: {
  1325. align: 'center',
  1326. x: 0,
  1327. y: null // auto
  1328. },
  1329. minorGridLineWidth: 0,
  1330. minorTickInterval: 'auto',
  1331. minorTickLength: 10,
  1332. minorTickPosition: 'inside',
  1333. minorTickWidth: 1,
  1334. tickLength: 10,
  1335. tickPosition: 'inside',
  1336. tickWidth: 2,
  1337. title: {
  1338. rotation: 0
  1339. },
  1340. zIndex: 2 // behind dials, points in the series group
  1341. };
  1342. /**
  1343. * Radial axis, like a spoke in a polar chart.
  1344. * @private
  1345. */
  1346. RadialAxis.defaultRadialOptions = {
  1347. /**
  1348. * In a polar chart, this is the angle of the Y axis in degrees, where
  1349. * 0 is up and 90 is right. The angle determines the position of the
  1350. * axis line and the labels, though the coordinate system is unaffected.
  1351. * Since v8.0.0 this option is also applicable for X axis (inverted
  1352. * polar).
  1353. *
  1354. * @sample {highcharts} highcharts/xaxis/angle/
  1355. * Custom X axis' angle on inverted polar chart
  1356. * @sample {highcharts} highcharts/yaxis/angle/
  1357. * Dual axis polar chart
  1358. *
  1359. * @type {number}
  1360. * @default 0
  1361. * @since 4.2.7
  1362. * @product highcharts
  1363. * @apioption xAxis.angle
  1364. */
  1365. /**
  1366. * Polar charts only. Whether the grid lines should draw as a polygon
  1367. * with straight lines between categories, or as circles. Can be either
  1368. * `circle` or `polygon`. Since v8.0.0 this option is also applicable
  1369. * for X axis (inverted polar).
  1370. *
  1371. * @sample {highcharts} highcharts/demo/polar-spider/
  1372. * Polygon grid lines
  1373. * @sample {highcharts} highcharts/xaxis/gridlineinterpolation/
  1374. * Circle and polygon on inverted polar
  1375. * @sample {highcharts} highcharts/yaxis/gridlineinterpolation/
  1376. * Circle and polygon
  1377. *
  1378. * @type {string}
  1379. * @product highcharts
  1380. * @validvalue ["circle", "polygon"]
  1381. * @apioption xAxis.gridLineInterpolation
  1382. */
  1383. gridLineInterpolation: 'circle',
  1384. gridLineWidth: 1,
  1385. labels: {
  1386. align: 'right',
  1387. x: -3,
  1388. y: -2
  1389. },
  1390. showLastLabel: false,
  1391. title: {
  1392. x: 4,
  1393. text: null,
  1394. rotation: 90
  1395. }
  1396. };
  1397. return RadialAxis;
  1398. }());
  1399. RadialAxis.compose(Axis, Tick); // @todo move outside
  1400. return RadialAxis;
  1401. });
  1402. _registerModule(_modules, 'Series/AreaRangeSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (BaseSeries, H, Point, U) {
  1403. /* *
  1404. *
  1405. * (c) 2010-2020 Torstein Honsi
  1406. *
  1407. * License: www.highcharts.com/license
  1408. *
  1409. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1410. *
  1411. * */
  1412. var noop = H.noop;
  1413. var defined = U.defined,
  1414. extend = U.extend,
  1415. isArray = U.isArray,
  1416. isNumber = U.isNumber,
  1417. pick = U.pick;
  1418. var Series = H.Series,
  1419. areaProto = BaseSeries.seriesTypes.area.prototype,
  1420. columnProto = BaseSeries.seriesTypes.column.prototype,
  1421. pointProto = Point.prototype,
  1422. seriesProto = Series.prototype;
  1423. /**
  1424. * The area range series is a carteseian series with higher and lower values for
  1425. * each point along an X axis, where the area between the values is shaded.
  1426. *
  1427. * @sample {highcharts} highcharts/demo/arearange/
  1428. * Area range chart
  1429. * @sample {highstock} stock/demo/arearange/
  1430. * Area range chart
  1431. *
  1432. * @extends plotOptions.area
  1433. * @product highcharts highstock
  1434. * @excluding stack, stacking
  1435. * @requires highcharts-more
  1436. * @optionparent plotOptions.arearange
  1437. */
  1438. BaseSeries.seriesType('arearange', 'area', {
  1439. /**
  1440. * @see [fillColor](#plotOptions.arearange.fillColor)
  1441. * @see [fillOpacity](#plotOptions.arearange.fillOpacity)
  1442. *
  1443. * @apioption plotOptions.arearange.color
  1444. */
  1445. /**
  1446. * @default low
  1447. * @apioption plotOptions.arearange.colorKey
  1448. */
  1449. /**
  1450. * @see [color](#plotOptions.arearange.color)
  1451. * @see [fillOpacity](#plotOptions.arearange.fillOpacity)
  1452. *
  1453. * @apioption plotOptions.arearange.fillColor
  1454. */
  1455. /**
  1456. * @see [color](#plotOptions.arearange.color)
  1457. * @see [fillColor](#plotOptions.arearange.fillColor)
  1458. *
  1459. * @default {highcharts} 0.75
  1460. * @default {highstock} 0.75
  1461. * @apioption plotOptions.arearange.fillOpacity
  1462. */
  1463. /**
  1464. * Whether to apply a drop shadow to the graph line. Since 2.3 the shadow
  1465. * can be an object configuration containing `color`, `offsetX`, `offsetY`,
  1466. * `opacity` and `width`.
  1467. *
  1468. * @type {boolean|Highcharts.ShadowOptionsObject}
  1469. * @product highcharts
  1470. * @apioption plotOptions.arearange.shadow
  1471. */
  1472. /**
  1473. * Pixel width of the arearange graph line.
  1474. *
  1475. * @since 2.3.0
  1476. *
  1477. * @private
  1478. */
  1479. lineWidth: 1,
  1480. threshold: null,
  1481. tooltip: {
  1482. pointFormat: '<span style="color:{series.color}">\u25CF</span> ' +
  1483. '{series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
  1484. },
  1485. /**
  1486. * Whether the whole area or just the line should respond to mouseover
  1487. * tooltips and other mouse or touch events.
  1488. *
  1489. * @since 2.3.0
  1490. *
  1491. * @private
  1492. */
  1493. trackByArea: true,
  1494. /**
  1495. * Extended data labels for range series types. Range series data labels use
  1496. * no `x` and `y` options. Instead, they have `xLow`, `xHigh`, `yLow` and
  1497. * `yHigh` options to allow the higher and lower data label sets
  1498. * individually.
  1499. *
  1500. * @declare Highcharts.SeriesAreaRangeDataLabelsOptionsObject
  1501. * @exclude x, y
  1502. * @since 2.3.0
  1503. * @product highcharts highstock
  1504. *
  1505. * @private
  1506. */
  1507. dataLabels: {
  1508. align: void 0,
  1509. verticalAlign: void 0,
  1510. /**
  1511. * X offset of the lower data labels relative to the point value.
  1512. *
  1513. * @sample highcharts/plotoptions/arearange-datalabels/
  1514. * Data labels on range series
  1515. * @sample highcharts/plotoptions/arearange-datalabels/
  1516. * Data labels on range series
  1517. */
  1518. xLow: 0,
  1519. /**
  1520. * X offset of the higher data labels relative to the point value.
  1521. *
  1522. * @sample highcharts/plotoptions/arearange-datalabels/
  1523. * Data labels on range series
  1524. */
  1525. xHigh: 0,
  1526. /**
  1527. * Y offset of the lower data labels relative to the point value.
  1528. *
  1529. * @sample highcharts/plotoptions/arearange-datalabels/
  1530. * Data labels on range series
  1531. */
  1532. yLow: 0,
  1533. /**
  1534. * Y offset of the higher data labels relative to the point value.
  1535. *
  1536. * @sample highcharts/plotoptions/arearange-datalabels/
  1537. * Data labels on range series
  1538. */
  1539. yHigh: 0
  1540. }
  1541. // Prototype members
  1542. }, {
  1543. pointArrayMap: ['low', 'high'],
  1544. pointValKey: 'low',
  1545. deferTranslatePolar: true,
  1546. /* eslint-disable valid-jsdoc */
  1547. /**
  1548. * @private
  1549. */
  1550. toYData: function (point) {
  1551. return [point.low, point.high];
  1552. },
  1553. /**
  1554. * Translate a point's plotHigh from the internal angle and radius measures
  1555. * to true plotHigh coordinates. This is an addition of the toXY method
  1556. * found in Polar.js, because it runs too early for arearanges to be
  1557. * considered (#3419).
  1558. * @private
  1559. */
  1560. highToXY: function (point) {
  1561. // Find the polar plotX and plotY
  1562. var chart = this.chart,
  1563. xy = this.xAxis.postTranslate(point.rectPlotX,
  1564. this.yAxis.len - point.plotHigh);
  1565. point.plotHighX = xy.x - chart.plotLeft;
  1566. point.plotHigh = xy.y - chart.plotTop;
  1567. point.plotLowX = point.plotX;
  1568. },
  1569. /**
  1570. * Translate data points from raw values x and y to plotX and plotY.
  1571. * @private
  1572. */
  1573. translate: function () {
  1574. var series = this,
  1575. yAxis = series.yAxis,
  1576. hasModifyValue = !!series.modifyValue;
  1577. areaProto.translate.apply(series);
  1578. // Set plotLow and plotHigh
  1579. series.points.forEach(function (point) {
  1580. var high = point.high,
  1581. plotY = point.plotY;
  1582. if (point.isNull) {
  1583. point.plotY = null;
  1584. }
  1585. else {
  1586. point.plotLow = plotY;
  1587. point.plotHigh = yAxis.translate(hasModifyValue ?
  1588. series.modifyValue(high, point) :
  1589. high, 0, 1, 0, 1);
  1590. if (hasModifyValue) {
  1591. point.yBottom = point.plotHigh;
  1592. }
  1593. }
  1594. });
  1595. // Postprocess plotHigh
  1596. if (this.chart.polar) {
  1597. this.points.forEach(function (point) {
  1598. series.highToXY(point);
  1599. point.tooltipPos = [
  1600. (point.plotHighX + point.plotLowX) / 2,
  1601. (point.plotHigh + point.plotLow) / 2
  1602. ];
  1603. });
  1604. }
  1605. },
  1606. /**
  1607. * Extend the line series' getSegmentPath method by applying the segment
  1608. * path to both lower and higher values of the range.
  1609. * @private
  1610. */
  1611. getGraphPath: function (points) {
  1612. var highPoints = [],
  1613. highAreaPoints = [],
  1614. i,
  1615. getGraphPath = areaProto.getGraphPath,
  1616. point,
  1617. pointShim,
  1618. linePath,
  1619. lowerPath,
  1620. options = this.options,
  1621. polar = this.chart.polar,
  1622. connectEnds = polar && options.connectEnds !== false,
  1623. connectNulls = options.connectNulls,
  1624. step = options.step,
  1625. higherPath,
  1626. higherAreaPath;
  1627. points = points || this.points;
  1628. // Create the top line and the top part of the area fill. The area fill
  1629. // compensates for null points by drawing down to the lower graph,
  1630. // moving across the null gap and starting again at the lower graph.
  1631. i = points.length;
  1632. while (i--) {
  1633. point = points[i];
  1634. // Support for polar
  1635. var highAreaPoint = polar ? {
  1636. plotX: point.rectPlotX,
  1637. plotY: point.yBottom,
  1638. doCurve: false // #5186, gaps in areasplinerange fill
  1639. } : {
  1640. plotX: point.plotX,
  1641. plotY: point.plotY,
  1642. doCurve: false // #5186, gaps in areasplinerange fill
  1643. };
  1644. if (!point.isNull &&
  1645. !connectEnds &&
  1646. !connectNulls &&
  1647. (!points[i + 1] || points[i + 1].isNull)) {
  1648. highAreaPoints.push(highAreaPoint);
  1649. }
  1650. pointShim = {
  1651. polarPlotY: point.polarPlotY,
  1652. rectPlotX: point.rectPlotX,
  1653. yBottom: point.yBottom,
  1654. // plotHighX is for polar charts
  1655. plotX: pick(point.plotHighX, point.plotX),
  1656. plotY: point.plotHigh,
  1657. isNull: point.isNull
  1658. };
  1659. highAreaPoints.push(pointShim);
  1660. highPoints.push(pointShim);
  1661. if (!point.isNull &&
  1662. !connectEnds &&
  1663. !connectNulls &&
  1664. (!points[i - 1] || points[i - 1].isNull)) {
  1665. highAreaPoints.push(highAreaPoint);
  1666. }
  1667. }
  1668. // Get the paths
  1669. lowerPath = getGraphPath.call(this, points);
  1670. if (step) {
  1671. if (step === true) {
  1672. step = 'left';
  1673. }
  1674. options.step = {
  1675. left: 'right',
  1676. center: 'center',
  1677. right: 'left'
  1678. }[step]; // swap for reading in getGraphPath
  1679. }
  1680. higherPath = getGraphPath.call(this, highPoints);
  1681. higherAreaPath = getGraphPath.call(this, highAreaPoints);
  1682. options.step = step;
  1683. // Create a line on both top and bottom of the range
  1684. linePath = []
  1685. .concat(lowerPath, higherPath);
  1686. // For the area path, we need to change the 'move' statement
  1687. // into 'lineTo'
  1688. if (!this.chart.polar && higherAreaPath[0] && higherAreaPath[0][0] === 'M') {
  1689. // This probably doesn't work for spline
  1690. higherAreaPath[0] = ['L', higherAreaPath[0][1], higherAreaPath[0][2]];
  1691. }
  1692. this.graphPath = linePath;
  1693. this.areaPath = lowerPath.concat(higherAreaPath);
  1694. // Prepare for sideways animation
  1695. linePath.isArea = true;
  1696. linePath.xMap = lowerPath.xMap;
  1697. this.areaPath.xMap = lowerPath.xMap;
  1698. return linePath;
  1699. },
  1700. /**
  1701. * Extend the basic drawDataLabels method by running it for both lower and
  1702. * higher values.
  1703. * @private
  1704. */
  1705. drawDataLabels: function () {
  1706. var data = this.points,
  1707. length = data.length,
  1708. i,
  1709. originalDataLabels = [],
  1710. dataLabelOptions = this.options.dataLabels,
  1711. point,
  1712. up,
  1713. inverted = this.chart.inverted,
  1714. upperDataLabelOptions,
  1715. lowerDataLabelOptions;
  1716. // Split into upper and lower options. If data labels is an array, the
  1717. // first element is the upper label, the second is the lower.
  1718. //
  1719. // TODO: We want to change this and allow multiple labels for both upper
  1720. // and lower values in the future - introducing some options for which
  1721. // point value to use as Y for the dataLabel, so that this could be
  1722. // handled in Series.drawDataLabels. This would also improve performance
  1723. // since we now have to loop over all the points multiple times to work
  1724. // around the data label logic.
  1725. if (isArray(dataLabelOptions)) {
  1726. upperDataLabelOptions = dataLabelOptions[0] || { enabled: false };
  1727. lowerDataLabelOptions = dataLabelOptions[1] || { enabled: false };
  1728. }
  1729. else {
  1730. // Make copies
  1731. upperDataLabelOptions = extend({}, dataLabelOptions);
  1732. upperDataLabelOptions.x = dataLabelOptions.xHigh;
  1733. upperDataLabelOptions.y = dataLabelOptions.yHigh;
  1734. lowerDataLabelOptions = extend({}, dataLabelOptions);
  1735. lowerDataLabelOptions.x = dataLabelOptions.xLow;
  1736. lowerDataLabelOptions.y = dataLabelOptions.yLow;
  1737. }
  1738. // Draw upper labels
  1739. if (upperDataLabelOptions.enabled || this._hasPointLabels) {
  1740. // Set preliminary values for plotY and dataLabel
  1741. // and draw the upper labels
  1742. i = length;
  1743. while (i--) {
  1744. point = data[i];
  1745. if (point) {
  1746. up = upperDataLabelOptions.inside ?
  1747. point.plotHigh < point.plotLow :
  1748. point.plotHigh > point.plotLow;
  1749. point.y = point.high;
  1750. point._plotY = point.plotY;
  1751. point.plotY = point.plotHigh;
  1752. // Store original data labels and set preliminary label
  1753. // objects to be picked up in the uber method
  1754. originalDataLabels[i] = point.dataLabel;
  1755. point.dataLabel = point.dataLabelUpper;
  1756. // Set the default offset
  1757. point.below = up;
  1758. if (inverted) {
  1759. if (!upperDataLabelOptions.align) {
  1760. upperDataLabelOptions.align = up ? 'right' : 'left';
  1761. }
  1762. }
  1763. else {
  1764. if (!upperDataLabelOptions.verticalAlign) {
  1765. upperDataLabelOptions.verticalAlign = up ?
  1766. 'top' :
  1767. 'bottom';
  1768. }
  1769. }
  1770. }
  1771. }
  1772. this.options.dataLabels = upperDataLabelOptions;
  1773. if (seriesProto.drawDataLabels) {
  1774. // #1209:
  1775. seriesProto.drawDataLabels.apply(this, arguments);
  1776. }
  1777. // Reset state after the upper labels were created. Move
  1778. // it to point.dataLabelUpper and reassign the originals.
  1779. // We do this here to support not drawing a lower label.
  1780. i = length;
  1781. while (i--) {
  1782. point = data[i];
  1783. if (point) {
  1784. point.dataLabelUpper = point.dataLabel;
  1785. point.dataLabel = originalDataLabels[i];
  1786. delete point.dataLabels;
  1787. point.y = point.low;
  1788. point.plotY = point._plotY;
  1789. }
  1790. }
  1791. }
  1792. // Draw lower labels
  1793. if (lowerDataLabelOptions.enabled || this._hasPointLabels) {
  1794. i = length;
  1795. while (i--) {
  1796. point = data[i];
  1797. if (point) {
  1798. up = lowerDataLabelOptions.inside ?
  1799. point.plotHigh < point.plotLow :
  1800. point.plotHigh > point.plotLow;
  1801. // Set the default offset
  1802. point.below = !up;
  1803. if (inverted) {
  1804. if (!lowerDataLabelOptions.align) {
  1805. lowerDataLabelOptions.align = up ? 'left' : 'right';
  1806. }
  1807. }
  1808. else {
  1809. if (!lowerDataLabelOptions.verticalAlign) {
  1810. lowerDataLabelOptions.verticalAlign = up ?
  1811. 'bottom' :
  1812. 'top';
  1813. }
  1814. }
  1815. }
  1816. }
  1817. this.options.dataLabels = lowerDataLabelOptions;
  1818. if (seriesProto.drawDataLabels) {
  1819. seriesProto.drawDataLabels.apply(this, arguments);
  1820. }
  1821. }
  1822. // Merge upper and lower into point.dataLabels for later destroying
  1823. if (upperDataLabelOptions.enabled) {
  1824. i = length;
  1825. while (i--) {
  1826. point = data[i];
  1827. if (point) {
  1828. point.dataLabels = [
  1829. point.dataLabelUpper,
  1830. point.dataLabel
  1831. ].filter(function (label) {
  1832. return !!label;
  1833. });
  1834. }
  1835. }
  1836. }
  1837. // Reset options
  1838. this.options.dataLabels = dataLabelOptions;
  1839. },
  1840. alignDataLabel: function () {
  1841. columnProto.alignDataLabel.apply(this, arguments);
  1842. },
  1843. drawPoints: function () {
  1844. var series = this,
  1845. pointLength = series.points.length,
  1846. point,
  1847. i;
  1848. // Draw bottom points
  1849. seriesProto.drawPoints
  1850. .apply(series, arguments);
  1851. // Prepare drawing top points
  1852. i = 0;
  1853. while (i < pointLength) {
  1854. point = series.points[i];
  1855. // Save original props to be overridden by temporary props for top
  1856. // points
  1857. point.origProps = {
  1858. plotY: point.plotY,
  1859. plotX: point.plotX,
  1860. isInside: point.isInside,
  1861. negative: point.negative,
  1862. zone: point.zone,
  1863. y: point.y
  1864. };
  1865. point.lowerGraphic = point.graphic;
  1866. point.graphic = point.upperGraphic;
  1867. point.plotY = point.plotHigh;
  1868. if (defined(point.plotHighX)) {
  1869. point.plotX = point.plotHighX;
  1870. }
  1871. point.y = point.high;
  1872. point.negative = point.high < (series.options.threshold || 0);
  1873. point.zone = (series.zones.length && point.getZone());
  1874. if (!series.chart.polar) {
  1875. point.isInside = point.isTopInside = (typeof point.plotY !== 'undefined' &&
  1876. point.plotY >= 0 &&
  1877. point.plotY <= series.yAxis.len && // #3519
  1878. point.plotX >= 0 &&
  1879. point.plotX <= series.xAxis.len);
  1880. }
  1881. i++;
  1882. }
  1883. // Draw top points
  1884. seriesProto.drawPoints.apply(series, arguments);
  1885. // Reset top points preliminary modifications
  1886. i = 0;
  1887. while (i < pointLength) {
  1888. point = series.points[i];
  1889. point.upperGraphic = point.graphic;
  1890. point.graphic = point.lowerGraphic;
  1891. extend(point, point.origProps);
  1892. delete point.origProps;
  1893. i++;
  1894. }
  1895. },
  1896. /* eslint-enable valid-jsdoc */
  1897. setStackedPoints: noop
  1898. }, {
  1899. /**
  1900. * Range series only. The high or maximum value for each data point.
  1901. * @name Highcharts.Point#high
  1902. * @type {number|undefined}
  1903. */
  1904. /**
  1905. * Range series only. The low or minimum value for each data point.
  1906. * @name Highcharts.Point#low
  1907. * @type {number|undefined}
  1908. */
  1909. /* eslint-disable valid-jsdoc */
  1910. /**
  1911. * @private
  1912. */
  1913. setState: function () {
  1914. var prevState = this.state,
  1915. series = this.series,
  1916. isPolar = series.chart.polar;
  1917. if (!defined(this.plotHigh)) {
  1918. // Boost doesn't calculate plotHigh
  1919. this.plotHigh = series.yAxis.toPixels(this.high, true);
  1920. }
  1921. if (!defined(this.plotLow)) {
  1922. // Boost doesn't calculate plotLow
  1923. this.plotLow = this.plotY = series.yAxis.toPixels(this.low, true);
  1924. }
  1925. if (series.stateMarkerGraphic) {
  1926. series.lowerStateMarkerGraphic = series.stateMarkerGraphic;
  1927. series.stateMarkerGraphic = series.upperStateMarkerGraphic;
  1928. }
  1929. // Change state also for the top marker
  1930. this.graphic = this.upperGraphic;
  1931. this.plotY = this.plotHigh;
  1932. if (isPolar) {
  1933. this.plotX = this.plotHighX;
  1934. }
  1935. // Top state:
  1936. pointProto.setState.apply(this, arguments);
  1937. this.state = prevState;
  1938. // Now restore defaults
  1939. this.plotY = this.plotLow;
  1940. this.graphic = this.lowerGraphic;
  1941. if (isPolar) {
  1942. this.plotX = this.plotLowX;
  1943. }
  1944. if (series.stateMarkerGraphic) {
  1945. series.upperStateMarkerGraphic = series.stateMarkerGraphic;
  1946. series.stateMarkerGraphic = series.lowerStateMarkerGraphic;
  1947. // Lower marker is stored at stateMarkerGraphic
  1948. // to avoid reference duplication (#7021)
  1949. series.lowerStateMarkerGraphic = void 0;
  1950. }
  1951. pointProto.setState.apply(this, arguments);
  1952. },
  1953. haloPath: function () {
  1954. var isPolar = this.series.chart.polar,
  1955. path = [];
  1956. // Bottom halo
  1957. this.plotY = this.plotLow;
  1958. if (isPolar) {
  1959. this.plotX = this.plotLowX;
  1960. }
  1961. if (this.isInside) {
  1962. path = pointProto.haloPath.apply(this, arguments);
  1963. }
  1964. // Top halo
  1965. this.plotY = this.plotHigh;
  1966. if (isPolar) {
  1967. this.plotX = this.plotHighX;
  1968. }
  1969. if (this.isTopInside) {
  1970. path = path.concat(pointProto.haloPath.apply(this, arguments));
  1971. }
  1972. return path;
  1973. },
  1974. destroyElements: function () {
  1975. var graphics = ['lowerGraphic', 'upperGraphic'];
  1976. graphics.forEach(function (graphicName) {
  1977. if (this[graphicName]) {
  1978. this[graphicName] =
  1979. this[graphicName].destroy();
  1980. }
  1981. }, this);
  1982. // Clear graphic for states, removed in the above each:
  1983. this.graphic = null;
  1984. return pointProto.destroyElements.apply(this, arguments);
  1985. },
  1986. isValid: function () {
  1987. return isNumber(this.low) && isNumber(this.high);
  1988. }
  1989. /* eslint-enable valid-jsdoc */
  1990. });
  1991. /**
  1992. * A `arearange` series. If the [type](#series.arearange.type) option is not
  1993. * specified, it is inherited from [chart.type](#chart.type).
  1994. *
  1995. *
  1996. * @extends series,plotOptions.arearange
  1997. * @excluding dataParser, dataURL, stack, stacking
  1998. * @product highcharts highstock
  1999. * @requires highcharts-more
  2000. * @apioption series.arearange
  2001. */
  2002. /**
  2003. * @see [fillColor](#series.arearange.fillColor)
  2004. * @see [fillOpacity](#series.arearange.fillOpacity)
  2005. *
  2006. * @apioption series.arearange.color
  2007. */
  2008. /**
  2009. * An array of data points for the series. For the `arearange` series type,
  2010. * points can be given in the following ways:
  2011. *
  2012. * 1. An array of arrays with 3 or 2 values. In this case, the values
  2013. * correspond to `x,low,high`. If the first value is a string, it is
  2014. * applied as the name of the point, and the `x` value is inferred.
  2015. * The `x` value can also be omitted, in which case the inner arrays
  2016. * should be of length 2\. Then the `x` value is automatically calculated,
  2017. * either starting at 0 and incremented by 1, or from `pointStart`
  2018. * and `pointInterval` given in the series options.
  2019. * ```js
  2020. * data: [
  2021. * [0, 8, 3],
  2022. * [1, 1, 1],
  2023. * [2, 6, 8]
  2024. * ]
  2025. * ```
  2026. *
  2027. * 2. An array of objects with named values. The following snippet shows only a
  2028. * few settings, see the complete options set below. If the total number of
  2029. * data points exceeds the series'
  2030. * [turboThreshold](#series.arearange.turboThreshold),
  2031. * this option is not available.
  2032. * ```js
  2033. * data: [{
  2034. * x: 1,
  2035. * low: 9,
  2036. * high: 0,
  2037. * name: "Point2",
  2038. * color: "#00FF00"
  2039. * }, {
  2040. * x: 1,
  2041. * low: 3,
  2042. * high: 4,
  2043. * name: "Point1",
  2044. * color: "#FF00FF"
  2045. * }]
  2046. * ```
  2047. *
  2048. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  2049. * Arrays of numeric x and y
  2050. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  2051. * Arrays of datetime x and y
  2052. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  2053. * Arrays of point.name and y
  2054. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2055. * Config objects
  2056. *
  2057. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  2058. * @extends series.line.data
  2059. * @excluding marker, y
  2060. * @product highcharts highstock
  2061. * @apioption series.arearange.data
  2062. */
  2063. /**
  2064. * @extends series.arearange.dataLabels
  2065. * @product highcharts highstock
  2066. * @apioption series.arearange.data.dataLabels
  2067. */
  2068. /**
  2069. * @see [color](#series.arearange.color)
  2070. * @see [fillOpacity](#series.arearange.fillOpacity)
  2071. *
  2072. * @apioption series.arearange.fillColor
  2073. */
  2074. /**
  2075. * @see [color](#series.arearange.color)
  2076. * @see [fillColor](#series.arearange.fillColor)
  2077. *
  2078. * @default {highcharts} 0.75
  2079. * @default {highstock} 0.75
  2080. * @apioption series.arearange.fillOpacity
  2081. */
  2082. /**
  2083. * The high or maximum value for each data point.
  2084. *
  2085. * @type {number}
  2086. * @product highcharts highstock
  2087. * @apioption series.arearange.data.high
  2088. */
  2089. /**
  2090. * The low or minimum value for each data point.
  2091. *
  2092. * @type {number}
  2093. * @product highcharts highstock
  2094. * @apioption series.arearange.data.low
  2095. */
  2096. ''; // adds doclets above to tranpiled file
  2097. });
  2098. _registerModule(_modules, 'Series/AreaSplineRangeSeries.js', [_modules['Core/Series/Series.js']], function (BaseSeries) {
  2099. /* *
  2100. *
  2101. * (c) 2010-2020 Torstein Honsi
  2102. *
  2103. * License: www.highcharts.com/license
  2104. *
  2105. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2106. *
  2107. * */
  2108. /**
  2109. * The area spline range is a cartesian series type with higher and
  2110. * lower Y values along an X axis. The area inside the range is colored, and
  2111. * the graph outlining the area is a smoothed spline.
  2112. *
  2113. * @sample {highstock|highstock} stock/demo/areasplinerange/
  2114. * Area spline range
  2115. *
  2116. * @extends plotOptions.arearange
  2117. * @since 2.3.0
  2118. * @excluding step, boostThreshold, boostBlending
  2119. * @product highcharts highstock
  2120. * @requires highcharts-more
  2121. * @apioption plotOptions.areasplinerange
  2122. */
  2123. BaseSeries.seriesType('areasplinerange', 'arearange',
  2124. /**
  2125. * @see [fillColor](#plotOptions.areasplinerange.fillColor)
  2126. * @see [fillOpacity](#plotOptions.areasplinerange.fillOpacity)
  2127. *
  2128. * @apioption plotOptions.areasplinerange.color
  2129. */
  2130. /**
  2131. * @see [color](#plotOptions.areasplinerange.color)
  2132. * @see [fillOpacity](#plotOptions.areasplinerange.fillOpacity)
  2133. *
  2134. * @apioption plotOptions.areasplinerange.fillColor
  2135. */
  2136. /**
  2137. * @see [color](#plotOptions.areasplinerange.color)
  2138. * @see [fillColor](#plotOptions.areasplinerange.fillColor)
  2139. *
  2140. * @default {highcharts} 0.75
  2141. * @default {highstock} 0.75
  2142. * @apioption plotOptions.areasplinerange.fillOpacity
  2143. */
  2144. null, {
  2145. getPointSpline: BaseSeries.seriesTypes.spline.prototype.getPointSpline
  2146. });
  2147. /**
  2148. * A `areasplinerange` series. If the [type](#series.areasplinerange.type)
  2149. * option is not specified, it is inherited from [chart.type](#chart.type).
  2150. *
  2151. * @extends series,plotOptions.areasplinerange
  2152. * @excluding dataParser, dataURL, stack, step, boostThreshold, boostBlending
  2153. * @product highcharts highstock
  2154. * @requires highcharts-more
  2155. * @apioption series.areasplinerange
  2156. */
  2157. /**
  2158. * @see [fillColor](#series.areasplinerange.fillColor)
  2159. * @see [fillOpacity](#series.areasplinerange.fillOpacity)
  2160. *
  2161. * @apioption series.areasplinerange.color
  2162. */
  2163. /**
  2164. * An array of data points for the series. For the `areasplinerange`
  2165. * series type, points can be given in the following ways:
  2166. *
  2167. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  2168. * to `x,low,high`. If the first value is a string, it is applied as the name
  2169. * of the point, and the `x` value is inferred. The `x` value can also be
  2170. * omitted, in which case the inner arrays should be of length 2\. Then the
  2171. * `x` value is automatically calculated, either starting at 0 and
  2172. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  2173. * series options.
  2174. * ```js
  2175. * data: [
  2176. * [0, 0, 5],
  2177. * [1, 9, 1],
  2178. * [2, 5, 2]
  2179. * ]
  2180. * ```
  2181. *
  2182. * 2. An array of objects with named values. The following snippet shows only a
  2183. * few settings, see the complete options set below. If the total number of
  2184. * data points exceeds the series'
  2185. * [turboThreshold](#series.areasplinerange.turboThreshold), this option is
  2186. * not available.
  2187. * ```js
  2188. * data: [{
  2189. * x: 1,
  2190. * low: 5,
  2191. * high: 0,
  2192. * name: "Point2",
  2193. * color: "#00FF00"
  2194. * }, {
  2195. * x: 1,
  2196. * low: 4,
  2197. * high: 1,
  2198. * name: "Point1",
  2199. * color: "#FF00FF"
  2200. * }]
  2201. * ```
  2202. *
  2203. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  2204. * Arrays of numeric x and y
  2205. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  2206. * Arrays of datetime x and y
  2207. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  2208. * Arrays of point.name and y
  2209. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2210. * Config objects
  2211. *
  2212. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  2213. * @extends series.arearange.data
  2214. * @product highcharts highstock
  2215. * @apioption series.areasplinerange.data
  2216. */
  2217. /**
  2218. * @see [color](#series.areasplinerange.color)
  2219. * @see [fillOpacity](#series.areasplinerange.fillOpacity)
  2220. *
  2221. * @apioption series.areasplinerange.fillColor
  2222. */
  2223. /**
  2224. * @see [color](#series.areasplinerange.color)
  2225. * @see [fillColor](#series.areasplinerange.fillColor)
  2226. *
  2227. * @default {highcharts} 0.75
  2228. * @default {highstock} 0.75
  2229. * @apioption series.areasplinerange.fillOpacity
  2230. */
  2231. ''; // adds doclets above to transpiled file
  2232. });
  2233. _registerModule(_modules, 'Series/ColumnRangeSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js']], function (BaseSeries, H, O, U) {
  2234. /* *
  2235. *
  2236. * (c) 2010-2020 Torstein Honsi
  2237. *
  2238. * License: www.highcharts.com/license
  2239. *
  2240. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2241. *
  2242. * */
  2243. var noop = H.noop;
  2244. var defaultOptions = O.defaultOptions;
  2245. var clamp = U.clamp,
  2246. merge = U.merge,
  2247. pick = U.pick;
  2248. var columnProto = BaseSeries.seriesTypes.column.prototype;
  2249. /**
  2250. * The column range is a cartesian series type with higher and lower
  2251. * Y values along an X axis. To display horizontal bars, set
  2252. * [chart.inverted](#chart.inverted) to `true`.
  2253. *
  2254. * @sample {highcharts|highstock} highcharts/demo/columnrange/
  2255. * Inverted column range
  2256. *
  2257. * @extends plotOptions.column
  2258. * @since 2.3.0
  2259. * @excluding negativeColor, stacking, softThreshold, threshold
  2260. * @product highcharts highstock
  2261. * @requires highcharts-more
  2262. * @optionparent plotOptions.columnrange
  2263. */
  2264. var columnRangeOptions = {
  2265. /**
  2266. * Extended data labels for range series types. Range series data labels
  2267. * have no `x` and `y` options. Instead,
  2268. they have `xLow`,
  2269. `xHigh`,
  2270. * `yLow` and `yHigh` options to allow the higher and lower data label
  2271. * sets individually.
  2272. *
  2273. * @declare Highcharts.SeriesAreaRangeDataLabelsOptionsObject
  2274. * @extends plotOptions.arearange.dataLabels
  2275. * @since 2.3.0
  2276. * @product highcharts highstock
  2277. * @apioption plotOptions.columnrange.dataLabels
  2278. */
  2279. pointRange: null,
  2280. /** @ignore-option */
  2281. marker: null,
  2282. states: {
  2283. hover: {
  2284. /** @ignore-option */
  2285. halo: false
  2286. }
  2287. }
  2288. };
  2289. /**
  2290. * The ColumnRangeSeries class
  2291. *
  2292. * @private
  2293. * @class
  2294. * @name Highcharts.seriesTypes.columnrange
  2295. *
  2296. * @augments Highcharts.Series
  2297. */
  2298. BaseSeries.seriesType('columnrange', 'arearange', merge(defaultOptions.plotOptions.column, defaultOptions.plotOptions.arearange, columnRangeOptions), {
  2299. // eslint-disable-next-line valid-jsdoc
  2300. /**
  2301. * Translate data points from raw values x and y to plotX and plotY
  2302. * @private
  2303. */
  2304. translate: function () {
  2305. var series = this,
  2306. yAxis = series.yAxis,
  2307. xAxis = series.xAxis,
  2308. startAngleRad = xAxis.startAngleRad,
  2309. start,
  2310. chart = series.chart,
  2311. isRadial = series.xAxis.isRadial,
  2312. safeDistance = Math.max(chart.chartWidth,
  2313. chart.chartHeight) + 999,
  2314. plotHigh;
  2315. // eslint-disable-next-line valid-jsdoc
  2316. /**
  2317. * Don't draw too far outside plot area (#6835)
  2318. * @private
  2319. */
  2320. function safeBounds(pixelPos) {
  2321. return clamp(pixelPos, -safeDistance, safeDistance);
  2322. }
  2323. columnProto.translate.apply(series);
  2324. // Set plotLow and plotHigh
  2325. series.points.forEach(function (point) {
  2326. var shapeArgs = point.shapeArgs,
  2327. minPointLength = series.options.minPointLength,
  2328. heightDifference,
  2329. height,
  2330. y;
  2331. point.plotHigh = plotHigh = safeBounds(yAxis.translate(point.high, 0, 1, 0, 1));
  2332. point.plotLow = safeBounds(point.plotY);
  2333. // adjust shape
  2334. y = plotHigh;
  2335. height = pick(point.rectPlotY, point.plotY) - plotHigh;
  2336. // Adjust for minPointLength
  2337. if (Math.abs(height) < minPointLength) {
  2338. heightDifference = (minPointLength - height);
  2339. height += heightDifference;
  2340. y -= heightDifference / 2;
  2341. // Adjust for negative ranges or reversed Y axis (#1457)
  2342. }
  2343. else if (height < 0) {
  2344. height *= -1;
  2345. y -= height;
  2346. }
  2347. if (isRadial) {
  2348. start = point.barX + startAngleRad;
  2349. point.shapeType = 'arc';
  2350. point.shapeArgs = series.polarArc(y + height, y, start, start + point.pointWidth);
  2351. }
  2352. else {
  2353. shapeArgs.height = height;
  2354. shapeArgs.y = y;
  2355. point.tooltipPos = chart.inverted ?
  2356. [
  2357. yAxis.len + yAxis.pos - chart.plotLeft - y -
  2358. height / 2,
  2359. xAxis.len + xAxis.pos - chart.plotTop -
  2360. shapeArgs.x - shapeArgs.width / 2,
  2361. height
  2362. ] : [
  2363. xAxis.left - chart.plotLeft + shapeArgs.x +
  2364. shapeArgs.width / 2,
  2365. yAxis.pos - chart.plotTop + y + height / 2,
  2366. height
  2367. ]; // don't inherit from column tooltip position - #3372
  2368. }
  2369. });
  2370. },
  2371. directTouch: true,
  2372. trackerGroups: ['group', 'dataLabelsGroup'],
  2373. drawGraph: noop,
  2374. getSymbol: noop,
  2375. // Overrides from modules that may be loaded after this module
  2376. crispCol: function () {
  2377. return columnProto.crispCol.apply(this, arguments);
  2378. },
  2379. drawPoints: function () {
  2380. return columnProto.drawPoints.apply(this, arguments);
  2381. },
  2382. drawTracker: function () {
  2383. return columnProto.drawTracker.apply(this, arguments);
  2384. },
  2385. getColumnMetrics: function () {
  2386. return columnProto.getColumnMetrics.apply(this, arguments);
  2387. },
  2388. pointAttribs: function () {
  2389. return columnProto.pointAttribs.apply(this, arguments);
  2390. },
  2391. animate: function () {
  2392. return columnProto.animate.apply(this, arguments);
  2393. },
  2394. polarArc: function () {
  2395. return columnProto.polarArc.apply(this, arguments);
  2396. },
  2397. translate3dPoints: function () {
  2398. return columnProto.translate3dPoints.apply(this, arguments);
  2399. },
  2400. translate3dShapes: function () {
  2401. return columnProto.translate3dShapes.apply(this, arguments);
  2402. }
  2403. }, {
  2404. setState: columnProto.pointClass.prototype.setState
  2405. });
  2406. /**
  2407. * A `columnrange` series. If the [type](#series.columnrange.type)
  2408. * option is not specified, it is inherited from
  2409. * [chart.type](#chart.type).
  2410. *
  2411. * @extends series,plotOptions.columnrange
  2412. * @excluding dataParser, dataURL, stack, stacking
  2413. * @product highcharts highstock
  2414. * @requires highcharts-more
  2415. * @apioption series.columnrange
  2416. */
  2417. /**
  2418. * An array of data points for the series. For the `columnrange` series
  2419. * type, points can be given in the following ways:
  2420. *
  2421. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  2422. * to `x,low,high`. If the first value is a string, it is applied as the name
  2423. * of the point, and the `x` value is inferred. The `x` value can also be
  2424. * omitted, in which case the inner arrays should be of length 2\. Then the
  2425. * `x` value is automatically calculated, either starting at 0 and
  2426. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  2427. * series options.
  2428. * ```js
  2429. * data: [
  2430. * [0, 4, 2],
  2431. * [1, 2, 1],
  2432. * [2, 9, 10]
  2433. * ]
  2434. * ```
  2435. *
  2436. * 2. An array of objects with named values. The following snippet shows only a
  2437. * few settings, see the complete options set below. If the total number of
  2438. * data points exceeds the series'
  2439. * [turboThreshold](#series.columnrange.turboThreshold), this option is not
  2440. * available.
  2441. * ```js
  2442. * data: [{
  2443. * x: 1,
  2444. * low: 0,
  2445. * high: 4,
  2446. * name: "Point2",
  2447. * color: "#00FF00"
  2448. * }, {
  2449. * x: 1,
  2450. * low: 5,
  2451. * high: 3,
  2452. * name: "Point1",
  2453. * color: "#FF00FF"
  2454. * }]
  2455. * ```
  2456. *
  2457. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  2458. * Arrays of numeric x and y
  2459. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  2460. * Arrays of datetime x and y
  2461. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  2462. * Arrays of point.name and y
  2463. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2464. * Config objects
  2465. *
  2466. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  2467. * @extends series.arearange.data
  2468. * @excluding marker
  2469. * @product highcharts highstock
  2470. * @apioption series.columnrange.data
  2471. */
  2472. /**
  2473. * @extends series.columnrange.dataLabels
  2474. * @product highcharts highstock
  2475. * @apioption series.columnrange.data.dataLabels
  2476. */
  2477. /**
  2478. * @excluding halo, lineWidth, lineWidthPlus, marker
  2479. * @product highcharts highstock
  2480. * @apioption series.columnrange.states.hover
  2481. */
  2482. /**
  2483. * @excluding halo, lineWidth, lineWidthPlus, marker
  2484. * @product highcharts highstock
  2485. * @apioption series.columnrange.states.select
  2486. */
  2487. ''; // adds doclets above into transpiled
  2488. });
  2489. _registerModule(_modules, 'Series/ColumnPyramidSeries.js', [_modules['Core/Series/Series.js'], _modules['Series/ColumnSeries.js'], _modules['Core/Utilities.js']], function (BaseSeries, ColumnSeries, U) {
  2490. /* *
  2491. *
  2492. * (c) 2010-2020 Sebastian Bochan
  2493. *
  2494. * License: www.highcharts.com/license
  2495. *
  2496. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2497. *
  2498. * */
  2499. var colProto = ColumnSeries.prototype;
  2500. var clamp = U.clamp,
  2501. pick = U.pick;
  2502. /**
  2503. * The ColumnPyramidSeries class
  2504. *
  2505. * @private
  2506. * @class
  2507. * @name Highcharts.seriesTypes.columnpyramid
  2508. *
  2509. * @augments Highcharts.Series
  2510. */
  2511. BaseSeries.seriesType('columnpyramid', 'column',
  2512. /**
  2513. * Column pyramid series display one pyramid per value along an X axis.
  2514. * To display horizontal pyramids, set [chart.inverted](#chart.inverted) to
  2515. * `true`.
  2516. *
  2517. * @sample {highcharts|highstock} highcharts/demo/column-pyramid/
  2518. * Column pyramid
  2519. * @sample {highcharts|highstock} highcharts/plotoptions/columnpyramid-stacked/
  2520. * Column pyramid stacked
  2521. * @sample {highcharts|highstock} highcharts/plotoptions/columnpyramid-inverted/
  2522. * Column pyramid inverted
  2523. *
  2524. * @extends plotOptions.column
  2525. * @since 7.0.0
  2526. * @product highcharts highstock
  2527. * @excluding boostThreshold, borderRadius, crisp, depth, edgeColor,
  2528. * edgeWidth, groupZPadding, negativeColor, softThreshold,
  2529. * threshold, zoneAxis, zones, boostBlending
  2530. * @requires highcharts-more
  2531. * @optionparent plotOptions.columnpyramid
  2532. */
  2533. {
  2534. // no additions
  2535. }, {
  2536. /* eslint-disable-next-line valid-jsdoc */
  2537. /**
  2538. * Overrides the column translate method
  2539. * @private
  2540. */
  2541. translate: function () {
  2542. var series = this,
  2543. chart = series.chart,
  2544. options = series.options,
  2545. dense = series.dense =
  2546. series.closestPointRange * series.xAxis.transA < 2,
  2547. borderWidth = series.borderWidth = pick(options.borderWidth,
  2548. dense ? 0 : 1 // #3635
  2549. ),
  2550. yAxis = series.yAxis,
  2551. threshold = options.threshold,
  2552. translatedThreshold = series.translatedThreshold =
  2553. yAxis.getThreshold(threshold),
  2554. minPointLength = pick(options.minPointLength, 5),
  2555. metrics = series.getColumnMetrics(),
  2556. pointWidth = metrics.width,
  2557. // postprocessed for border width
  2558. seriesBarW = series.barW =
  2559. Math.max(pointWidth, 1 + 2 * borderWidth),
  2560. pointXOffset = series.pointXOffset = metrics.offset;
  2561. if (chart.inverted) {
  2562. translatedThreshold -= 0.5; // #3355
  2563. }
  2564. // When the pointPadding is 0,
  2565. // we want the pyramids to be packed tightly,
  2566. // so we allow individual pyramids to have individual sizes.
  2567. // When pointPadding is greater,
  2568. // we strive for equal-width columns (#2694).
  2569. if (options.pointPadding) {
  2570. seriesBarW = Math.ceil(seriesBarW);
  2571. }
  2572. colProto.translate.apply(series);
  2573. // Record the new values
  2574. series.points.forEach(function (point) {
  2575. var yBottom = pick(point.yBottom,
  2576. translatedThreshold),
  2577. safeDistance = 999 + Math.abs(yBottom),
  2578. plotY = clamp(point.plotY, -safeDistance,
  2579. yAxis.len + safeDistance),
  2580. // Don't draw too far outside plot area
  2581. // (#1303, #2241, #4264)
  2582. barX = point.plotX + pointXOffset,
  2583. barW = seriesBarW / 2,
  2584. barY = Math.min(plotY,
  2585. yBottom),
  2586. barH = Math.max(plotY,
  2587. yBottom) - barY,
  2588. stackTotal,
  2589. stackHeight,
  2590. topPointY,
  2591. topXwidth,
  2592. bottomXwidth,
  2593. invBarPos,
  2594. x1,
  2595. x2,
  2596. x3,
  2597. x4,
  2598. y1,
  2599. y2;
  2600. point.barX = barX;
  2601. point.pointWidth = pointWidth;
  2602. // Fix the tooltip on center of grouped pyramids
  2603. // (#1216, #424, #3648)
  2604. point.tooltipPos = chart.inverted ?
  2605. [
  2606. yAxis.len + yAxis.pos - chart.plotLeft - plotY,
  2607. series.xAxis.len - barX - barW,
  2608. barH
  2609. ] :
  2610. [
  2611. barX + barW,
  2612. plotY + yAxis.pos - chart.plotTop,
  2613. barH
  2614. ];
  2615. stackTotal =
  2616. threshold + (point.total || point.y);
  2617. // overwrite stacktotal (always 100 / -100)
  2618. if (options.stacking === 'percent') {
  2619. stackTotal =
  2620. threshold + (point.y < 0) ?
  2621. -100 :
  2622. 100;
  2623. }
  2624. // get the highest point (if stack, extract from total)
  2625. topPointY = yAxis.toPixels((stackTotal), true);
  2626. // calculate height of stack (in pixels)
  2627. stackHeight =
  2628. chart.plotHeight - topPointY -
  2629. (chart.plotHeight - translatedThreshold);
  2630. // topXwidth and bottomXwidth = width of lines from the center
  2631. // calculated from tanges proportion.
  2632. // Can not be a NaN #12514
  2633. topXwidth = stackHeight ? (barW * (barY - topPointY)) / stackHeight : 0;
  2634. // like topXwidth, but with height of point
  2635. bottomXwidth = stackHeight ? (barW * (barY + barH - topPointY)) / stackHeight : 0;
  2636. /*
  2637. /\
  2638. / \
  2639. x1,y1,------ x2,y1
  2640. / \
  2641. ----------
  2642. x4,y2 x3,y2
  2643. */
  2644. x1 = barX - topXwidth + barW;
  2645. x2 = barX + topXwidth + barW;
  2646. x3 = barX + bottomXwidth + barW;
  2647. x4 = barX - bottomXwidth + barW;
  2648. y1 = barY - minPointLength;
  2649. y2 = barY + barH;
  2650. if (point.y < 0) {
  2651. y1 = barY;
  2652. y2 = barY + barH + minPointLength;
  2653. }
  2654. // inverted chart
  2655. if (chart.inverted) {
  2656. invBarPos = chart.plotWidth - barY;
  2657. stackHeight = (topPointY -
  2658. (chart.plotWidth - translatedThreshold));
  2659. // proportion tanges
  2660. topXwidth = (barW *
  2661. (topPointY - invBarPos)) / stackHeight;
  2662. bottomXwidth = (barW *
  2663. (topPointY - (invBarPos - barH))) / stackHeight;
  2664. x1 = barX + barW + topXwidth; // top bottom
  2665. x2 = x1 - 2 * topXwidth; // top top
  2666. x3 = barX - bottomXwidth + barW; // bottom top
  2667. x4 = barX + bottomXwidth + barW; // bottom bottom
  2668. y1 = barY;
  2669. y2 = barY + barH - minPointLength;
  2670. if (point.y < 0) {
  2671. y2 = barY + barH + minPointLength;
  2672. }
  2673. }
  2674. // Register shape type and arguments to be used in drawPoints
  2675. point.shapeType = 'path';
  2676. point.shapeArgs = {
  2677. // args for datalabels positioning
  2678. x: x1,
  2679. y: y1,
  2680. width: x2 - x1,
  2681. height: barH,
  2682. // path of pyramid
  2683. d: [
  2684. ['M', x1, y1],
  2685. ['L', x2, y1],
  2686. ['L', x3, y2],
  2687. ['L', x4, y2],
  2688. ['Z']
  2689. ]
  2690. };
  2691. });
  2692. }
  2693. });
  2694. /**
  2695. * A `columnpyramid` series. If the [type](#series.columnpyramid.type) option is
  2696. * not specified, it is inherited from [chart.type](#chart.type).
  2697. *
  2698. * @extends series,plotOptions.columnpyramid
  2699. * @excluding connectEnds, connectNulls, dashStyle, dataParser, dataURL,
  2700. * gapSize, gapUnit, linecap, lineWidth, marker, step,
  2701. * boostThreshold, boostBlending
  2702. * @product highcharts highstock
  2703. * @requires highcharts-more
  2704. * @apioption series.columnpyramid
  2705. */
  2706. /**
  2707. * @excluding halo, lineWidth, lineWidthPlus, marker
  2708. * @product highcharts highstock
  2709. * @apioption series.columnpyramid.states.hover
  2710. */
  2711. /**
  2712. * @excluding halo, lineWidth, lineWidthPlus, marker
  2713. * @product highcharts highstock
  2714. * @apioption series.columnpyramid.states.select
  2715. */
  2716. /**
  2717. * An array of data points for the series. For the `columnpyramid` series type,
  2718. * points can be given in the following ways:
  2719. *
  2720. * 1. An array of numerical values. In this case, the numerical values will be
  2721. * interpreted as `y` options. The `x` values will be automatically
  2722. * calculated, either starting at 0 and incremented by 1, or from
  2723. * `pointStart` and `pointInterval` given in the series options. If the axis
  2724. * has categories, these will be used. Example:
  2725. * ```js
  2726. * data: [0, 5, 3, 5]
  2727. * ```
  2728. *
  2729. * 2. An array of arrays with 2 values. In this case, the values correspond to
  2730. * `x,y`. If the first value is a string, it is applied as the name of the
  2731. * point, and the `x` value is inferred.
  2732. * ```js
  2733. * data: [
  2734. * [0, 6],
  2735. * [1, 2],
  2736. * [2, 6]
  2737. * ]
  2738. * ```
  2739. *
  2740. * 3. An array of objects with named values. The objects are point configuration
  2741. * objects as seen below. If the total number of data points exceeds the
  2742. * series' [turboThreshold](#series.columnpyramid.turboThreshold), this
  2743. * option is not available.
  2744. * ```js
  2745. * data: [{
  2746. * x: 1,
  2747. * y: 9,
  2748. * name: "Point2",
  2749. * color: "#00FF00"
  2750. * }, {
  2751. * x: 1,
  2752. * y: 6,
  2753. * name: "Point1",
  2754. * color: "#FF00FF"
  2755. * }]
  2756. * ```
  2757. *
  2758. * @sample {highcharts} highcharts/chart/reflow-true/
  2759. * Numerical values
  2760. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  2761. * Arrays of numeric x and y
  2762. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  2763. * Arrays of datetime x and y
  2764. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  2765. * Arrays of point.name and y
  2766. * @sample {highcharts} highcharts/series/data-array-of-objects/
  2767. * Config objects
  2768. *
  2769. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  2770. * @extends series.line.data
  2771. * @excluding marker
  2772. * @product highcharts highstock
  2773. * @apioption series.columnpyramid.data
  2774. */
  2775. ''; // adds doclets above to transpiled file;
  2776. });
  2777. _registerModule(_modules, 'Series/GaugeSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (BaseSeries, H, U) {
  2778. /* *
  2779. *
  2780. * (c) 2010-2020 Torstein Honsi
  2781. *
  2782. * License: www.highcharts.com/license
  2783. *
  2784. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2785. *
  2786. * */
  2787. var noop = H.noop;
  2788. var clamp = U.clamp,
  2789. isNumber = U.isNumber,
  2790. merge = U.merge,
  2791. pick = U.pick,
  2792. pInt = U.pInt;
  2793. var Series = H.Series,
  2794. TrackerMixin = H.TrackerMixin;
  2795. /**
  2796. * Gauges are circular plots displaying one or more values with a dial pointing
  2797. * to values along the perimeter.
  2798. *
  2799. * @sample highcharts/demo/gauge-speedometer/
  2800. * Gauge chart
  2801. *
  2802. * @extends plotOptions.line
  2803. * @excluding animationLimit, boostThreshold, colorAxis, colorKey,
  2804. * connectEnds, connectNulls, cropThreshold, dashStyle, dragDrop,
  2805. * findNearestPointBy, getExtremesFromAll, marker, negativeColor,
  2806. * pointPlacement, shadow, softThreshold, stacking, states, step,
  2807. * threshold, turboThreshold, xAxis, zoneAxis, zones, dataSorting,
  2808. * boostBlending
  2809. * @product highcharts
  2810. * @requires highcharts-more
  2811. * @optionparent plotOptions.gauge
  2812. */
  2813. BaseSeries.seriesType('gauge', 'line', {
  2814. /**
  2815. * When this option is `true`, the dial will wrap around the axes. For
  2816. * instance, in a full-range gauge going from 0 to 360, a value of 400
  2817. * will point to 40\. When `wrap` is `false`, the dial stops at 360.
  2818. *
  2819. * @see [overshoot](#plotOptions.gauge.overshoot)
  2820. *
  2821. * @type {boolean}
  2822. * @default true
  2823. * @since 3.0
  2824. * @product highcharts
  2825. * @apioption plotOptions.gauge.wrap
  2826. */
  2827. /**
  2828. * Data labels for the gauge. For gauges, the data labels are enabled
  2829. * by default and shown in a bordered box below the point.
  2830. *
  2831. * @since 2.3.0
  2832. * @product highcharts
  2833. */
  2834. dataLabels: {
  2835. borderColor: '#cccccc',
  2836. borderRadius: 3,
  2837. borderWidth: 1,
  2838. crop: false,
  2839. defer: false,
  2840. enabled: true,
  2841. verticalAlign: 'top',
  2842. y: 15,
  2843. zIndex: 2
  2844. },
  2845. /**
  2846. * Options for the dial or arrow pointer of the gauge.
  2847. *
  2848. * In styled mode, the dial is styled with the
  2849. * `.highcharts-gauge-series .highcharts-dial` rule.
  2850. *
  2851. * @sample {highcharts} highcharts/css/gauge/
  2852. * Styled mode
  2853. *
  2854. * @type {*}
  2855. * @since 2.3.0
  2856. * @product highcharts
  2857. */
  2858. dial: {},
  2859. /**
  2860. * The length of the dial's base part, relative to the total radius
  2861. * or length of the dial.
  2862. *
  2863. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2864. * Dial options demonstrated
  2865. *
  2866. * @type {string}
  2867. * @default 70%
  2868. * @since 2.3.0
  2869. * @product highcharts
  2870. * @apioption plotOptions.gauge.dial.baseLength
  2871. */
  2872. /**
  2873. * The pixel width of the base of the gauge dial. The base is the part
  2874. * closest to the pivot, defined by baseLength.
  2875. *
  2876. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2877. * Dial options demonstrated
  2878. *
  2879. * @type {number}
  2880. * @default 3
  2881. * @since 2.3.0
  2882. * @product highcharts
  2883. * @apioption plotOptions.gauge.dial.baseWidth
  2884. */
  2885. /**
  2886. * The radius or length of the dial, in percentages relative to the
  2887. * radius of the gauge itself.
  2888. *
  2889. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2890. * Dial options demonstrated
  2891. *
  2892. * @type {string}
  2893. * @default 80%
  2894. * @since 2.3.0
  2895. * @product highcharts
  2896. * @apioption plotOptions.gauge.dial.radius
  2897. */
  2898. /**
  2899. * The length of the dial's rear end, the part that extends out on the
  2900. * other side of the pivot. Relative to the dial's length.
  2901. *
  2902. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2903. * Dial options demonstrated
  2904. *
  2905. * @type {string}
  2906. * @default 10%
  2907. * @since 2.3.0
  2908. * @product highcharts
  2909. * @apioption plotOptions.gauge.dial.rearLength
  2910. */
  2911. /**
  2912. * The width of the top of the dial, closest to the perimeter. The pivot
  2913. * narrows in from the base to the top.
  2914. *
  2915. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2916. * Dial options demonstrated
  2917. *
  2918. * @type {number}
  2919. * @default 1
  2920. * @since 2.3.0
  2921. * @product highcharts
  2922. * @apioption plotOptions.gauge.dial.topWidth
  2923. */
  2924. /**
  2925. * The background or fill color of the gauge's dial.
  2926. *
  2927. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2928. * Dial options demonstrated
  2929. *
  2930. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2931. * @default #000000
  2932. * @since 2.3.0
  2933. * @product highcharts
  2934. * @apioption plotOptions.gauge.dial.backgroundColor
  2935. */
  2936. /**
  2937. * The border color or stroke of the gauge's dial. By default, the
  2938. * borderWidth is 0, so this must be set in addition to a custom border
  2939. * color.
  2940. *
  2941. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2942. * Dial options demonstrated
  2943. *
  2944. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2945. * @default #cccccc
  2946. * @since 2.3.0
  2947. * @product highcharts
  2948. * @apioption plotOptions.gauge.dial.borderColor
  2949. */
  2950. /**
  2951. * The width of the gauge dial border in pixels.
  2952. *
  2953. * @sample {highcharts} highcharts/plotoptions/gauge-dial/
  2954. * Dial options demonstrated
  2955. *
  2956. * @type {number}
  2957. * @default 0
  2958. * @since 2.3.0
  2959. * @product highcharts
  2960. * @apioption plotOptions.gauge.dial.borderWidth
  2961. */
  2962. /**
  2963. * Allow the dial to overshoot the end of the perimeter axis by this
  2964. * many degrees. Say if the gauge axis goes from 0 to 60, a value of
  2965. * 100, or 1000, will show 5 degrees beyond the end of the axis when this
  2966. * option is set to 5.
  2967. *
  2968. * @see [wrap](#plotOptions.gauge.wrap)
  2969. *
  2970. * @sample {highcharts} highcharts/plotoptions/gauge-overshoot/
  2971. * Allow 5 degrees overshoot
  2972. *
  2973. * @type {number}
  2974. * @since 3.0.10
  2975. * @product highcharts
  2976. * @apioption plotOptions.gauge.overshoot
  2977. */
  2978. /**
  2979. * Options for the pivot or the center point of the gauge.
  2980. *
  2981. * In styled mode, the pivot is styled with the
  2982. * `.highcharts-gauge-series .highcharts-pivot` rule.
  2983. *
  2984. * @sample {highcharts} highcharts/css/gauge/
  2985. * Styled mode
  2986. *
  2987. * @type {*}
  2988. * @since 2.3.0
  2989. * @product highcharts
  2990. */
  2991. pivot: {},
  2992. /**
  2993. * The pixel radius of the pivot.
  2994. *
  2995. * @sample {highcharts} highcharts/plotoptions/gauge-pivot/
  2996. * Pivot options demonstrated
  2997. *
  2998. * @type {number}
  2999. * @default 5
  3000. * @since 2.3.0
  3001. * @product highcharts
  3002. * @apioption plotOptions.gauge.pivot.radius
  3003. */
  3004. /**
  3005. * The border or stroke width of the pivot.
  3006. *
  3007. * @sample {highcharts} highcharts/plotoptions/gauge-pivot/
  3008. * Pivot options demonstrated
  3009. *
  3010. * @type {number}
  3011. * @default 0
  3012. * @since 2.3.0
  3013. * @product highcharts
  3014. * @apioption plotOptions.gauge.pivot.borderWidth
  3015. */
  3016. /**
  3017. * The border or stroke color of the pivot. In able to change this,
  3018. * the borderWidth must also be set to something other than the default
  3019. * 0.
  3020. *
  3021. * @sample {highcharts} highcharts/plotoptions/gauge-pivot/
  3022. * Pivot options demonstrated
  3023. *
  3024. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3025. * @default #cccccc
  3026. * @since 2.3.0
  3027. * @product highcharts
  3028. * @apioption plotOptions.gauge.pivot.borderColor
  3029. */
  3030. /**
  3031. * The background color or fill of the pivot.
  3032. *
  3033. * @sample {highcharts} highcharts/plotoptions/gauge-pivot/
  3034. * Pivot options demonstrated
  3035. *
  3036. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3037. * @default #000000
  3038. * @since 2.3.0
  3039. * @product highcharts
  3040. * @apioption plotOptions.gauge.pivot.backgroundColor
  3041. */
  3042. tooltip: {
  3043. headerFormat: ''
  3044. },
  3045. /**
  3046. * Whether to display this particular series or series type in the
  3047. * legend. Defaults to false for gauge series.
  3048. *
  3049. * @since 2.3.0
  3050. * @product highcharts
  3051. */
  3052. showInLegend: false
  3053. // Prototype members
  3054. }, {
  3055. // chart.angular will be set to true when a gauge series is present,
  3056. // and this will be used on the axes
  3057. angular: true,
  3058. directTouch: true,
  3059. drawGraph: noop,
  3060. fixedBox: true,
  3061. forceDL: true,
  3062. noSharedTooltip: true,
  3063. trackerGroups: ['group', 'dataLabelsGroup'],
  3064. /* eslint-disable valid-jsdoc */
  3065. /**
  3066. * Calculate paths etc
  3067. * @private
  3068. */
  3069. translate: function () {
  3070. var series = this,
  3071. yAxis = series.yAxis,
  3072. options = series.options,
  3073. center = yAxis.center;
  3074. series.generatePoints();
  3075. series.points.forEach(function (point) {
  3076. var dialOptions = merge(options.dial,
  3077. point.dial),
  3078. radius = ((pInt(pick(dialOptions.radius, '80%')) * center[2]) /
  3079. 200),
  3080. baseLength = ((pInt(pick(dialOptions.baseLength, '70%')) * radius) /
  3081. 100),
  3082. rearLength = ((pInt(pick(dialOptions.rearLength, '10%')) * radius) /
  3083. 100),
  3084. baseWidth = dialOptions.baseWidth || 3,
  3085. topWidth = dialOptions.topWidth || 1,
  3086. overshoot = options.overshoot,
  3087. rotation = yAxis.startAngleRad + yAxis.translate(point.y,
  3088. null,
  3089. null,
  3090. null,
  3091. true);
  3092. // Handle the wrap and overshoot options
  3093. if (isNumber(overshoot) || options.wrap === false) {
  3094. overshoot = isNumber(overshoot) ?
  3095. (overshoot / 180 * Math.PI) : 0;
  3096. rotation = clamp(rotation, yAxis.startAngleRad - overshoot, yAxis.endAngleRad + overshoot);
  3097. }
  3098. rotation = rotation * 180 / Math.PI;
  3099. point.shapeType = 'path';
  3100. var d = dialOptions.path || [
  3101. ['M', -rearLength, -baseWidth / 2],
  3102. ['L',
  3103. baseLength, -baseWidth / 2],
  3104. ['L',
  3105. radius, -topWidth / 2],
  3106. ['L',
  3107. radius,
  3108. topWidth / 2],
  3109. ['L',
  3110. baseLength,
  3111. baseWidth / 2],
  3112. ['L', -rearLength,
  3113. baseWidth / 2],
  3114. ['Z']
  3115. ];
  3116. point.shapeArgs = {
  3117. d: d,
  3118. translateX: center[0],
  3119. translateY: center[1],
  3120. rotation: rotation
  3121. };
  3122. // Positions for data label
  3123. point.plotX = center[0];
  3124. point.plotY = center[1];
  3125. });
  3126. },
  3127. /**
  3128. * Draw the points where each point is one needle
  3129. * @private
  3130. */
  3131. drawPoints: function () {
  3132. var series = this,
  3133. chart = series.chart,
  3134. center = series.yAxis.center,
  3135. pivot = series.pivot,
  3136. options = series.options,
  3137. pivotOptions = options.pivot,
  3138. renderer = chart.renderer;
  3139. series.points.forEach(function (point) {
  3140. var graphic = point.graphic,
  3141. shapeArgs = point.shapeArgs,
  3142. d = shapeArgs.d,
  3143. dialOptions = merge(options.dial,
  3144. point.dial); // #1233
  3145. if (graphic) {
  3146. graphic.animate(shapeArgs);
  3147. shapeArgs.d = d; // animate alters it
  3148. }
  3149. else {
  3150. point.graphic =
  3151. renderer[point.shapeType](shapeArgs)
  3152. .attr({
  3153. // required by VML when animation is false
  3154. rotation: shapeArgs.rotation,
  3155. zIndex: 1
  3156. })
  3157. .addClass('highcharts-dial')
  3158. .add(series.group);
  3159. }
  3160. // Presentational attributes
  3161. if (!chart.styledMode) {
  3162. point.graphic[graphic ? 'animate' : 'attr']({
  3163. stroke: dialOptions.borderColor || 'none',
  3164. 'stroke-width': dialOptions.borderWidth || 0,
  3165. fill: dialOptions.backgroundColor ||
  3166. '#000000'
  3167. });
  3168. }
  3169. });
  3170. // Add or move the pivot
  3171. if (pivot) {
  3172. pivot.animate({
  3173. translateX: center[0],
  3174. translateY: center[1]
  3175. });
  3176. }
  3177. else {
  3178. series.pivot =
  3179. renderer.circle(0, 0, pick(pivotOptions.radius, 5))
  3180. .attr({
  3181. zIndex: 2
  3182. })
  3183. .addClass('highcharts-pivot')
  3184. .translate(center[0], center[1])
  3185. .add(series.group);
  3186. // Presentational attributes
  3187. if (!chart.styledMode) {
  3188. series.pivot.attr({
  3189. 'stroke-width': pivotOptions.borderWidth || 0,
  3190. stroke: pivotOptions.borderColor ||
  3191. '#cccccc',
  3192. fill: pivotOptions.backgroundColor ||
  3193. '#000000'
  3194. });
  3195. }
  3196. }
  3197. },
  3198. /**
  3199. * Animate the arrow up from startAngle
  3200. * @private
  3201. */
  3202. animate: function (init) {
  3203. var series = this;
  3204. if (!init) {
  3205. series.points.forEach(function (point) {
  3206. var graphic = point.graphic;
  3207. if (graphic) {
  3208. // start value
  3209. graphic.attr({
  3210. rotation: series.yAxis.startAngleRad * 180 / Math.PI
  3211. });
  3212. // animate
  3213. graphic.animate({
  3214. rotation: point.shapeArgs.rotation
  3215. }, series.options.animation);
  3216. }
  3217. });
  3218. }
  3219. },
  3220. /**
  3221. * @private
  3222. */
  3223. render: function () {
  3224. this.group = this.plotGroup('group', 'series', this.visible ? 'visible' : 'hidden', this.options.zIndex, this.chart.seriesGroup);
  3225. Series.prototype.render.call(this);
  3226. this.group.clip(this.chart.clipRect);
  3227. },
  3228. /**
  3229. * Extend the basic setData method by running processData and generatePoints
  3230. * immediately, in order to access the points from the legend.
  3231. * @private
  3232. */
  3233. setData: function (data, redraw) {
  3234. Series.prototype.setData.call(this, data, false);
  3235. this.processData();
  3236. this.generatePoints();
  3237. if (pick(redraw, true)) {
  3238. this.chart.redraw();
  3239. }
  3240. },
  3241. /**
  3242. * Define hasData function for non-cartesian series.
  3243. * Returns true if the series has points at all.
  3244. * @private
  3245. */
  3246. hasData: function () {
  3247. return !!this.points.length; // != 0
  3248. },
  3249. // If the tracking module is loaded, add the point tracker
  3250. drawTracker: TrackerMixin && TrackerMixin.drawTrackerPoint
  3251. /* eslint-enable valid-jsdoc */
  3252. }, {
  3253. // Point members
  3254. /* eslint-disable valid-jsdoc */
  3255. /**
  3256. * Don't do any hover colors or anything
  3257. * @private
  3258. */
  3259. setState: function (state) {
  3260. this.state = state;
  3261. }
  3262. /* eslint-enable valid-jsdoc */
  3263. });
  3264. /**
  3265. * A `gauge` series. If the [type](#series.gauge.type) option is not
  3266. * specified, it is inherited from [chart.type](#chart.type).
  3267. *
  3268. * @extends series,plotOptions.gauge
  3269. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  3270. * cropThreshold, dashStyle, dataParser, dataURL, findNearestPointBy,
  3271. * getExtremesFromAll, marker, negativeColor, pointPlacement, shadow,
  3272. * softThreshold, stack, stacking, states, step, threshold,
  3273. * turboThreshold, zoneAxis, zones, dataSorting, boostBlending
  3274. * @product highcharts
  3275. * @requires highcharts-more
  3276. * @apioption series.gauge
  3277. */
  3278. /**
  3279. * An array of data points for the series. For the `gauge` series type,
  3280. * points can be given in the following ways:
  3281. *
  3282. * 1. An array of numerical values. In this case, the numerical values will be
  3283. * interpreted as `y` options. Example:
  3284. * ```js
  3285. * data: [0, 5, 3, 5]
  3286. * ```
  3287. *
  3288. * 2. An array of objects with named values. The following snippet shows only a
  3289. * few settings, see the complete options set below. If the total number of
  3290. * data points exceeds the series'
  3291. * [turboThreshold](#series.gauge.turboThreshold), this option is not
  3292. * available.
  3293. * ```js
  3294. * data: [{
  3295. * y: 6,
  3296. * name: "Point2",
  3297. * color: "#00FF00"
  3298. * }, {
  3299. * y: 8,
  3300. * name: "Point1",
  3301. * color: "#FF00FF"
  3302. * }]
  3303. * ```
  3304. *
  3305. * The typical gauge only contains a single data value.
  3306. *
  3307. * @sample {highcharts} highcharts/chart/reflow-true/
  3308. * Numerical values
  3309. * @sample {highcharts} highcharts/series/data-array-of-objects/
  3310. * Config objects
  3311. *
  3312. * @type {Array<number|null|*>}
  3313. * @extends series.line.data
  3314. * @excluding drilldown, marker, x
  3315. * @product highcharts
  3316. * @apioption series.gauge.data
  3317. */
  3318. ''; // adds the doclets above in the transpiled file
  3319. });
  3320. _registerModule(_modules, 'Series/BoxPlotSeries.js', [_modules['Core/Series/Series.js'], _modules['Series/ColumnSeries.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Series, ColumnSeries, H, U) {
  3321. /* *
  3322. *
  3323. * (c) 2010-2020 Torstein Honsi
  3324. *
  3325. * License: www.highcharts.com/license
  3326. *
  3327. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3328. *
  3329. * */
  3330. var columnProto = ColumnSeries.prototype;
  3331. var noop = H.noop;
  3332. var pick = U.pick;
  3333. /**
  3334. * The boxplot series type.
  3335. *
  3336. * @private
  3337. * @class
  3338. * @name Highcharts.seriesTypes#boxplot
  3339. *
  3340. * @augments Highcharts.Series
  3341. */
  3342. /**
  3343. * A box plot is a convenient way of depicting groups of data through their
  3344. * five-number summaries: the smallest observation (sample minimum), lower
  3345. * quartile (Q1), median (Q2), upper quartile (Q3), and largest observation
  3346. * (sample maximum).
  3347. *
  3348. * @sample highcharts/demo/box-plot/
  3349. * Box plot
  3350. *
  3351. * @extends plotOptions.column
  3352. * @excluding borderColor, borderRadius, borderWidth, groupZPadding, states,
  3353. * boostThreshold, boostBlending
  3354. * @product highcharts
  3355. * @requires highcharts-more
  3356. * @optionparent plotOptions.boxplot
  3357. */
  3358. Series.seriesType('boxplot', 'column', {
  3359. threshold: null,
  3360. tooltip: {
  3361. pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> ' +
  3362. '{series.name}</b><br/>' +
  3363. 'Maximum: {point.high}<br/>' +
  3364. 'Upper quartile: {point.q3}<br/>' +
  3365. 'Median: {point.median}<br/>' +
  3366. 'Lower quartile: {point.q1}<br/>' +
  3367. 'Minimum: {point.low}<br/>'
  3368. },
  3369. /**
  3370. * The length of the whiskers, the horizontal lines marking low and
  3371. * high values. It can be a numerical pixel value, or a percentage
  3372. * value of the box width. Set `0` to disable whiskers.
  3373. *
  3374. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3375. * True by default
  3376. *
  3377. * @type {number|string}
  3378. * @since 3.0
  3379. * @product highcharts
  3380. */
  3381. whiskerLength: '50%',
  3382. /**
  3383. * The fill color of the box.
  3384. *
  3385. * In styled mode, the fill color can be set with the
  3386. * `.highcharts-boxplot-box` class.
  3387. *
  3388. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3389. * Box plot styling
  3390. *
  3391. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3392. * @default #ffffff
  3393. * @since 3.0
  3394. * @product highcharts
  3395. */
  3396. fillColor: '#ffffff',
  3397. /**
  3398. * The width of the line surrounding the box. If any of
  3399. * [stemWidth](#plotOptions.boxplot.stemWidth),
  3400. * [medianWidth](#plotOptions.boxplot.medianWidth)
  3401. * or [whiskerWidth](#plotOptions.boxplot.whiskerWidth) are `null`,
  3402. * the lineWidth also applies to these lines.
  3403. *
  3404. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3405. * Box plot styling
  3406. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  3407. * Error bar styling
  3408. *
  3409. * @since 3.0
  3410. * @product highcharts
  3411. */
  3412. lineWidth: 1,
  3413. /**
  3414. * The color of the median line. If `undefined`, the general series
  3415. * color applies.
  3416. *
  3417. * In styled mode, the median stroke width can be set with the
  3418. * `.highcharts-boxplot-median` class.
  3419. *
  3420. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3421. * Box plot styling
  3422. * @sample {highcharts} highcharts/css/boxplot/
  3423. * Box plot in styled mode
  3424. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  3425. * Error bar styling
  3426. *
  3427. * @type {Highcharts.ColorString|Highcharts.GradientColorObject}
  3428. * @since 3.0
  3429. * @product highcharts
  3430. * @apioption plotOptions.boxplot.medianColor
  3431. */
  3432. /**
  3433. * The pixel width of the median line. If `null`, the
  3434. * [lineWidth](#plotOptions.boxplot.lineWidth) is used.
  3435. *
  3436. * In styled mode, the median stroke width can be set with the
  3437. * `.highcharts-boxplot-median` class.
  3438. *
  3439. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3440. * Box plot styling
  3441. * @sample {highcharts} highcharts/css/boxplot/
  3442. * Box plot in styled mode
  3443. *
  3444. * @type {number|null}
  3445. * @since 3.0
  3446. * @product highcharts
  3447. */
  3448. medianWidth: 2,
  3449. /*
  3450. // States are not working and are removed from docs.
  3451. // Refer to: #2340
  3452. states: {
  3453. hover: {
  3454. brightness: -0.3
  3455. }
  3456. },
  3457. /**
  3458. * The color of the stem, the vertical line extending from the box to
  3459. * the whiskers. If `undefined`, the series color is used.
  3460. *
  3461. * In styled mode, the stem stroke can be set with the
  3462. * `.highcharts-boxplot-stem` class.
  3463. *
  3464. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3465. * Box plot styling
  3466. * @sample {highcharts} highcharts/css/boxplot/
  3467. * Box plot in styled mode
  3468. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  3469. * Error bar styling
  3470. *
  3471. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3472. * @since 3.0
  3473. * @product highcharts
  3474. * @apioption plotOptions.boxplot.stemColor
  3475. */
  3476. /**
  3477. * The dash style of the box.
  3478. *
  3479. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3480. * Box plot styling
  3481. * @sample {highcharts} highcharts/css/boxplot/
  3482. * Box plot in styled mode
  3483. *
  3484. * @type {Highcharts.DashStyleValue}
  3485. * @default Solid
  3486. * @since 8.1.0
  3487. * @product highcharts
  3488. * @apioption plotOptions.boxplot.boxDashStyle
  3489. */
  3490. /**
  3491. * The dash style of the median.
  3492. *
  3493. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3494. * Box plot styling
  3495. * @sample {highcharts} highcharts/css/boxplot/
  3496. * Box plot in styled mode
  3497. *
  3498. * @type {Highcharts.DashStyleValue}
  3499. * @default Solid
  3500. * @since 8.1.0
  3501. * @product highcharts
  3502. * @apioption plotOptions.boxplot.medianDashStyle
  3503. */
  3504. /**
  3505. * The dash style of the stem, the vertical line extending from the
  3506. * box to the whiskers.
  3507. *
  3508. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3509. * Box plot styling
  3510. * @sample {highcharts} highcharts/css/boxplot/
  3511. * Box plot in styled mode
  3512. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  3513. * Error bar styling
  3514. *
  3515. * @type {Highcharts.DashStyleValue}
  3516. * @default Solid
  3517. * @since 3.0
  3518. * @product highcharts
  3519. * @apioption plotOptions.boxplot.stemDashStyle
  3520. */
  3521. /**
  3522. * The dash style of the whiskers.
  3523. *
  3524. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3525. * Box plot styling
  3526. * @sample {highcharts} highcharts/css/boxplot/
  3527. * Box plot in styled mode
  3528. *
  3529. * @type {Highcharts.DashStyleValue}
  3530. * @default Solid
  3531. * @since 8.1.0
  3532. * @product highcharts
  3533. * @apioption plotOptions.boxplot.whiskerDashStyle
  3534. */
  3535. /**
  3536. * The width of the stem, the vertical line extending from the box to
  3537. * the whiskers. If `undefined`, the width is inherited from the
  3538. * [lineWidth](#plotOptions.boxplot.lineWidth) option.
  3539. *
  3540. * In styled mode, the stem stroke width can be set with the
  3541. * `.highcharts-boxplot-stem` class.
  3542. *
  3543. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3544. * Box plot styling
  3545. * @sample {highcharts} highcharts/css/boxplot/
  3546. * Box plot in styled mode
  3547. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  3548. * Error bar styling
  3549. *
  3550. * @type {number}
  3551. * @since 3.0
  3552. * @product highcharts
  3553. * @apioption plotOptions.boxplot.stemWidth
  3554. */
  3555. /**
  3556. * @default high
  3557. * @apioption plotOptions.boxplot.colorKey
  3558. */
  3559. /**
  3560. * The color of the whiskers, the horizontal lines marking low and high
  3561. * values. When `undefined`, the general series color is used.
  3562. *
  3563. * In styled mode, the whisker stroke can be set with the
  3564. * `.highcharts-boxplot-whisker` class .
  3565. *
  3566. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3567. * Box plot styling
  3568. * @sample {highcharts} highcharts/css/boxplot/
  3569. * Box plot in styled mode
  3570. *
  3571. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3572. * @since 3.0
  3573. * @product highcharts
  3574. * @apioption plotOptions.boxplot.whiskerColor
  3575. */
  3576. /**
  3577. * The line width of the whiskers, the horizontal lines marking low and
  3578. * high values. When `undefined`, the general
  3579. * [lineWidth](#plotOptions.boxplot.lineWidth) applies.
  3580. *
  3581. * In styled mode, the whisker stroke width can be set with the
  3582. * `.highcharts-boxplot-whisker` class.
  3583. *
  3584. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3585. * Box plot styling
  3586. * @sample {highcharts} highcharts/css/boxplot/
  3587. * Box plot in styled mode
  3588. *
  3589. * @since 3.0
  3590. * @product highcharts
  3591. */
  3592. whiskerWidth: 2
  3593. },
  3594. /** @lends Highcharts.seriesTypes.boxplot */
  3595. {
  3596. // array point configs are mapped to this
  3597. pointArrayMap: ['low', 'q1', 'median', 'q3', 'high'],
  3598. // return a plain array for speedy calculation
  3599. toYData: function (point) {
  3600. return [point.low, point.q1, point.median, point.q3, point.high];
  3601. },
  3602. // defines the top of the tracker
  3603. pointValKey: 'high',
  3604. // Get presentational attributes
  3605. pointAttribs: function () {
  3606. // No attributes should be set on point.graphic which is the group
  3607. return {};
  3608. },
  3609. // Disable data labels for box plot
  3610. drawDataLabels: noop,
  3611. // Translate data points from raw values x and y to plotX and plotY
  3612. translate: function () {
  3613. var series = this,
  3614. yAxis = series.yAxis,
  3615. pointArrayMap = series.pointArrayMap;
  3616. columnProto.translate.apply(series);
  3617. // do the translation on each point dimension
  3618. series.points.forEach(function (point) {
  3619. pointArrayMap.forEach(function (key) {
  3620. if (point[key] !== null) {
  3621. point[key + 'Plot'] = yAxis.translate(point[key], 0, 1, 0, 1);
  3622. }
  3623. });
  3624. point.plotHigh = point.highPlot; // For data label validation
  3625. });
  3626. },
  3627. // eslint-disable-next-line valid-jsdoc
  3628. /**
  3629. * Draw the data points
  3630. * @private
  3631. */
  3632. drawPoints: function () {
  3633. var series = this,
  3634. points = series.points,
  3635. options = series.options,
  3636. chart = series.chart,
  3637. renderer = chart.renderer,
  3638. q1Plot,
  3639. q3Plot,
  3640. highPlot,
  3641. lowPlot,
  3642. medianPlot,
  3643. medianPath,
  3644. crispCorr,
  3645. crispX = 0,
  3646. boxPath,
  3647. width,
  3648. left,
  3649. right,
  3650. halfWidth,
  3651. // error bar inherits this series type but doesn't do quartiles
  3652. doQuartiles = series.doQuartiles !== false,
  3653. pointWiskerLength,
  3654. whiskerLength = series.options.whiskerLength;
  3655. points.forEach(function (point) {
  3656. var graphic = point.graphic,
  3657. verb = graphic ? 'animate' : 'attr',
  3658. shapeArgs = point.shapeArgs,
  3659. boxAttr = {},
  3660. stemAttr = {},
  3661. whiskersAttr = {},
  3662. medianAttr = {},
  3663. color = point.color || series.color;
  3664. if (typeof point.plotY !== 'undefined') {
  3665. // crisp vector coordinates
  3666. width = Math.round(shapeArgs.width);
  3667. left = Math.floor(shapeArgs.x);
  3668. right = left + width;
  3669. halfWidth = Math.round(width / 2);
  3670. q1Plot = Math.floor(doQuartiles ? point.q1Plot : point.lowPlot);
  3671. q3Plot = Math.floor(doQuartiles ? point.q3Plot : point.lowPlot);
  3672. highPlot = Math.floor(point.highPlot);
  3673. lowPlot = Math.floor(point.lowPlot);
  3674. if (!graphic) {
  3675. point.graphic = graphic = renderer.g('point')
  3676. .add(series.group);
  3677. point.stem = renderer.path()
  3678. .addClass('highcharts-boxplot-stem')
  3679. .add(graphic);
  3680. if (whiskerLength) {
  3681. point.whiskers = renderer.path()
  3682. .addClass('highcharts-boxplot-whisker')
  3683. .add(graphic);
  3684. }
  3685. if (doQuartiles) {
  3686. point.box = renderer.path(boxPath)
  3687. .addClass('highcharts-boxplot-box')
  3688. .add(graphic);
  3689. }
  3690. point.medianShape = renderer.path(medianPath)
  3691. .addClass('highcharts-boxplot-median')
  3692. .add(graphic);
  3693. }
  3694. if (!chart.styledMode) {
  3695. // Stem attributes
  3696. stemAttr.stroke =
  3697. point.stemColor || options.stemColor || color;
  3698. stemAttr['stroke-width'] = pick(point.stemWidth, options.stemWidth, options.lineWidth);
  3699. stemAttr.dashstyle = (point.stemDashStyle ||
  3700. options.stemDashStyle ||
  3701. options.dashStyle);
  3702. point.stem.attr(stemAttr);
  3703. // Whiskers attributes
  3704. if (whiskerLength) {
  3705. whiskersAttr.stroke = (point.whiskerColor ||
  3706. options.whiskerColor ||
  3707. color);
  3708. whiskersAttr['stroke-width'] = pick(point.whiskerWidth, options.whiskerWidth, options.lineWidth);
  3709. whiskersAttr.dashstyle = (point.whiskerDashStyle ||
  3710. options.whiskerDashStyle ||
  3711. options.dashStyle);
  3712. point.whiskers.attr(whiskersAttr);
  3713. }
  3714. if (doQuartiles) {
  3715. boxAttr.fill = (point.fillColor ||
  3716. options.fillColor ||
  3717. color);
  3718. boxAttr.stroke = options.lineColor || color;
  3719. boxAttr['stroke-width'] = options.lineWidth || 0;
  3720. boxAttr.dashstyle = (point.boxDashStyle ||
  3721. options.boxDashStyle ||
  3722. options.dashStyle);
  3723. point.box.attr(boxAttr);
  3724. }
  3725. // Median attributes
  3726. medianAttr.stroke = (point.medianColor ||
  3727. options.medianColor ||
  3728. color);
  3729. medianAttr['stroke-width'] = pick(point.medianWidth, options.medianWidth, options.lineWidth);
  3730. medianAttr.dashstyle = (point.medianDashStyle ||
  3731. options.medianDashStyle ||
  3732. options.dashStyle);
  3733. point.medianShape.attr(medianAttr);
  3734. }
  3735. var d = void 0;
  3736. // The stem
  3737. crispCorr = (point.stem.strokeWidth() % 2) / 2;
  3738. crispX = left + halfWidth + crispCorr;
  3739. d = [
  3740. // stem up
  3741. ['M', crispX, q3Plot],
  3742. ['L', crispX, highPlot],
  3743. // stem down
  3744. ['M', crispX, q1Plot],
  3745. ['L', crispX, lowPlot]
  3746. ];
  3747. point.stem[verb]({ d: d });
  3748. // The box
  3749. if (doQuartiles) {
  3750. crispCorr = (point.box.strokeWidth() % 2) / 2;
  3751. q1Plot = Math.floor(q1Plot) + crispCorr;
  3752. q3Plot = Math.floor(q3Plot) + crispCorr;
  3753. left += crispCorr;
  3754. right += crispCorr;
  3755. d = [
  3756. ['M', left, q3Plot],
  3757. ['L', left, q1Plot],
  3758. ['L', right, q1Plot],
  3759. ['L', right, q3Plot],
  3760. ['L', left, q3Plot],
  3761. ['Z']
  3762. ];
  3763. point.box[verb]({ d: d });
  3764. }
  3765. // The whiskers
  3766. if (whiskerLength) {
  3767. crispCorr = (point.whiskers.strokeWidth() % 2) / 2;
  3768. highPlot = highPlot + crispCorr;
  3769. lowPlot = lowPlot + crispCorr;
  3770. pointWiskerLength = (/%$/).test(whiskerLength) ?
  3771. halfWidth * parseFloat(whiskerLength) / 100 :
  3772. whiskerLength / 2;
  3773. d = [
  3774. // High whisker
  3775. ['M', crispX - pointWiskerLength, highPlot],
  3776. ['L', crispX + pointWiskerLength, highPlot],
  3777. // Low whisker
  3778. ['M', crispX - pointWiskerLength, lowPlot],
  3779. ['L', crispX + pointWiskerLength, lowPlot]
  3780. ];
  3781. point.whiskers[verb]({ d: d });
  3782. }
  3783. // The median
  3784. medianPlot = Math.round(point.medianPlot);
  3785. crispCorr = (point.medianShape.strokeWidth() % 2) / 2;
  3786. medianPlot = medianPlot + crispCorr;
  3787. d = [
  3788. ['M', left, medianPlot],
  3789. ['L', right, medianPlot]
  3790. ];
  3791. point.medianShape[verb]({ d: d });
  3792. }
  3793. });
  3794. },
  3795. setStackedPoints: noop // #3890
  3796. });
  3797. /**
  3798. * A `boxplot` series. If the [type](#series.boxplot.type) option is
  3799. * not specified, it is inherited from [chart.type](#chart.type).
  3800. *
  3801. * @extends series,plotOptions.boxplot
  3802. * @excluding dataParser, dataURL, marker, stack, stacking, states,
  3803. * boostThreshold, boostBlending
  3804. * @product highcharts
  3805. * @requires highcharts-more
  3806. * @apioption series.boxplot
  3807. */
  3808. /**
  3809. * An array of data points for the series. For the `boxplot` series
  3810. * type, points can be given in the following ways:
  3811. *
  3812. * 1. An array of arrays with 6 or 5 values. In this case, the values correspond
  3813. * to `x,low,q1,median,q3,high`. If the first value is a string, it is
  3814. * applied as the name of the point, and the `x` value is inferred. The `x`
  3815. * value can also be omitted, in which case the inner arrays should be of
  3816. * length 5. Then the `x` value is automatically calculated, either starting
  3817. * at 0 and incremented by 1, or from `pointStart` and `pointInterval` given
  3818. * in the series options.
  3819. * ```js
  3820. * data: [
  3821. * [0, 3, 0, 10, 3, 5],
  3822. * [1, 7, 8, 7, 2, 9],
  3823. * [2, 6, 9, 5, 1, 3]
  3824. * ]
  3825. * ```
  3826. *
  3827. * 2. An array of objects with named values. The following snippet shows only a
  3828. * few settings, see the complete options set below. If the total number of
  3829. * data points exceeds the series'
  3830. * [turboThreshold](#series.boxplot.turboThreshold), this option is not
  3831. * available.
  3832. * ```js
  3833. * data: [{
  3834. * x: 1,
  3835. * low: 4,
  3836. * q1: 9,
  3837. * median: 9,
  3838. * q3: 1,
  3839. * high: 10,
  3840. * name: "Point2",
  3841. * color: "#00FF00"
  3842. * }, {
  3843. * x: 1,
  3844. * low: 5,
  3845. * q1: 7,
  3846. * median: 3,
  3847. * q3: 6,
  3848. * high: 2,
  3849. * name: "Point1",
  3850. * color: "#FF00FF"
  3851. * }]
  3852. * ```
  3853. *
  3854. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  3855. * Arrays of numeric x and y
  3856. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  3857. * Arrays of datetime x and y
  3858. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  3859. * Arrays of point.name and y
  3860. * @sample {highcharts} highcharts/series/data-array-of-objects/
  3861. * Config objects
  3862. *
  3863. * @type {Array<Array<(number|string),number,number,number,number>|Array<(number|string),number,number,number,number,number>|*>}
  3864. * @extends series.line.data
  3865. * @excluding marker
  3866. * @product highcharts
  3867. * @apioption series.boxplot.data
  3868. */
  3869. /**
  3870. * The `high` value for each data point, signifying the highest value
  3871. * in the sample set. The top whisker is drawn here.
  3872. *
  3873. * @type {number}
  3874. * @product highcharts
  3875. * @apioption series.boxplot.data.high
  3876. */
  3877. /**
  3878. * The `low` value for each data point, signifying the lowest value
  3879. * in the sample set. The bottom whisker is drawn here.
  3880. *
  3881. * @type {number}
  3882. * @product highcharts
  3883. * @apioption series.boxplot.data.low
  3884. */
  3885. /**
  3886. * The median for each data point. This is drawn as a line through the
  3887. * middle area of the box.
  3888. *
  3889. * @type {number}
  3890. * @product highcharts
  3891. * @apioption series.boxplot.data.median
  3892. */
  3893. /**
  3894. * The lower quartile for each data point. This is the bottom of the
  3895. * box.
  3896. *
  3897. * @type {number}
  3898. * @product highcharts
  3899. * @apioption series.boxplot.data.q1
  3900. */
  3901. /**
  3902. * The higher quartile for each data point. This is the top of the box.
  3903. *
  3904. * @type {number}
  3905. * @product highcharts
  3906. * @apioption series.boxplot.data.q3
  3907. */
  3908. /**
  3909. * The dash style of the box.
  3910. *
  3911. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3912. * Box plot styling
  3913. * @sample {highcharts} highcharts/css/boxplot/
  3914. * Box plot in styled mode
  3915. *
  3916. * @type {Highcharts.DashStyleValue}
  3917. * @default Solid
  3918. * @since 8.1.0
  3919. * @product highcharts
  3920. * @apioption series.boxplot.data.boxDashStyle
  3921. */
  3922. /**
  3923. * The dash style of the median.
  3924. *
  3925. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3926. * Box plot styling
  3927. * @sample {highcharts} highcharts/css/boxplot/
  3928. * Box plot in styled mode
  3929. *
  3930. * @type {Highcharts.DashStyleValue}
  3931. * @default Solid
  3932. * @since 8.1.0
  3933. * @product highcharts
  3934. * @apioption series.boxplot.data.medianDashStyle
  3935. */
  3936. /**
  3937. * The dash style of the stem.
  3938. *
  3939. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3940. * Box plot styling
  3941. * @sample {highcharts} highcharts/css/boxplot/
  3942. * Box plot in styled mode
  3943. *
  3944. * @type {Highcharts.DashStyleValue}
  3945. * @default Solid
  3946. * @since 8.1.0
  3947. * @product highcharts
  3948. * @apioption series.boxplot.data.stemDashStyle
  3949. */
  3950. /**
  3951. * The dash style of the whiskers.
  3952. *
  3953. * @sample {highcharts} highcharts/plotoptions/box-plot-styling/
  3954. * Box plot styling
  3955. * @sample {highcharts} highcharts/css/boxplot/
  3956. * Box plot in styled mode
  3957. *
  3958. * @type {Highcharts.DashStyleValue}
  3959. * @default Solid
  3960. * @since 8.1.0
  3961. * @product highcharts
  3962. * @apioption series.boxplot.data.whiskerDashStyle
  3963. */
  3964. ''; // adds doclets above to transpiled file
  3965. });
  3966. _registerModule(_modules, 'Series/ErrorBarSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js']], function (BaseSeries, H) {
  3967. /* *
  3968. *
  3969. * (c) 2010-2020 Torstein Honsi
  3970. *
  3971. * License: www.highcharts.com/license
  3972. *
  3973. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3974. *
  3975. * */
  3976. var noop = H.noop,
  3977. seriesTypes = BaseSeries.seriesTypes;
  3978. /**
  3979. * Error bars are a graphical representation of the variability of data and are
  3980. * used on graphs to indicate the error, or uncertainty in a reported
  3981. * measurement.
  3982. *
  3983. * @sample highcharts/demo/error-bar/
  3984. * Error bars on a column series
  3985. * @sample highcharts/series-errorbar/on-scatter/
  3986. * Error bars on a scatter series
  3987. *
  3988. * @extends plotOptions.boxplot
  3989. * @excluding boostBlending, boostThreshold
  3990. * @product highcharts highstock
  3991. * @requires highcharts-more
  3992. * @optionparent plotOptions.errorbar
  3993. */
  3994. BaseSeries.seriesType('errorbar', 'boxplot', {
  3995. /**
  3996. * The main color of the bars. This can be overridden by
  3997. * [stemColor](#plotOptions.errorbar.stemColor) and
  3998. * [whiskerColor](#plotOptions.errorbar.whiskerColor) individually.
  3999. *
  4000. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  4001. * Error bar styling
  4002. *
  4003. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4004. * @default #000000
  4005. * @since 3.0
  4006. * @product highcharts
  4007. */
  4008. color: '#000000',
  4009. grouping: false,
  4010. /**
  4011. * The parent series of the error bar. The default value links it to
  4012. * the previous series. Otherwise, use the id of the parent series.
  4013. *
  4014. * @since 3.0
  4015. * @product highcharts
  4016. */
  4017. linkedTo: ':previous',
  4018. tooltip: {
  4019. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.low}</b> - <b>{point.high}</b><br/>'
  4020. },
  4021. /**
  4022. * The line width of the whiskers, the horizontal lines marking low
  4023. * and high values. When `null`, the general
  4024. * [lineWidth](#plotOptions.errorbar.lineWidth) applies.
  4025. *
  4026. * @sample {highcharts} highcharts/plotoptions/error-bar-styling/
  4027. * Error bar styling
  4028. *
  4029. * @type {number}
  4030. * @since 3.0
  4031. * @product highcharts
  4032. */
  4033. whiskerWidth: null
  4034. // Prototype members
  4035. }, {
  4036. type: 'errorbar',
  4037. // array point configs are mapped to this
  4038. pointArrayMap: ['low', 'high'],
  4039. // return a plain array for speedy calculation
  4040. toYData: function (point) {
  4041. return [point.low, point.high];
  4042. },
  4043. pointValKey: 'high',
  4044. doQuartiles: false,
  4045. drawDataLabels: seriesTypes.arearange ?
  4046. function () {
  4047. var valKey = this.pointValKey;
  4048. seriesTypes.arearange.prototype.drawDataLabels.call(this);
  4049. // Arearange drawDataLabels does not reset point.y to high,
  4050. // but to low after drawing (#4133)
  4051. this.data.forEach(function (point) {
  4052. point.y = point[valKey];
  4053. });
  4054. } :
  4055. noop,
  4056. // Get the width and X offset, either on top of the linked series column or
  4057. // standalone
  4058. getColumnMetrics: function () {
  4059. return ((this.linkedParent && this.linkedParent.columnMetrics) ||
  4060. seriesTypes.column.prototype.getColumnMetrics.call(this));
  4061. }
  4062. });
  4063. /**
  4064. * A `errorbar` series. If the [type](#series.errorbar.type) option
  4065. * is not specified, it is inherited from [chart.type](#chart.type).
  4066. *
  4067. * @extends series,plotOptions.errorbar
  4068. * @excluding dataParser, dataURL, stack, stacking, boostThreshold,
  4069. * boostBlending
  4070. * @product highcharts
  4071. * @requires highcharts-more
  4072. * @apioption series.errorbar
  4073. */
  4074. /**
  4075. * An array of data points for the series. For the `errorbar` series
  4076. * type, points can be given in the following ways:
  4077. *
  4078. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  4079. * to `x,low,high`. If the first value is a string, it is applied as the name
  4080. * of the point, and the `x` value is inferred. The `x` value can also be
  4081. * omitted, in which case the inner arrays should be of length 2\. Then the
  4082. * `x` value is automatically calculated, either starting at 0 and
  4083. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  4084. * series options.
  4085. * ```js
  4086. * data: [
  4087. * [0, 10, 2],
  4088. * [1, 1, 8],
  4089. * [2, 4, 5]
  4090. * ]
  4091. * ```
  4092. *
  4093. * 2. An array of objects with named values. The following snippet shows only a
  4094. * few settings, see the complete options set below. If the total number of
  4095. * data points exceeds the series'
  4096. * [turboThreshold](#series.errorbar.turboThreshold), this option is not
  4097. * available.
  4098. * ```js
  4099. * data: [{
  4100. * x: 1,
  4101. * low: 0,
  4102. * high: 0,
  4103. * name: "Point2",
  4104. * color: "#00FF00"
  4105. * }, {
  4106. * x: 1,
  4107. * low: 5,
  4108. * high: 5,
  4109. * name: "Point1",
  4110. * color: "#FF00FF"
  4111. * }]
  4112. * ```
  4113. *
  4114. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  4115. * Arrays of numeric x and y
  4116. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  4117. * Arrays of datetime x and y
  4118. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  4119. * Arrays of point.name and y
  4120. * @sample {highcharts} highcharts/series/data-array-of-objects/
  4121. * Config objects
  4122. *
  4123. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  4124. * @extends series.arearange.data
  4125. * @excluding dataLabels, drilldown, marker, states
  4126. * @product highcharts
  4127. * @apioption series.errorbar.data
  4128. */
  4129. ''; // adds doclets above to transpiled file
  4130. });
  4131. _registerModule(_modules, 'Series/WaterfallSeries.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Series/Series.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Extensions/Stacking.js'], _modules['Core/Utilities.js']], function (Axis, BaseSeries, Chart, H, Point, StackItem, U) {
  4132. /* *
  4133. *
  4134. * (c) 2010-2020 Torstein Honsi
  4135. *
  4136. * License: www.highcharts.com/license
  4137. *
  4138. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4139. *
  4140. * */
  4141. var seriesTypes = BaseSeries.seriesTypes;
  4142. var addEvent = U.addEvent,
  4143. arrayMax = U.arrayMax,
  4144. arrayMin = U.arrayMin,
  4145. correctFloat = U.correctFloat,
  4146. isNumber = U.isNumber,
  4147. objectEach = U.objectEach,
  4148. pick = U.pick;
  4149. var Series = H.Series;
  4150. /**
  4151. * Returns true if the key is a direct property of the object.
  4152. * @private
  4153. * @param {*} obj - Object with property to test
  4154. * @param {string} key - Property key to test
  4155. * @return {boolean} - Whether it is a direct property
  4156. */
  4157. function ownProp(obj, key) {
  4158. return Object.hasOwnProperty.call(obj, key);
  4159. }
  4160. /**
  4161. * @private
  4162. */
  4163. var WaterfallAxis;
  4164. (function (WaterfallAxis) {
  4165. /* *
  4166. *
  4167. * Interfaces
  4168. *
  4169. * */
  4170. /* *
  4171. *
  4172. * Classes
  4173. *
  4174. * */
  4175. /**
  4176. * @private
  4177. */
  4178. var Composition = /** @class */ (function () {
  4179. /* *
  4180. *
  4181. * Constructors
  4182. *
  4183. * */
  4184. /**
  4185. * @private
  4186. */
  4187. function Composition(axis) {
  4188. this.axis = axis;
  4189. this.stacks = {
  4190. changed: false
  4191. };
  4192. }
  4193. /* *
  4194. *
  4195. * Functions
  4196. *
  4197. * */
  4198. /**
  4199. * Calls StackItem.prototype.render function that creates and renders
  4200. * stack total label for each waterfall stack item.
  4201. *
  4202. * @private
  4203. * @function Highcharts.Axis#renderWaterfallStackTotals
  4204. */
  4205. Composition.prototype.renderStackTotals = function () {
  4206. var yAxis = this.axis,
  4207. waterfallStacks = yAxis.waterfall.stacks,
  4208. stackTotalGroup = yAxis.stacking && yAxis.stacking.stackTotalGroup,
  4209. dummyStackItem = new StackItem(yAxis,
  4210. yAxis.options.stackLabels,
  4211. false, 0,
  4212. void 0);
  4213. this.dummyStackItem = dummyStackItem;
  4214. // Render each waterfall stack total
  4215. objectEach(waterfallStacks, function (type) {
  4216. objectEach(type, function (stackItem) {
  4217. dummyStackItem.total = stackItem.stackTotal;
  4218. if (stackItem.label) {
  4219. dummyStackItem.label = stackItem.label;
  4220. }
  4221. StackItem.prototype.render.call(dummyStackItem, stackTotalGroup);
  4222. stackItem.label = dummyStackItem.label;
  4223. delete dummyStackItem.label;
  4224. });
  4225. });
  4226. dummyStackItem.total = null;
  4227. };
  4228. return Composition;
  4229. }());
  4230. WaterfallAxis.Composition = Composition;
  4231. /* *
  4232. *
  4233. * Functions
  4234. *
  4235. * */
  4236. /**
  4237. * @private
  4238. */
  4239. function compose(AxisClass, ChartClass) {
  4240. addEvent(AxisClass, 'init', onInit);
  4241. addEvent(AxisClass, 'afterBuildStacks', onAfterBuildStacks);
  4242. addEvent(AxisClass, 'afterRender', onAfterRender);
  4243. addEvent(ChartClass, 'beforeRedraw', onBeforeRedraw);
  4244. }
  4245. WaterfallAxis.compose = compose;
  4246. /**
  4247. * @private
  4248. */
  4249. function onAfterBuildStacks() {
  4250. var axis = this;
  4251. var stacks = axis.waterfall.stacks;
  4252. if (stacks) {
  4253. stacks.changed = false;
  4254. delete stacks.alreadyChanged;
  4255. }
  4256. }
  4257. /**
  4258. * @private
  4259. */
  4260. function onAfterRender() {
  4261. var axis = this;
  4262. var stackLabelOptions = axis.options.stackLabels;
  4263. if (stackLabelOptions && stackLabelOptions.enabled &&
  4264. axis.waterfall.stacks) {
  4265. axis.waterfall.renderStackTotals();
  4266. }
  4267. }
  4268. /**
  4269. * @private
  4270. */
  4271. function onBeforeRedraw() {
  4272. var axes = this.axes,
  4273. series = this.series,
  4274. i = series.length;
  4275. while (i--) {
  4276. if (series[i].options.stacking) {
  4277. axes.forEach(function (axis) {
  4278. if (!axis.isXAxis) {
  4279. axis.waterfall.stacks.changed = true;
  4280. }
  4281. });
  4282. i = 0;
  4283. }
  4284. }
  4285. }
  4286. /**
  4287. * @private
  4288. */
  4289. function onInit() {
  4290. var axis = this;
  4291. if (!axis.waterfall) {
  4292. axis.waterfall = new Composition(axis);
  4293. }
  4294. }
  4295. })(WaterfallAxis || (WaterfallAxis = {}));
  4296. // eslint-disable-next-line valid-jsdoc
  4297. /**
  4298. * A waterfall chart displays sequentially introduced positive or negative
  4299. * values in cumulative columns.
  4300. *
  4301. * @sample highcharts/demo/waterfall/
  4302. * Waterfall chart
  4303. * @sample highcharts/plotoptions/waterfall-inverted/
  4304. * Horizontal (inverted) waterfall
  4305. * @sample highcharts/plotoptions/waterfall-stacked/
  4306. * Stacked waterfall chart
  4307. *
  4308. * @extends plotOptions.column
  4309. * @excluding boostThreshold, boostBlending
  4310. * @product highcharts
  4311. * @requires highcharts-more
  4312. * @optionparent plotOptions.waterfall
  4313. */
  4314. BaseSeries.seriesType('waterfall', 'column', {
  4315. /**
  4316. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4317. * @apioption plotOptions.waterfall.color
  4318. */
  4319. /**
  4320. * The color used specifically for positive point columns. When not
  4321. * specified, the general series color is used.
  4322. *
  4323. * In styled mode, the waterfall colors can be set with the
  4324. * `.highcharts-point-negative`, `.highcharts-sum` and
  4325. * `.highcharts-intermediate-sum` classes.
  4326. *
  4327. * @sample {highcharts} highcharts/demo/waterfall/
  4328. * Waterfall
  4329. *
  4330. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4331. * @product highcharts
  4332. * @apioption plotOptions.waterfall.upColor
  4333. */
  4334. dataLabels: {
  4335. inside: true
  4336. },
  4337. /**
  4338. * The width of the line connecting waterfall columns.
  4339. *
  4340. * @product highcharts
  4341. */
  4342. lineWidth: 1,
  4343. /**
  4344. * The color of the line that connects columns in a waterfall series.
  4345. *
  4346. * In styled mode, the stroke can be set with the `.highcharts-graph` class.
  4347. *
  4348. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4349. * @since 3.0
  4350. * @product highcharts
  4351. */
  4352. lineColor: '#333333',
  4353. /**
  4354. * A name for the dash style to use for the line connecting the columns
  4355. * of the waterfall series. Possible values: Dash, DashDot, Dot, LongDash,
  4356. * LongDashDot, LongDashDotDot, ShortDash, ShortDashDot, ShortDashDotDot,
  4357. * ShortDot, Solid
  4358. *
  4359. * In styled mode, the stroke dash-array can be set with the
  4360. * `.highcharts-graph` class.
  4361. *
  4362. * @type {Highcharts.DashStyleValue}
  4363. * @since 3.0
  4364. * @product highcharts
  4365. */
  4366. dashStyle: 'Dot',
  4367. /**
  4368. * The color of the border of each waterfall column.
  4369. *
  4370. * In styled mode, the border stroke can be set with the
  4371. * `.highcharts-point` class.
  4372. *
  4373. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4374. * @since 3.0
  4375. * @product highcharts
  4376. */
  4377. borderColor: '#333333',
  4378. states: {
  4379. hover: {
  4380. lineWidthPlus: 0 // #3126
  4381. }
  4382. }
  4383. // Prototype members
  4384. }, {
  4385. pointValKey: 'y',
  4386. // Property needed to prevent lines between the columns from disappearing
  4387. // when negativeColor is used.
  4388. showLine: true,
  4389. // After generating points, set y-values for all sums.
  4390. generatePoints: function () {
  4391. var point,
  4392. len,
  4393. i,
  4394. y;
  4395. // Parent call:
  4396. seriesTypes.column.prototype.generatePoints.apply(this);
  4397. for (i = 0, len = this.points.length; i < len; i++) {
  4398. point = this.points[i];
  4399. y = this.processedYData[i];
  4400. // override point value for sums
  4401. // #3710 Update point does not propagate to sum
  4402. if (point.isIntermediateSum || point.isSum) {
  4403. point.y = correctFloat(y);
  4404. }
  4405. }
  4406. },
  4407. // Translate data points from raw values
  4408. translate: function () {
  4409. var series = this,
  4410. options = series.options,
  4411. yAxis = series.yAxis,
  4412. len,
  4413. i,
  4414. points,
  4415. point,
  4416. shapeArgs,
  4417. y,
  4418. yValue,
  4419. previousY,
  4420. previousIntermediate,
  4421. range,
  4422. minPointLength = pick(options.minPointLength, 5),
  4423. halfMinPointLength = minPointLength / 2,
  4424. threshold = options.threshold,
  4425. stacking = options.stacking,
  4426. tooltipY,
  4427. actualStack = yAxis.waterfall.stacks[series.stackKey],
  4428. actualStackX,
  4429. dummyStackItem,
  4430. total,
  4431. pointY,
  4432. yPos,
  4433. hPos;
  4434. // run column series translate
  4435. seriesTypes.column.prototype.translate.apply(series);
  4436. previousY = previousIntermediate = threshold;
  4437. points = series.points;
  4438. for (i = 0, len = points.length; i < len; i++) {
  4439. // cache current point object
  4440. point = points[i];
  4441. yValue = series.processedYData[i];
  4442. shapeArgs = point.shapeArgs;
  4443. range = [0, yValue];
  4444. pointY = point.y;
  4445. // code responsible for correct positions of stacked points
  4446. // starts here
  4447. if (stacking) {
  4448. if (actualStack) {
  4449. actualStackX = actualStack[i];
  4450. if (stacking === 'overlap') {
  4451. total =
  4452. actualStackX.stackState[actualStackX.stateIndex--];
  4453. y = pointY >= 0 ? total : total - pointY;
  4454. if (ownProp(actualStackX, 'absolutePos')) {
  4455. delete actualStackX.absolutePos;
  4456. }
  4457. if (ownProp(actualStackX, 'absoluteNeg')) {
  4458. delete actualStackX.absoluteNeg;
  4459. }
  4460. }
  4461. else {
  4462. if (pointY >= 0) {
  4463. total = actualStackX.threshold +
  4464. actualStackX.posTotal;
  4465. actualStackX.posTotal -= pointY;
  4466. y = total;
  4467. }
  4468. else {
  4469. total = actualStackX.threshold +
  4470. actualStackX.negTotal;
  4471. actualStackX.negTotal -= pointY;
  4472. y = total - pointY;
  4473. }
  4474. if (!actualStackX.posTotal) {
  4475. if (ownProp(actualStackX, 'absolutePos')) {
  4476. actualStackX.posTotal =
  4477. actualStackX.absolutePos;
  4478. delete actualStackX.absolutePos;
  4479. }
  4480. }
  4481. if (!actualStackX.negTotal) {
  4482. if (ownProp(actualStackX, 'absoluteNeg')) {
  4483. actualStackX.negTotal =
  4484. actualStackX.absoluteNeg;
  4485. delete actualStackX.absoluteNeg;
  4486. }
  4487. }
  4488. }
  4489. if (!point.isSum) {
  4490. // the connectorThreshold property is later used in
  4491. // getCrispPath function to draw a connector line in a
  4492. // correct place
  4493. actualStackX.connectorThreshold =
  4494. actualStackX.threshold + actualStackX.stackTotal;
  4495. }
  4496. if (yAxis.reversed) {
  4497. yPos = (pointY >= 0) ? (y - pointY) : (y + pointY);
  4498. hPos = y;
  4499. }
  4500. else {
  4501. yPos = y;
  4502. hPos = y - pointY;
  4503. }
  4504. point.below = yPos <= pick(threshold, 0);
  4505. shapeArgs.y = yAxis.translate(yPos, 0, 1, 0, 1);
  4506. shapeArgs.height = Math.abs(shapeArgs.y -
  4507. yAxis.translate(hPos, 0, 1, 0, 1));
  4508. }
  4509. dummyStackItem = yAxis.waterfall.dummyStackItem;
  4510. if (dummyStackItem) {
  4511. dummyStackItem.x = i;
  4512. dummyStackItem.label = actualStack[i].label;
  4513. dummyStackItem.setOffset(series.pointXOffset || 0, series.barW || 0, series.stackedYNeg[i], series.stackedYPos[i]);
  4514. }
  4515. }
  4516. else {
  4517. // up points
  4518. y =
  4519. Math.max(previousY, previousY + pointY) + range[0];
  4520. shapeArgs.y =
  4521. yAxis.translate(y, 0, 1, 0, 1);
  4522. // sum points
  4523. if (point.isSum) {
  4524. shapeArgs.y = yAxis.translate(range[1], 0, 1, 0, 1);
  4525. shapeArgs.height = Math.min(yAxis.translate(range[0], 0, 1, 0, 1), yAxis.len) - shapeArgs.y; // #4256
  4526. }
  4527. else if (point.isIntermediateSum) {
  4528. if (pointY >= 0) {
  4529. yPos = range[1] + previousIntermediate;
  4530. hPos = previousIntermediate;
  4531. }
  4532. else {
  4533. yPos = previousIntermediate;
  4534. hPos = range[1] + previousIntermediate;
  4535. }
  4536. if (yAxis.reversed) {
  4537. // swapping values
  4538. yPos ^= hPos;
  4539. hPos ^= yPos;
  4540. yPos ^= hPos;
  4541. }
  4542. shapeArgs.y = yAxis.translate(yPos, 0, 1, 0, 1);
  4543. shapeArgs.height = Math.abs(shapeArgs.y -
  4544. Math.min(yAxis.translate(hPos, 0, 1, 0, 1), yAxis.len));
  4545. previousIntermediate += range[1];
  4546. // If it's not the sum point, update previous stack end position
  4547. // and get shape height (#3886)
  4548. }
  4549. else {
  4550. shapeArgs.height = yValue > 0 ?
  4551. yAxis.translate(previousY, 0, 1, 0, 1) - shapeArgs.y :
  4552. yAxis.translate(previousY, 0, 1, 0, 1) - yAxis.translate(previousY - yValue, 0, 1, 0, 1);
  4553. previousY += yValue;
  4554. point.below = previousY < pick(threshold, 0);
  4555. }
  4556. // #3952 Negative sum or intermediate sum not rendered correctly
  4557. if (shapeArgs.height < 0) {
  4558. shapeArgs.y += shapeArgs.height;
  4559. shapeArgs.height *= -1;
  4560. }
  4561. }
  4562. point.plotY = shapeArgs.y =
  4563. Math.round(shapeArgs.y) - (series.borderWidth % 2) / 2;
  4564. // #3151
  4565. shapeArgs.height =
  4566. Math.max(Math.round(shapeArgs.height), 0.001);
  4567. point.yBottom = shapeArgs.y + shapeArgs.height;
  4568. if (shapeArgs.height <= minPointLength && !point.isNull) {
  4569. shapeArgs.height = minPointLength;
  4570. shapeArgs.y -= halfMinPointLength;
  4571. point.plotY = shapeArgs.y;
  4572. if (point.y < 0) {
  4573. point.minPointLengthOffset = -halfMinPointLength;
  4574. }
  4575. else {
  4576. point.minPointLengthOffset = halfMinPointLength;
  4577. }
  4578. }
  4579. else {
  4580. if (point.isNull) {
  4581. shapeArgs.width = 0;
  4582. }
  4583. point.minPointLengthOffset = 0;
  4584. }
  4585. // Correct tooltip placement (#3014)
  4586. tooltipY =
  4587. point.plotY + (point.negative ? shapeArgs.height : 0);
  4588. if (series.chart.inverted) {
  4589. point.tooltipPos[0] = yAxis.len - tooltipY;
  4590. }
  4591. else {
  4592. point.tooltipPos[1] = tooltipY;
  4593. }
  4594. }
  4595. },
  4596. // Call default processData then override yData to reflect waterfall's
  4597. // extremes on yAxis
  4598. processData: function (force) {
  4599. var series = this,
  4600. options = series.options,
  4601. yData = series.yData,
  4602. // #3710 Update point does not propagate to sum
  4603. points = options.data,
  4604. point,
  4605. dataLength = yData.length,
  4606. threshold = options.threshold || 0,
  4607. subSum,
  4608. sum,
  4609. dataMin,
  4610. dataMax,
  4611. y,
  4612. i;
  4613. sum = subSum = dataMin = dataMax = 0;
  4614. for (i = 0; i < dataLength; i++) {
  4615. y = yData[i];
  4616. point = points && points[i] ? points[i] : {};
  4617. if (y === 'sum' || point.isSum) {
  4618. yData[i] = correctFloat(sum);
  4619. }
  4620. else if (y === 'intermediateSum' ||
  4621. point.isIntermediateSum) {
  4622. yData[i] = correctFloat(subSum);
  4623. subSum = 0;
  4624. }
  4625. else {
  4626. sum += y;
  4627. subSum += y;
  4628. }
  4629. dataMin = Math.min(sum, dataMin);
  4630. dataMax = Math.max(sum, dataMax);
  4631. }
  4632. Series.prototype.processData.call(this, force);
  4633. // Record extremes only if stacking was not set:
  4634. if (!options.stacking) {
  4635. series.dataMin = dataMin + threshold;
  4636. series.dataMax = dataMax;
  4637. }
  4638. return;
  4639. },
  4640. // Return y value or string if point is sum
  4641. toYData: function (pt) {
  4642. if (pt.isSum) {
  4643. return 'sum';
  4644. }
  4645. if (pt.isIntermediateSum) {
  4646. return 'intermediateSum';
  4647. }
  4648. return pt.y;
  4649. },
  4650. updateParallelArrays: function (point, i) {
  4651. Series.prototype.updateParallelArrays.call(this, point, i);
  4652. // Prevent initial sums from triggering an error (#3245, #7559)
  4653. if (this.yData[0] === 'sum' || this.yData[0] === 'intermediateSum') {
  4654. this.yData[0] = null;
  4655. }
  4656. },
  4657. // Postprocess mapping between options and SVG attributes
  4658. pointAttribs: function (point, state) {
  4659. var upColor = this.options.upColor,
  4660. attr;
  4661. // Set or reset up color (#3710, update to negative)
  4662. if (upColor && !point.options.color) {
  4663. point.color = point.y > 0 ? upColor : null;
  4664. }
  4665. attr = seriesTypes.column.prototype.pointAttribs.call(this, point, state);
  4666. // The dashStyle option in waterfall applies to the graph, not
  4667. // the points
  4668. delete attr.dashstyle;
  4669. return attr;
  4670. },
  4671. // Return an empty path initially, because we need to know the stroke-width
  4672. // in order to set the final path.
  4673. getGraphPath: function () {
  4674. return [['M', 0, 0]];
  4675. },
  4676. // Draw columns' connector lines
  4677. getCrispPath: function () {
  4678. var data = this.data,
  4679. yAxis = this.yAxis,
  4680. length = data.length,
  4681. graphNormalizer = Math.round(this.graph.strokeWidth()) % 2 / 2,
  4682. borderNormalizer = Math.round(this.borderWidth) % 2 / 2,
  4683. reversedXAxis = this.xAxis.reversed,
  4684. reversedYAxis = this.yAxis.reversed,
  4685. stacking = this.options.stacking,
  4686. path = [],
  4687. connectorThreshold,
  4688. prevStack,
  4689. prevStackX,
  4690. prevPoint,
  4691. yPos,
  4692. isPos,
  4693. prevArgs,
  4694. pointArgs,
  4695. i;
  4696. for (i = 1; i < length; i++) {
  4697. pointArgs = data[i].shapeArgs;
  4698. prevPoint = data[i - 1];
  4699. prevArgs = data[i - 1].shapeArgs;
  4700. prevStack = yAxis.waterfall.stacks[this.stackKey];
  4701. isPos = prevPoint.y > 0 ? -prevArgs.height : 0;
  4702. if (prevStack && prevArgs && pointArgs) {
  4703. prevStackX = prevStack[i - 1];
  4704. // y position of the connector is different when series are
  4705. // stacked, yAxis is reversed and it also depends on point's
  4706. // value
  4707. if (stacking) {
  4708. connectorThreshold = prevStackX.connectorThreshold;
  4709. yPos = Math.round((yAxis.translate(connectorThreshold, 0, 1, 0, 1) +
  4710. (reversedYAxis ? isPos : 0))) - graphNormalizer;
  4711. }
  4712. else {
  4713. yPos =
  4714. prevArgs.y + prevPoint.minPointLengthOffset +
  4715. borderNormalizer - graphNormalizer;
  4716. }
  4717. path.push([
  4718. 'M',
  4719. (prevArgs.x || 0) + (reversedXAxis ?
  4720. 0 :
  4721. (prevArgs.width || 0)),
  4722. yPos
  4723. ], [
  4724. 'L',
  4725. (pointArgs.x || 0) + (reversedXAxis ?
  4726. (pointArgs.width || 0) :
  4727. 0),
  4728. yPos
  4729. ]);
  4730. }
  4731. if (!stacking &&
  4732. path.length &&
  4733. prevArgs &&
  4734. ((prevPoint.y < 0 && !reversedYAxis) ||
  4735. (prevPoint.y > 0 && reversedYAxis))) {
  4736. path[path.length - 2][2] += prevArgs.height;
  4737. path[path.length - 1][2] += prevArgs.height;
  4738. }
  4739. }
  4740. return path;
  4741. },
  4742. // The graph is initially drawn with an empty definition, then updated with
  4743. // crisp rendering.
  4744. drawGraph: function () {
  4745. Series.prototype.drawGraph.call(this);
  4746. this.graph.attr({
  4747. d: this.getCrispPath()
  4748. });
  4749. },
  4750. // Waterfall has stacking along the x-values too.
  4751. setStackedPoints: function () {
  4752. var series = this,
  4753. options = series.options,
  4754. waterfallStacks = series.yAxis.waterfall.stacks,
  4755. seriesThreshold = options.threshold,
  4756. stackThreshold = seriesThreshold || 0,
  4757. interSum = stackThreshold,
  4758. stackKey = series.stackKey,
  4759. xData = series.xData,
  4760. xLength = xData.length,
  4761. actualStack,
  4762. actualStackX,
  4763. totalYVal,
  4764. actualSum,
  4765. prevSum,
  4766. statesLen,
  4767. posTotal,
  4768. negTotal,
  4769. xPoint,
  4770. yVal,
  4771. x,
  4772. alreadyChanged,
  4773. changed;
  4774. // function responsible for calculating correct values for stackState
  4775. // array of each stack item. The arguments are: firstS - the value for
  4776. // the first state, nextS - the difference between the previous and the
  4777. // newest state, sInx - counter used in the for that updates each state
  4778. // when necessary, sOff - offset that must be added to each state when
  4779. // they need to be updated (if point isn't a total sum)
  4780. // eslint-disable-next-line require-jsdoc
  4781. function calculateStackState(firstS, nextS, sInx, sOff) {
  4782. if (!statesLen) {
  4783. actualStackX.stackState[0] = firstS;
  4784. statesLen = actualStackX.stackState.length;
  4785. }
  4786. else {
  4787. for (sInx; sInx < statesLen; sInx++) {
  4788. actualStackX.stackState[sInx] += sOff;
  4789. }
  4790. }
  4791. actualStackX.stackState.push(actualStackX.stackState[statesLen - 1] + nextS);
  4792. }
  4793. series.yAxis.stacking.usePercentage = false;
  4794. totalYVal = actualSum = prevSum = stackThreshold;
  4795. // code responsible for creating stacks for waterfall series
  4796. if (series.visible ||
  4797. !series.chart.options.chart.ignoreHiddenSeries) {
  4798. changed = waterfallStacks.changed;
  4799. alreadyChanged = waterfallStacks.alreadyChanged;
  4800. // in case of a redraw, stack for each x value must be
  4801. // emptied (only for the first series in a specific stack)
  4802. // and recalculated once more
  4803. if (alreadyChanged &&
  4804. alreadyChanged.indexOf(stackKey) < 0) {
  4805. changed = true;
  4806. }
  4807. if (!waterfallStacks[stackKey]) {
  4808. waterfallStacks[stackKey] = {};
  4809. }
  4810. actualStack = waterfallStacks[stackKey];
  4811. for (var i = 0; i < xLength; i++) {
  4812. x = xData[i];
  4813. if (!actualStack[x] || changed) {
  4814. actualStack[x] = {
  4815. negTotal: 0,
  4816. posTotal: 0,
  4817. stackTotal: 0,
  4818. threshold: 0,
  4819. stateIndex: 0,
  4820. stackState: [],
  4821. label: ((changed &&
  4822. actualStack[x]) ?
  4823. actualStack[x].label :
  4824. void 0)
  4825. };
  4826. }
  4827. actualStackX = actualStack[x];
  4828. yVal = series.yData[i];
  4829. if (yVal >= 0) {
  4830. actualStackX.posTotal += yVal;
  4831. }
  4832. else {
  4833. actualStackX.negTotal += yVal;
  4834. }
  4835. // points do not exist yet, so raw data is used
  4836. xPoint = options.data[i];
  4837. posTotal = actualStackX.absolutePos =
  4838. actualStackX.posTotal;
  4839. negTotal = actualStackX.absoluteNeg =
  4840. actualStackX.negTotal;
  4841. actualStackX.stackTotal = posTotal + negTotal;
  4842. statesLen = actualStackX.stackState.length;
  4843. if (xPoint && xPoint.isIntermediateSum) {
  4844. calculateStackState(prevSum, actualSum, 0, prevSum);
  4845. prevSum = actualSum;
  4846. actualSum = seriesThreshold;
  4847. // swapping values
  4848. stackThreshold ^= interSum;
  4849. interSum ^= stackThreshold;
  4850. stackThreshold ^= interSum;
  4851. }
  4852. else if (xPoint && xPoint.isSum) {
  4853. calculateStackState(seriesThreshold, totalYVal, statesLen);
  4854. stackThreshold = seriesThreshold;
  4855. }
  4856. else {
  4857. calculateStackState(stackThreshold, yVal, 0, totalYVal);
  4858. if (xPoint) {
  4859. totalYVal += yVal;
  4860. actualSum += yVal;
  4861. }
  4862. }
  4863. actualStackX.stateIndex++;
  4864. actualStackX.threshold = stackThreshold;
  4865. stackThreshold += actualStackX.stackTotal;
  4866. }
  4867. waterfallStacks.changed = false;
  4868. if (!waterfallStacks.alreadyChanged) {
  4869. waterfallStacks.alreadyChanged = [];
  4870. }
  4871. waterfallStacks.alreadyChanged.push(stackKey);
  4872. }
  4873. },
  4874. // Extremes for a non-stacked series are recorded in processData.
  4875. // In case of stacking, use Series.stackedYData to calculate extremes.
  4876. getExtremes: function () {
  4877. var stacking = this.options.stacking,
  4878. yAxis,
  4879. waterfallStacks,
  4880. stackedYNeg,
  4881. stackedYPos;
  4882. if (stacking) {
  4883. yAxis = this.yAxis;
  4884. waterfallStacks = yAxis.waterfall.stacks;
  4885. stackedYNeg = this.stackedYNeg = [];
  4886. stackedYPos = this.stackedYPos = [];
  4887. // the visible y range can be different when stacking is set to
  4888. // overlap and different when it's set to normal
  4889. if (stacking === 'overlap') {
  4890. objectEach(waterfallStacks[this.stackKey], function (stackX) {
  4891. stackedYNeg.push(arrayMin(stackX.stackState));
  4892. stackedYPos.push(arrayMax(stackX.stackState));
  4893. });
  4894. }
  4895. else {
  4896. objectEach(waterfallStacks[this.stackKey], function (stackX) {
  4897. stackedYNeg.push(stackX.negTotal + stackX.threshold);
  4898. stackedYPos.push(stackX.posTotal + stackX.threshold);
  4899. });
  4900. }
  4901. return {
  4902. dataMin: arrayMin(stackedYNeg),
  4903. dataMax: arrayMax(stackedYPos)
  4904. };
  4905. }
  4906. // When not stacking, data extremes have already been computed in the
  4907. // processData function.
  4908. return {
  4909. dataMin: this.dataMin,
  4910. dataMax: this.dataMax
  4911. };
  4912. }
  4913. // Point members
  4914. }, {
  4915. getClassName: function () {
  4916. var className = Point.prototype.getClassName.call(this);
  4917. if (this.isSum) {
  4918. className += ' highcharts-sum';
  4919. }
  4920. else if (this.isIntermediateSum) {
  4921. className += ' highcharts-intermediate-sum';
  4922. }
  4923. return className;
  4924. },
  4925. // Pass the null test in ColumnSeries.translate.
  4926. isValid: function () {
  4927. return (isNumber(this.y) ||
  4928. this.isSum ||
  4929. Boolean(this.isIntermediateSum));
  4930. }
  4931. });
  4932. /**
  4933. * A `waterfall` series. If the [type](#series.waterfall.type) option
  4934. * is not specified, it is inherited from [chart.type](#chart.type).
  4935. *
  4936. * @extends series,plotOptions.waterfall
  4937. * @excluding dataParser, dataURL, boostThreshold, boostBlending
  4938. * @product highcharts
  4939. * @requires highcharts-more
  4940. * @apioption series.waterfall
  4941. */
  4942. /**
  4943. * An array of data points for the series. For the `waterfall` series
  4944. * type, points can be given in the following ways:
  4945. *
  4946. * 1. An array of numerical values. In this case, the numerical values will be
  4947. * interpreted as `y` options. The `x` values will be automatically
  4948. * calculated, either starting at 0 and incremented by 1, or from
  4949. * `pointStart` and `pointInterval` given in the series options. If the axis
  4950. * has categories, these will be used. Example:
  4951. * ```js
  4952. * data: [0, 5, 3, 5]
  4953. * ```
  4954. *
  4955. * 2. An array of arrays with 2 values. In this case, the values correspond to
  4956. * `x,y`. If the first value is a string, it is applied as the name of the
  4957. * point, and the `x` value is inferred.
  4958. * ```js
  4959. * data: [
  4960. * [0, 7],
  4961. * [1, 8],
  4962. * [2, 3]
  4963. * ]
  4964. * ```
  4965. *
  4966. * 3. An array of objects with named values. The following snippet shows only a
  4967. * few settings, see the complete options set below. If the total number of
  4968. * data points exceeds the series'
  4969. * [turboThreshold](#series.waterfall.turboThreshold), this option is not
  4970. * available.
  4971. * ```js
  4972. * data: [{
  4973. * x: 1,
  4974. * y: 8,
  4975. * name: "Point2",
  4976. * color: "#00FF00"
  4977. * }, {
  4978. * x: 1,
  4979. * y: 8,
  4980. * name: "Point1",
  4981. * color: "#FF00FF"
  4982. * }]
  4983. * ```
  4984. *
  4985. * @sample {highcharts} highcharts/chart/reflow-true/
  4986. * Numerical values
  4987. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  4988. * Arrays of numeric x and y
  4989. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  4990. * Arrays of datetime x and y
  4991. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  4992. * Arrays of point.name and y
  4993. * @sample {highcharts} highcharts/series/data-array-of-objects/
  4994. * Config objects
  4995. *
  4996. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  4997. * @extends series.line.data
  4998. * @excluding marker
  4999. * @product highcharts
  5000. * @apioption series.waterfall.data
  5001. */
  5002. /**
  5003. * When this property is true, the points acts as a summary column for
  5004. * the values added or substracted since the last intermediate sum,
  5005. * or since the start of the series. The `y` value is ignored.
  5006. *
  5007. * @sample {highcharts} highcharts/demo/waterfall/
  5008. * Waterfall
  5009. *
  5010. * @type {boolean}
  5011. * @default false
  5012. * @product highcharts
  5013. * @apioption series.waterfall.data.isIntermediateSum
  5014. */
  5015. /**
  5016. * When this property is true, the point display the total sum across
  5017. * the entire series. The `y` value is ignored.
  5018. *
  5019. * @sample {highcharts} highcharts/demo/waterfall/
  5020. * Waterfall
  5021. *
  5022. * @type {boolean}
  5023. * @default false
  5024. * @product highcharts
  5025. * @apioption series.waterfall.data.isSum
  5026. */
  5027. ''; // adds doclets above to transpiled file
  5028. WaterfallAxis.compose(Axis, Chart);
  5029. return WaterfallAxis;
  5030. });
  5031. _registerModule(_modules, 'Series/PolygonSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js']], function (BaseSeries, H, LegendSymbolMixin) {
  5032. /* *
  5033. *
  5034. * (c) 2010-2020 Torstein Honsi
  5035. *
  5036. * License: www.highcharts.com/license
  5037. *
  5038. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5039. *
  5040. * */
  5041. var seriesTypes = BaseSeries.seriesTypes;
  5042. var noop = H.noop;
  5043. var Series = H.Series;
  5044. /**
  5045. * A polygon series can be used to draw any freeform shape in the cartesian
  5046. * coordinate system. A fill is applied with the `color` option, and
  5047. * stroke is applied through `lineWidth` and `lineColor` options.
  5048. *
  5049. * @sample {highcharts} highcharts/demo/polygon/
  5050. * Polygon
  5051. * @sample {highstock} highcharts/demo/polygon/
  5052. * Polygon
  5053. *
  5054. * @extends plotOptions.scatter
  5055. * @since 4.1.0
  5056. * @excluding jitter, softThreshold, threshold, cluster, boostThreshold,
  5057. * boostBlending
  5058. * @product highcharts highstock
  5059. * @requires highcharts-more
  5060. * @optionparent plotOptions.polygon
  5061. */
  5062. BaseSeries.seriesType('polygon', 'scatter', {
  5063. marker: {
  5064. enabled: false,
  5065. states: {
  5066. hover: {
  5067. enabled: false
  5068. }
  5069. }
  5070. },
  5071. stickyTracking: false,
  5072. tooltip: {
  5073. followPointer: true,
  5074. pointFormat: ''
  5075. },
  5076. trackByArea: true
  5077. // Prototype members
  5078. }, {
  5079. type: 'polygon',
  5080. getGraphPath: function () {
  5081. var graphPath = Series.prototype.getGraphPath.call(this),
  5082. i = graphPath.length + 1;
  5083. // Close all segments
  5084. while (i--) {
  5085. if ((i === graphPath.length || graphPath[i][0] === 'M') && i > 0) {
  5086. graphPath.splice(i, 0, ['Z']);
  5087. }
  5088. }
  5089. this.areaPath = graphPath;
  5090. return graphPath;
  5091. },
  5092. drawGraph: function () {
  5093. // Hack into the fill logic in area.drawGraph
  5094. this.options.fillColor = this.color;
  5095. seriesTypes.area.prototype.drawGraph.call(this);
  5096. },
  5097. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  5098. drawTracker: Series.prototype.drawTracker,
  5099. setStackedPoints: noop // No stacking points on polygons (#5310)
  5100. });
  5101. /**
  5102. * A `polygon` series. If the [type](#series.polygon.type) option is
  5103. * not specified, it is inherited from [chart.type](#chart.type).
  5104. *
  5105. * @extends series,plotOptions.polygon
  5106. * @excluding dataParser, dataURL, stack, boostThreshold, boostBlending
  5107. * @product highcharts highstock
  5108. * @requires highcharts-more
  5109. * @apioption series.polygon
  5110. */
  5111. /**
  5112. * An array of data points for the series. For the `polygon` series
  5113. * type, points can be given in the following ways:
  5114. *
  5115. * 1. An array of numerical values. In this case, the numerical values will be
  5116. * interpreted as `y` options. The `x` values will be automatically
  5117. * calculated, either starting at 0 and incremented by 1, or from
  5118. * `pointStart` and `pointInterval` given in the series options. If the axis
  5119. * has categories, these will be used. Example:
  5120. * ```js
  5121. * data: [0, 5, 3, 5]
  5122. * ```
  5123. *
  5124. * 2. An array of arrays with 2 values. In this case, the values correspond to
  5125. * `x,y`. If the first value is a string, it is applied as the name of the
  5126. * point, and the `x` value is inferred.
  5127. * ```js
  5128. * data: [
  5129. * [0, 10],
  5130. * [1, 3],
  5131. * [2, 1]
  5132. * ]
  5133. * ```
  5134. *
  5135. * 3. An array of objects with named values. The following snippet shows only a
  5136. * few settings, see the complete options set below. If the total number of
  5137. * data points exceeds the series'
  5138. * [turboThreshold](#series.polygon.turboThreshold), this option is not
  5139. * available.
  5140. * ```js
  5141. * data: [{
  5142. * x: 1,
  5143. * y: 1,
  5144. * name: "Point2",
  5145. * color: "#00FF00"
  5146. * }, {
  5147. * x: 1,
  5148. * y: 8,
  5149. * name: "Point1",
  5150. * color: "#FF00FF"
  5151. * }]
  5152. * ```
  5153. *
  5154. * @sample {highcharts} highcharts/chart/reflow-true/
  5155. * Numerical values
  5156. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  5157. * Arrays of numeric x and y
  5158. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  5159. * Arrays of datetime x and y
  5160. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  5161. * Arrays of point.name and y
  5162. * @sample {highcharts} highcharts/series/data-array-of-objects/
  5163. * Config objects
  5164. *
  5165. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  5166. * @extends series.line.data
  5167. * @product highcharts highstock
  5168. * @apioption series.polygon.data
  5169. */
  5170. ''; // adds doclets above to transpiled file
  5171. });
  5172. _registerModule(_modules, 'Series/Bubble/BubbleLegend.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/Utilities.js']], function (Chart, Color, H, Legend, U) {
  5173. /* *
  5174. *
  5175. * (c) 2010-2020 Highsoft AS
  5176. *
  5177. * Author: Paweł Potaczek
  5178. *
  5179. * License: www.highcharts.com/license
  5180. *
  5181. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5182. *
  5183. * */
  5184. var color = Color.parse;
  5185. var addEvent = U.addEvent,
  5186. arrayMax = U.arrayMax,
  5187. arrayMin = U.arrayMin,
  5188. isNumber = U.isNumber,
  5189. merge = U.merge,
  5190. objectEach = U.objectEach,
  5191. pick = U.pick,
  5192. setOptions = U.setOptions,
  5193. stableSort = U.stableSort,
  5194. wrap = U.wrap;
  5195. /**
  5196. * @interface Highcharts.BubbleLegendFormatterContextObject
  5197. */ /**
  5198. * The center y position of the range.
  5199. * @name Highcharts.BubbleLegendFormatterContextObject#center
  5200. * @type {number}
  5201. */ /**
  5202. * The radius of the bubble range.
  5203. * @name Highcharts.BubbleLegendFormatterContextObject#radius
  5204. * @type {number}
  5205. */ /**
  5206. * The bubble value.
  5207. * @name Highcharts.BubbleLegendFormatterContextObject#value
  5208. * @type {number}
  5209. */
  5210. ''; // detach doclets above
  5211. var Series = H.Series,
  5212. noop = H.noop;
  5213. setOptions({
  5214. legend: {
  5215. /**
  5216. * The bubble legend is an additional element in legend which
  5217. * presents the scale of the bubble series. Individual bubble ranges
  5218. * can be defined by user or calculated from series. In the case of
  5219. * automatically calculated ranges, a 1px margin of error is
  5220. * permitted.
  5221. *
  5222. * @since 7.0.0
  5223. * @product highcharts highstock highmaps
  5224. * @requires highcharts-more
  5225. * @optionparent legend.bubbleLegend
  5226. */
  5227. bubbleLegend: {
  5228. /**
  5229. * The color of the ranges borders, can be also defined for an
  5230. * individual range.
  5231. *
  5232. * @sample highcharts/bubble-legend/similartoseries/
  5233. * Similar look to the bubble series
  5234. * @sample highcharts/bubble-legend/bordercolor/
  5235. * Individual bubble border color
  5236. *
  5237. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5238. */
  5239. borderColor: void 0,
  5240. /**
  5241. * The width of the ranges borders in pixels, can be also
  5242. * defined for an individual range.
  5243. */
  5244. borderWidth: 2,
  5245. /**
  5246. * An additional class name to apply to the bubble legend'
  5247. * circle graphical elements. This option does not replace
  5248. * default class names of the graphical element.
  5249. *
  5250. * @sample {highcharts} highcharts/css/bubble-legend/
  5251. * Styling by CSS
  5252. *
  5253. * @type {string}
  5254. */
  5255. className: void 0,
  5256. /**
  5257. * The main color of the bubble legend. Applies to ranges, if
  5258. * individual color is not defined.
  5259. *
  5260. * @sample highcharts/bubble-legend/similartoseries/
  5261. * Similar look to the bubble series
  5262. * @sample highcharts/bubble-legend/color/
  5263. * Individual bubble color
  5264. *
  5265. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5266. */
  5267. color: void 0,
  5268. /**
  5269. * An additional class name to apply to the bubble legend's
  5270. * connector graphical elements. This option does not replace
  5271. * default class names of the graphical element.
  5272. *
  5273. * @sample {highcharts} highcharts/css/bubble-legend/
  5274. * Styling by CSS
  5275. *
  5276. * @type {string}
  5277. */
  5278. connectorClassName: void 0,
  5279. /**
  5280. * The color of the connector, can be also defined
  5281. * for an individual range.
  5282. *
  5283. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5284. */
  5285. connectorColor: void 0,
  5286. /**
  5287. * The length of the connectors in pixels. If labels are
  5288. * centered, the distance is reduced to 0.
  5289. *
  5290. * @sample highcharts/bubble-legend/connectorandlabels/
  5291. * Increased connector length
  5292. */
  5293. connectorDistance: 60,
  5294. /**
  5295. * The width of the connectors in pixels.
  5296. *
  5297. * @sample highcharts/bubble-legend/connectorandlabels/
  5298. * Increased connector width
  5299. */
  5300. connectorWidth: 1,
  5301. /**
  5302. * Enable or disable the bubble legend.
  5303. */
  5304. enabled: false,
  5305. /**
  5306. * Options for the bubble legend labels.
  5307. */
  5308. labels: {
  5309. /**
  5310. * An additional class name to apply to the bubble legend
  5311. * label graphical elements. This option does not replace
  5312. * default class names of the graphical element.
  5313. *
  5314. * @sample {highcharts} highcharts/css/bubble-legend/
  5315. * Styling by CSS
  5316. *
  5317. * @type {string}
  5318. */
  5319. className: void 0,
  5320. /**
  5321. * Whether to allow data labels to overlap.
  5322. */
  5323. allowOverlap: false,
  5324. /**
  5325. * A format string for the bubble legend labels. Available
  5326. * variables are the same as for `formatter`.
  5327. *
  5328. * @sample highcharts/bubble-legend/format/
  5329. * Add a unit
  5330. *
  5331. * @type {string}
  5332. */
  5333. format: '',
  5334. /**
  5335. * Available `this` properties are:
  5336. *
  5337. * - `this.value`: The bubble value.
  5338. *
  5339. * - `this.radius`: The radius of the bubble range.
  5340. *
  5341. * - `this.center`: The center y position of the range.
  5342. *
  5343. * @type {Highcharts.FormatterCallbackFunction<Highcharts.BubbleLegendFormatterContextObject>}
  5344. */
  5345. formatter: void 0,
  5346. /**
  5347. * The alignment of the labels compared to the bubble
  5348. * legend. Can be one of `left`, `center` or `right`.
  5349. *
  5350. * @sample highcharts/bubble-legend/connectorandlabels/
  5351. * Labels on left
  5352. *
  5353. * @type {Highcharts.AlignValue}
  5354. */
  5355. align: 'right',
  5356. /**
  5357. * CSS styles for the labels.
  5358. *
  5359. * @type {Highcharts.CSSObject}
  5360. */
  5361. style: {
  5362. /** @ignore-option */
  5363. fontSize: 10,
  5364. /** @ignore-option */
  5365. color: void 0
  5366. },
  5367. /**
  5368. * The x position offset of the label relative to the
  5369. * connector.
  5370. */
  5371. x: 0,
  5372. /**
  5373. * The y position offset of the label relative to the
  5374. * connector.
  5375. */
  5376. y: 0
  5377. },
  5378. /**
  5379. * Miximum bubble legend range size. If values for ranges are
  5380. * not specified, the `minSize` and the `maxSize` are calculated
  5381. * from bubble series.
  5382. */
  5383. maxSize: 60,
  5384. /**
  5385. * Minimum bubble legend range size. If values for ranges are
  5386. * not specified, the `minSize` and the `maxSize` are calculated
  5387. * from bubble series.
  5388. */
  5389. minSize: 10,
  5390. /**
  5391. * The position of the bubble legend in the legend.
  5392. * @sample highcharts/bubble-legend/connectorandlabels/
  5393. * Bubble legend as last item in legend
  5394. */
  5395. legendIndex: 0,
  5396. /**
  5397. * Options for specific range. One range consists of bubble,
  5398. * label and connector.
  5399. *
  5400. * @sample highcharts/bubble-legend/ranges/
  5401. * Manually defined ranges
  5402. * @sample highcharts/bubble-legend/autoranges/
  5403. * Auto calculated ranges
  5404. *
  5405. * @type {Array<*>}
  5406. */
  5407. ranges: {
  5408. /**
  5409. * Range size value, similar to bubble Z data.
  5410. * @type {number}
  5411. */
  5412. value: void 0,
  5413. /**
  5414. * The color of the border for individual range.
  5415. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5416. */
  5417. borderColor: void 0,
  5418. /**
  5419. * The color of the bubble for individual range.
  5420. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5421. */
  5422. color: void 0,
  5423. /**
  5424. * The color of the connector for individual range.
  5425. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5426. */
  5427. connectorColor: void 0
  5428. },
  5429. /**
  5430. * Whether the bubble legend range value should be represented
  5431. * by the area or the width of the bubble. The default, area,
  5432. * corresponds best to the human perception of the size of each
  5433. * bubble.
  5434. *
  5435. * @sample highcharts/bubble-legend/ranges/
  5436. * Size by width
  5437. *
  5438. * @type {Highcharts.BubbleSizeByValue}
  5439. */
  5440. sizeBy: 'area',
  5441. /**
  5442. * When this is true, the absolute value of z determines the
  5443. * size of the bubble. This means that with the default
  5444. * zThreshold of 0, a bubble of value -1 will have the same size
  5445. * as a bubble of value 1, while a bubble of value 0 will have a
  5446. * smaller size according to minSize.
  5447. */
  5448. sizeByAbsoluteValue: false,
  5449. /**
  5450. * Define the visual z index of the bubble legend.
  5451. */
  5452. zIndex: 1,
  5453. /**
  5454. * Ranges with with lower value than zThreshold, are skipped.
  5455. */
  5456. zThreshold: 0
  5457. }
  5458. }
  5459. });
  5460. /* eslint-disable no-invalid-this, valid-jsdoc */
  5461. /**
  5462. * BubbleLegend class.
  5463. *
  5464. * @private
  5465. * @class
  5466. * @name Highcharts.BubbleLegend
  5467. * @param {Highcharts.LegendBubbleLegendOptions} options
  5468. * Bubble legend options
  5469. * @param {Highcharts.Legend} legend
  5470. * Legend
  5471. */
  5472. var BubbleLegend = /** @class */ (function () {
  5473. function BubbleLegend(options, legend) {
  5474. this.chart = void 0;
  5475. this.fontMetrics = void 0;
  5476. this.legend = void 0;
  5477. this.legendGroup = void 0;
  5478. this.legendItem = void 0;
  5479. this.legendItemHeight = void 0;
  5480. this.legendItemWidth = void 0;
  5481. this.legendSymbol = void 0;
  5482. this.maxLabel = void 0;
  5483. this.movementX = void 0;
  5484. this.ranges = void 0;
  5485. this.visible = void 0;
  5486. this.symbols = void 0;
  5487. this.options = void 0;
  5488. this.setState = noop;
  5489. this.init(options, legend);
  5490. }
  5491. /**
  5492. * Create basic bubbleLegend properties similar to item in legend.
  5493. *
  5494. * @private
  5495. * @function Highcharts.BubbleLegend#init
  5496. * @param {Highcharts.LegendBubbleLegendOptions} options
  5497. * Bubble legend options
  5498. * @param {Highcharts.Legend} legend
  5499. * Legend
  5500. * @return {void}
  5501. */
  5502. BubbleLegend.prototype.init = function (options, legend) {
  5503. this.options = options;
  5504. this.visible = true;
  5505. this.chart = legend.chart;
  5506. this.legend = legend;
  5507. };
  5508. /**
  5509. * Depending on the position option, add bubbleLegend to legend items.
  5510. *
  5511. * @private
  5512. * @function Highcharts.BubbleLegend#addToLegend
  5513. * @param {Array<(Highcharts.Point|Highcharts.Series)>}
  5514. * All legend items
  5515. * @return {void}
  5516. */
  5517. BubbleLegend.prototype.addToLegend = function (items) {
  5518. // Insert bubbleLegend into legend items
  5519. items.splice(this.options.legendIndex, 0, this);
  5520. };
  5521. /**
  5522. * Calculate ranges, sizes and call the next steps of bubbleLegend
  5523. * creation.
  5524. *
  5525. * @private
  5526. * @function Highcharts.BubbleLegend#drawLegendSymbol
  5527. * @param {Highcharts.Legend} legend
  5528. * Legend instance
  5529. * @return {void}
  5530. */
  5531. BubbleLegend.prototype.drawLegendSymbol = function (legend) {
  5532. var chart = this.chart,
  5533. options = this.options,
  5534. size,
  5535. itemDistance = pick(legend.options.itemDistance, 20),
  5536. connectorSpace,
  5537. ranges = options.ranges,
  5538. radius,
  5539. maxLabel,
  5540. connectorDistance = options.connectorDistance;
  5541. // Predict label dimensions
  5542. this.fontMetrics = chart.renderer.fontMetrics(options.labels.style.fontSize.toString() + 'px');
  5543. // Do not create bubbleLegend now if ranges or ranges valeus are not
  5544. // specified or if are empty array.
  5545. if (!ranges || !ranges.length || !isNumber(ranges[0].value)) {
  5546. legend.options.bubbleLegend.autoRanges = true;
  5547. return;
  5548. }
  5549. // Sort ranges to right render order
  5550. stableSort(ranges, function (a, b) {
  5551. return b.value - a.value;
  5552. });
  5553. this.ranges = ranges;
  5554. this.setOptions();
  5555. this.render();
  5556. // Get max label size
  5557. maxLabel = this.getMaxLabelSize();
  5558. radius = this.ranges[0].radius;
  5559. size = radius * 2;
  5560. // Space for connectors and labels.
  5561. connectorSpace =
  5562. connectorDistance - radius + maxLabel.width;
  5563. connectorSpace = connectorSpace > 0 ? connectorSpace : 0;
  5564. this.maxLabel = maxLabel;
  5565. this.movementX = options.labels.align === 'left' ?
  5566. connectorSpace : 0;
  5567. this.legendItemWidth = size + connectorSpace + itemDistance;
  5568. this.legendItemHeight = size + this.fontMetrics.h / 2;
  5569. };
  5570. /**
  5571. * Set style options for each bubbleLegend range.
  5572. *
  5573. * @private
  5574. * @function Highcharts.BubbleLegend#setOptions
  5575. * @return {void}
  5576. */
  5577. BubbleLegend.prototype.setOptions = function () {
  5578. var ranges = this.ranges,
  5579. options = this.options,
  5580. series = this.chart.series[options.seriesIndex],
  5581. baseline = this.legend.baseline,
  5582. bubbleStyle = {
  5583. 'z-index': options.zIndex,
  5584. 'stroke-width': options.borderWidth
  5585. },
  5586. connectorStyle = {
  5587. 'z-index': options.zIndex,
  5588. 'stroke-width': options.connectorWidth
  5589. },
  5590. labelStyle = this.getLabelStyles(),
  5591. fillOpacity = series.options.marker.fillOpacity,
  5592. styledMode = this.chart.styledMode;
  5593. // Allow to parts of styles be used individually for range
  5594. ranges.forEach(function (range, i) {
  5595. if (!styledMode) {
  5596. bubbleStyle.stroke = pick(range.borderColor, options.borderColor, series.color);
  5597. bubbleStyle.fill = pick(range.color, options.color, fillOpacity !== 1 ?
  5598. color(series.color).setOpacity(fillOpacity)
  5599. .get('rgba') :
  5600. series.color);
  5601. connectorStyle.stroke = pick(range.connectorColor, options.connectorColor, series.color);
  5602. }
  5603. // Set options needed for rendering each range
  5604. ranges[i].radius = this.getRangeRadius(range.value);
  5605. ranges[i] = merge(ranges[i], {
  5606. center: (ranges[0].radius - ranges[i].radius +
  5607. baseline)
  5608. });
  5609. if (!styledMode) {
  5610. merge(true, ranges[i], {
  5611. bubbleStyle: merge(false, bubbleStyle),
  5612. connectorStyle: merge(false, connectorStyle),
  5613. labelStyle: labelStyle
  5614. });
  5615. }
  5616. }, this);
  5617. };
  5618. /**
  5619. * Merge options for bubbleLegend labels.
  5620. *
  5621. * @private
  5622. * @function Highcharts.BubbleLegend#getLabelStyles
  5623. * @return {Highcharts.CSSObject}
  5624. */
  5625. BubbleLegend.prototype.getLabelStyles = function () {
  5626. var options = this.options,
  5627. additionalLabelsStyle = {},
  5628. labelsOnLeft = options.labels.align === 'left',
  5629. rtl = this.legend.options.rtl;
  5630. // To separate additional style options
  5631. objectEach(options.labels.style, function (value, key) {
  5632. if (key !== 'color' &&
  5633. key !== 'fontSize' &&
  5634. key !== 'z-index') {
  5635. additionalLabelsStyle[key] = value;
  5636. }
  5637. });
  5638. return merge(false, additionalLabelsStyle, {
  5639. 'font-size': options.labels.style.fontSize,
  5640. fill: pick(options.labels.style.color, '#000000'),
  5641. 'z-index': options.zIndex,
  5642. align: rtl || labelsOnLeft ? 'right' : 'left'
  5643. });
  5644. };
  5645. /**
  5646. * Calculate radius for each bubble range,
  5647. * used code from BubbleSeries.js 'getRadius' method.
  5648. *
  5649. * @private
  5650. * @function Highcharts.BubbleLegend#getRangeRadius
  5651. * @param {number} value
  5652. * Range value
  5653. * @return {number|null}
  5654. * Radius for one range
  5655. */
  5656. BubbleLegend.prototype.getRangeRadius = function (value) {
  5657. var options = this.options,
  5658. seriesIndex = this.options.seriesIndex,
  5659. bubbleSeries = this.chart.series[seriesIndex],
  5660. zMax = options.ranges[0].value,
  5661. zMin = options.ranges[options.ranges.length - 1].value,
  5662. minSize = options.minSize,
  5663. maxSize = options.maxSize;
  5664. return bubbleSeries.getRadius.call(this, zMin, zMax, minSize, maxSize, value);
  5665. };
  5666. /**
  5667. * Render the legendSymbol group.
  5668. *
  5669. * @private
  5670. * @function Highcharts.BubbleLegend#render
  5671. * @return {void}
  5672. */
  5673. BubbleLegend.prototype.render = function () {
  5674. var renderer = this.chart.renderer,
  5675. zThreshold = this.options.zThreshold;
  5676. if (!this.symbols) {
  5677. this.symbols = {
  5678. connectors: [],
  5679. bubbleItems: [],
  5680. labels: []
  5681. };
  5682. }
  5683. // Nesting SVG groups to enable handleOverflow
  5684. this.legendSymbol = renderer.g('bubble-legend');
  5685. this.legendItem = renderer.g('bubble-legend-item');
  5686. // To enable default 'hideOverlappingLabels' method
  5687. this.legendSymbol.translateX = 0;
  5688. this.legendSymbol.translateY = 0;
  5689. this.ranges.forEach(function (range) {
  5690. if (range.value >= zThreshold) {
  5691. this.renderRange(range);
  5692. }
  5693. }, this);
  5694. // To use handleOverflow method
  5695. this.legendSymbol.add(this.legendItem);
  5696. this.legendItem.add(this.legendGroup);
  5697. this.hideOverlappingLabels();
  5698. };
  5699. /**
  5700. * Render one range, consisting of bubble symbol, connector and label.
  5701. *
  5702. * @private
  5703. * @function Highcharts.BubbleLegend#renderRange
  5704. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  5705. * Range options
  5706. * @return {void}
  5707. */
  5708. BubbleLegend.prototype.renderRange = function (range) {
  5709. var mainRange = this.ranges[0],
  5710. legend = this.legend,
  5711. options = this.options,
  5712. labelsOptions = options.labels,
  5713. chart = this.chart,
  5714. renderer = chart.renderer,
  5715. symbols = this.symbols,
  5716. labels = symbols.labels,
  5717. label,
  5718. elementCenter = range.center,
  5719. absoluteRadius = Math.abs(range.radius),
  5720. connectorDistance = options.connectorDistance || 0,
  5721. labelsAlign = labelsOptions.align,
  5722. rtl = legend.options.rtl,
  5723. fontSize = labelsOptions.style.fontSize,
  5724. connectorLength = rtl || labelsAlign === 'left' ?
  5725. -connectorDistance : connectorDistance,
  5726. borderWidth = options.borderWidth,
  5727. connectorWidth = options.connectorWidth,
  5728. posX = mainRange.radius || 0,
  5729. posY = elementCenter - absoluteRadius -
  5730. borderWidth / 2 + connectorWidth / 2,
  5731. labelY,
  5732. labelX,
  5733. fontMetrics = this.fontMetrics,
  5734. labelMovement = fontSize / 2 - (fontMetrics.h - fontSize) / 2,
  5735. crispMovement = (posY % 1 ? 1 : 0.5) -
  5736. (connectorWidth % 2 ? 0 : 0.5),
  5737. styledMode = renderer.styledMode;
  5738. // Set options for centered labels
  5739. if (labelsAlign === 'center') {
  5740. connectorLength = 0; // do not use connector
  5741. options.connectorDistance = 0;
  5742. range.labelStyle.align = 'center';
  5743. }
  5744. labelY = posY + options.labels.y;
  5745. labelX = posX + connectorLength + options.labels.x;
  5746. // Render bubble symbol
  5747. symbols.bubbleItems.push(renderer
  5748. .circle(posX, elementCenter + crispMovement, absoluteRadius)
  5749. .attr(styledMode ? {} : range.bubbleStyle)
  5750. .addClass((styledMode ?
  5751. 'highcharts-color-' +
  5752. this.options.seriesIndex + ' ' :
  5753. '') +
  5754. 'highcharts-bubble-legend-symbol ' +
  5755. (options.className || '')).add(this.legendSymbol));
  5756. // Render connector
  5757. symbols.connectors.push(renderer
  5758. .path(renderer.crispLine([
  5759. ['M', posX, posY],
  5760. ['L', posX + connectorLength, posY]
  5761. ], options.connectorWidth))
  5762. .attr(styledMode ? {} : range.connectorStyle)
  5763. .addClass((styledMode ?
  5764. 'highcharts-color-' +
  5765. this.options.seriesIndex + ' ' : '') +
  5766. 'highcharts-bubble-legend-connectors ' +
  5767. (options.connectorClassName || '')).add(this.legendSymbol));
  5768. // Render label
  5769. label = renderer
  5770. .text(this.formatLabel(range), labelX, labelY + labelMovement)
  5771. .attr(styledMode ? {} : range.labelStyle)
  5772. .addClass('highcharts-bubble-legend-labels ' +
  5773. (options.labels.className || '')).add(this.legendSymbol);
  5774. labels.push(label);
  5775. // To enable default 'hideOverlappingLabels' method
  5776. label.placed = true;
  5777. label.alignAttr = {
  5778. x: labelX,
  5779. y: labelY + labelMovement
  5780. };
  5781. };
  5782. /**
  5783. * Get the label which takes up the most space.
  5784. *
  5785. * @private
  5786. * @function Highcharts.BubbleLegend#getMaxLabelSize
  5787. * @return {Highcharts.BBoxObject}
  5788. */
  5789. BubbleLegend.prototype.getMaxLabelSize = function () {
  5790. var labels = this.symbols.labels,
  5791. maxLabel,
  5792. labelSize;
  5793. labels.forEach(function (label) {
  5794. labelSize = label.getBBox(true);
  5795. if (maxLabel) {
  5796. maxLabel = labelSize.width > maxLabel.width ?
  5797. labelSize : maxLabel;
  5798. }
  5799. else {
  5800. maxLabel = labelSize;
  5801. }
  5802. });
  5803. return maxLabel || {};
  5804. };
  5805. /**
  5806. * Get formatted label for range.
  5807. *
  5808. * @private
  5809. * @function Highcharts.BubbleLegend#formatLabel
  5810. * @param {Highcharts.LegendBubbleLegendRangesOptions} range
  5811. * Range options
  5812. * @return {string}
  5813. * Range label text
  5814. */
  5815. BubbleLegend.prototype.formatLabel = function (range) {
  5816. var options = this.options,
  5817. formatter = options.labels.formatter,
  5818. format = options.labels.format;
  5819. var numberFormatter = this.chart.numberFormatter;
  5820. return format ? U.format(format, range) :
  5821. formatter ? formatter.call(range) :
  5822. numberFormatter(range.value, 1);
  5823. };
  5824. /**
  5825. * By using default chart 'hideOverlappingLabels' method, hide or show
  5826. * labels and connectors.
  5827. *
  5828. * @private
  5829. * @function Highcharts.BubbleLegend#hideOverlappingLabels
  5830. * @return {void}
  5831. */
  5832. BubbleLegend.prototype.hideOverlappingLabels = function () {
  5833. var chart = this.chart,
  5834. allowOverlap = this.options.labels.allowOverlap,
  5835. symbols = this.symbols;
  5836. if (!allowOverlap && symbols) {
  5837. chart.hideOverlappingLabels(symbols.labels);
  5838. // Hide or show connectors
  5839. symbols.labels.forEach(function (label, index) {
  5840. if (!label.newOpacity) {
  5841. symbols.connectors[index].hide();
  5842. }
  5843. else if (label.newOpacity !== label.oldOpacity) {
  5844. symbols.connectors[index].show();
  5845. }
  5846. });
  5847. }
  5848. };
  5849. /**
  5850. * Calculate ranges from created series.
  5851. *
  5852. * @private
  5853. * @function Highcharts.BubbleLegend#getRanges
  5854. * @return {Array<Highcharts.LegendBubbleLegendRangesOptions>}
  5855. * Array of range objects
  5856. */
  5857. BubbleLegend.prototype.getRanges = function () {
  5858. var bubbleLegend = this.legend.bubbleLegend,
  5859. series = bubbleLegend.chart.series,
  5860. ranges,
  5861. rangesOptions = bubbleLegend.options.ranges,
  5862. zData,
  5863. minZ = Number.MAX_VALUE,
  5864. maxZ = -Number.MAX_VALUE;
  5865. series.forEach(function (s) {
  5866. // Find the min and max Z, like in bubble series
  5867. if (s.isBubble && !s.ignoreSeries) {
  5868. zData = s.zData.filter(isNumber);
  5869. if (zData.length) {
  5870. minZ = pick(s.options.zMin, Math.min(minZ, Math.max(arrayMin(zData), s.options.displayNegative === false ?
  5871. s.options.zThreshold :
  5872. -Number.MAX_VALUE)));
  5873. maxZ = pick(s.options.zMax, Math.max(maxZ, arrayMax(zData)));
  5874. }
  5875. }
  5876. });
  5877. // Set values for ranges
  5878. if (minZ === maxZ) {
  5879. // Only one range if min and max values are the same.
  5880. ranges = [{ value: maxZ }];
  5881. }
  5882. else {
  5883. ranges = [
  5884. { value: minZ },
  5885. { value: (minZ + maxZ) / 2 },
  5886. { value: maxZ, autoRanges: true }
  5887. ];
  5888. }
  5889. // Prevent reverse order of ranges after redraw
  5890. if (rangesOptions.length && rangesOptions[0].radius) {
  5891. ranges.reverse();
  5892. }
  5893. // Merge ranges values with user options
  5894. ranges.forEach(function (range, i) {
  5895. if (rangesOptions && rangesOptions[i]) {
  5896. ranges[i] = merge(false, rangesOptions[i], range);
  5897. }
  5898. });
  5899. return ranges;
  5900. };
  5901. /**
  5902. * Calculate bubble legend sizes from rendered series.
  5903. *
  5904. * @private
  5905. * @function Highcharts.BubbleLegend#predictBubbleSizes
  5906. * @return {Array<number,number>}
  5907. * Calculated min and max bubble sizes
  5908. */
  5909. BubbleLegend.prototype.predictBubbleSizes = function () {
  5910. var chart = this.chart,
  5911. fontMetrics = this.fontMetrics,
  5912. legendOptions = chart.legend.options,
  5913. floating = legendOptions.floating,
  5914. horizontal = legendOptions.layout === 'horizontal',
  5915. lastLineHeight = horizontal ? chart.legend.lastLineHeight : 0,
  5916. plotSizeX = chart.plotSizeX,
  5917. plotSizeY = chart.plotSizeY,
  5918. bubbleSeries = chart.series[this.options.seriesIndex],
  5919. minSize = Math.ceil(bubbleSeries.minPxSize),
  5920. maxPxSize = Math.ceil(bubbleSeries.maxPxSize),
  5921. maxSize = bubbleSeries.options.maxSize,
  5922. plotSize = Math.min(plotSizeY,
  5923. plotSizeX),
  5924. calculatedSize;
  5925. // Calculate prediceted max size of bubble
  5926. if (floating || !(/%$/.test(maxSize))) {
  5927. calculatedSize = maxPxSize;
  5928. }
  5929. else {
  5930. maxSize = parseFloat(maxSize);
  5931. calculatedSize = ((plotSize + lastLineHeight -
  5932. fontMetrics.h / 2) * maxSize / 100) / (maxSize / 100 + 1);
  5933. // Get maxPxSize from bubble series if calculated bubble legend
  5934. // size will not affect to bubbles series.
  5935. if ((horizontal && plotSizeY - calculatedSize >=
  5936. plotSizeX) || (!horizontal && plotSizeX -
  5937. calculatedSize >= plotSizeY)) {
  5938. calculatedSize = maxPxSize;
  5939. }
  5940. }
  5941. return [minSize, Math.ceil(calculatedSize)];
  5942. };
  5943. /**
  5944. * Correct ranges with calculated sizes.
  5945. *
  5946. * @private
  5947. * @function Highcharts.BubbleLegend#updateRanges
  5948. * @param {number} min
  5949. * @param {number} max
  5950. * @return {void}
  5951. */
  5952. BubbleLegend.prototype.updateRanges = function (min, max) {
  5953. var bubbleLegendOptions = this.legend.options.bubbleLegend;
  5954. bubbleLegendOptions.minSize = min;
  5955. bubbleLegendOptions.maxSize = max;
  5956. bubbleLegendOptions.ranges = this.getRanges();
  5957. };
  5958. /**
  5959. * Because of the possibility of creating another legend line, predicted
  5960. * bubble legend sizes may differ by a few pixels, so it is necessary to
  5961. * correct them.
  5962. *
  5963. * @private
  5964. * @function Highcharts.BubbleLegend#correctSizes
  5965. * @return {void}
  5966. */
  5967. BubbleLegend.prototype.correctSizes = function () {
  5968. var legend = this.legend,
  5969. chart = this.chart,
  5970. bubbleSeries = chart.series[this.options.seriesIndex],
  5971. bubbleSeriesSize = bubbleSeries.maxPxSize,
  5972. bubbleLegendSize = this.options.maxSize;
  5973. if (Math.abs(Math.ceil(bubbleSeriesSize) - bubbleLegendSize) >
  5974. 1) {
  5975. this.updateRanges(this.options.minSize, bubbleSeries.maxPxSize);
  5976. legend.render();
  5977. }
  5978. };
  5979. return BubbleLegend;
  5980. }());
  5981. // Start the bubble legend creation process.
  5982. addEvent(Legend, 'afterGetAllItems', function (e) {
  5983. var legend = this,
  5984. bubbleLegend = legend.bubbleLegend,
  5985. legendOptions = legend.options,
  5986. options = legendOptions.bubbleLegend,
  5987. bubbleSeriesIndex = legend.chart.getVisibleBubbleSeriesIndex();
  5988. // Remove unnecessary element
  5989. if (bubbleLegend && bubbleLegend.ranges && bubbleLegend.ranges.length) {
  5990. // Allow change the way of calculating ranges in update
  5991. if (options.ranges.length) {
  5992. options.autoRanges =
  5993. !!options.ranges[0].autoRanges;
  5994. }
  5995. // Update bubbleLegend dimensions in each redraw
  5996. legend.destroyItem(bubbleLegend);
  5997. }
  5998. // Create bubble legend
  5999. if (bubbleSeriesIndex >= 0 &&
  6000. legendOptions.enabled &&
  6001. options.enabled) {
  6002. options.seriesIndex = bubbleSeriesIndex;
  6003. legend.bubbleLegend = new H.BubbleLegend(options, legend);
  6004. legend.bubbleLegend.addToLegend(e.allItems);
  6005. }
  6006. });
  6007. /**
  6008. * Check if there is at least one visible bubble series.
  6009. *
  6010. * @private
  6011. * @function Highcharts.Chart#getVisibleBubbleSeriesIndex
  6012. * @return {number}
  6013. * First visible bubble series index
  6014. */
  6015. Chart.prototype.getVisibleBubbleSeriesIndex = function () {
  6016. var series = this.series,
  6017. i = 0;
  6018. while (i < series.length) {
  6019. if (series[i] &&
  6020. series[i].isBubble &&
  6021. series[i].visible &&
  6022. series[i].zData.length) {
  6023. return i;
  6024. }
  6025. i++;
  6026. }
  6027. return -1;
  6028. };
  6029. /**
  6030. * Calculate height for each row in legend.
  6031. *
  6032. * @private
  6033. * @function Highcharts.Legend#getLinesHeights
  6034. * @return {Array<Highcharts.Dictionary<number>>}
  6035. * Informations about line height and items amount
  6036. */
  6037. Legend.prototype.getLinesHeights = function () {
  6038. var items = this.allItems,
  6039. lines = [],
  6040. lastLine,
  6041. length = items.length,
  6042. i = 0,
  6043. j = 0;
  6044. for (i = 0; i < length; i++) {
  6045. if (items[i].legendItemHeight) {
  6046. // for bubbleLegend
  6047. items[i].itemHeight = items[i].legendItemHeight;
  6048. }
  6049. if ( // Line break
  6050. items[i] === items[length - 1] ||
  6051. items[i + 1] &&
  6052. items[i]._legendItemPos[1] !==
  6053. items[i + 1]._legendItemPos[1]) {
  6054. lines.push({ height: 0 });
  6055. lastLine = lines[lines.length - 1];
  6056. // Find the highest item in line
  6057. for (j; j <= i; j++) {
  6058. if (items[j].itemHeight > lastLine.height) {
  6059. lastLine.height = items[j].itemHeight;
  6060. }
  6061. }
  6062. lastLine.step = i;
  6063. }
  6064. }
  6065. return lines;
  6066. };
  6067. /**
  6068. * Correct legend items translation in case of different elements heights.
  6069. *
  6070. * @private
  6071. * @function Highcharts.Legend#retranslateItems
  6072. * @param {Array<Highcharts.Dictionary<number>>} lines
  6073. * Informations about line height and items amount
  6074. * @return {void}
  6075. */
  6076. Legend.prototype.retranslateItems = function (lines) {
  6077. var items = this.allItems,
  6078. orgTranslateX,
  6079. orgTranslateY,
  6080. movementX,
  6081. rtl = this.options.rtl,
  6082. actualLine = 0;
  6083. items.forEach(function (item, index) {
  6084. orgTranslateX = item.legendGroup.translateX;
  6085. orgTranslateY = item._legendItemPos[1];
  6086. movementX = item.movementX;
  6087. if (movementX || (rtl && item.ranges)) {
  6088. movementX = rtl ?
  6089. orgTranslateX - item.options.maxSize / 2 :
  6090. orgTranslateX + movementX;
  6091. item.legendGroup.attr({ translateX: movementX });
  6092. }
  6093. if (index > lines[actualLine].step) {
  6094. actualLine++;
  6095. }
  6096. item.legendGroup.attr({
  6097. translateY: Math.round(orgTranslateY + lines[actualLine].height / 2)
  6098. });
  6099. item._legendItemPos[1] = orgTranslateY +
  6100. lines[actualLine].height / 2;
  6101. });
  6102. };
  6103. // Toggle bubble legend depending on the visible status of bubble series.
  6104. addEvent(Series, 'legendItemClick', function () {
  6105. var series = this,
  6106. chart = series.chart,
  6107. visible = series.visible,
  6108. legend = series.chart.legend,
  6109. status;
  6110. if (legend && legend.bubbleLegend) {
  6111. // Temporary correct 'visible' property
  6112. series.visible = !visible;
  6113. // Save future status for getRanges method
  6114. series.ignoreSeries = visible;
  6115. // Check if at lest one bubble series is visible
  6116. status = chart.getVisibleBubbleSeriesIndex() >= 0;
  6117. // Hide bubble legend if all bubble series are disabled
  6118. if (legend.bubbleLegend.visible !== status) {
  6119. // Show or hide bubble legend
  6120. legend.update({
  6121. bubbleLegend: { enabled: status }
  6122. });
  6123. legend.bubbleLegend.visible = status; // Restore default status
  6124. }
  6125. series.visible = visible;
  6126. }
  6127. });
  6128. // If ranges are not specified, determine ranges from rendered bubble series
  6129. // and render legend again.
  6130. wrap(Chart.prototype, 'drawChartBox', function (proceed, options, callback) {
  6131. var chart = this,
  6132. legend = chart.legend,
  6133. bubbleSeries = chart.getVisibleBubbleSeriesIndex() >= 0,
  6134. bubbleLegendOptions,
  6135. bubbleSizes;
  6136. if (legend && legend.options.enabled && legend.bubbleLegend &&
  6137. legend.options.bubbleLegend.autoRanges && bubbleSeries) {
  6138. bubbleLegendOptions = legend.bubbleLegend.options;
  6139. bubbleSizes = legend.bubbleLegend.predictBubbleSizes();
  6140. legend.bubbleLegend.updateRanges(bubbleSizes[0], bubbleSizes[1]);
  6141. // Disable animation on init
  6142. if (!bubbleLegendOptions.placed) {
  6143. legend.group.placed = false;
  6144. legend.allItems.forEach(function (item) {
  6145. item.legendGroup.translateY = null;
  6146. });
  6147. }
  6148. // Create legend with bubbleLegend
  6149. legend.render();
  6150. chart.getMargins();
  6151. chart.axes.forEach(function (axis) {
  6152. if (axis.visible) { // #11448
  6153. axis.render();
  6154. }
  6155. if (!bubbleLegendOptions.placed) {
  6156. axis.setScale();
  6157. axis.updateNames();
  6158. // Disable axis animation on init
  6159. objectEach(axis.ticks, function (tick) {
  6160. tick.isNew = true;
  6161. tick.isNewLabel = true;
  6162. });
  6163. }
  6164. });
  6165. bubbleLegendOptions.placed = true;
  6166. // After recalculate axes, calculate margins again.
  6167. chart.getMargins();
  6168. // Call default 'drawChartBox' method.
  6169. proceed.call(chart, options, callback);
  6170. // Check bubble legend sizes and correct them if necessary.
  6171. legend.bubbleLegend.correctSizes();
  6172. // Correct items positions with different dimensions in legend.
  6173. legend.retranslateItems(legend.getLinesHeights());
  6174. }
  6175. else {
  6176. proceed.call(chart, options, callback);
  6177. // Allow color change on static bubble legend after click on legend
  6178. if (legend && legend.options.enabled && legend.bubbleLegend) {
  6179. legend.render();
  6180. legend.retranslateItems(legend.getLinesHeights());
  6181. }
  6182. }
  6183. });
  6184. H.BubbleLegend = BubbleLegend;
  6185. return H.BubbleLegend;
  6186. });
  6187. _registerModule(_modules, 'Series/Bubble/BubbleSeries.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Series/Series.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (Axis, BaseSeries, Color, H, Point, U) {
  6188. /* *
  6189. *
  6190. * (c) 2010-2020 Torstein Honsi
  6191. *
  6192. * License: www.highcharts.com/license
  6193. *
  6194. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6195. *
  6196. * */
  6197. var color = Color.parse;
  6198. var noop = H.noop;
  6199. var arrayMax = U.arrayMax,
  6200. arrayMin = U.arrayMin,
  6201. clamp = U.clamp,
  6202. extend = U.extend,
  6203. isNumber = U.isNumber,
  6204. pick = U.pick,
  6205. pInt = U.pInt;
  6206. var Series = H.Series,
  6207. seriesTypes = BaseSeries.seriesTypes;
  6208. /**
  6209. * @typedef {"area"|"width"} Highcharts.BubbleSizeByValue
  6210. */
  6211. ''; // detach doclets above
  6212. /**
  6213. * A bubble series is a three dimensional series type where each point renders
  6214. * an X, Y and Z value. Each points is drawn as a bubble where the position
  6215. * along the X and Y axes mark the X and Y values, and the size of the bubble
  6216. * relates to the Z value.
  6217. *
  6218. * @sample {highcharts} highcharts/demo/bubble/
  6219. * Bubble chart
  6220. *
  6221. * @extends plotOptions.scatter
  6222. * @excluding cluster
  6223. * @product highcharts highstock
  6224. * @requires highcharts-more
  6225. * @optionparent plotOptions.bubble
  6226. */
  6227. BaseSeries.seriesType('bubble', 'scatter', {
  6228. dataLabels: {
  6229. formatter: function () {
  6230. return this.point.z;
  6231. },
  6232. inside: true,
  6233. verticalAlign: 'middle'
  6234. },
  6235. /**
  6236. * If there are more points in the series than the `animationLimit`, the
  6237. * animation won't run. Animation affects overall performance and doesn't
  6238. * work well with heavy data series.
  6239. *
  6240. * @since 6.1.0
  6241. */
  6242. animationLimit: 250,
  6243. /**
  6244. * Whether to display negative sized bubbles. The threshold is given
  6245. * by the [zThreshold](#plotOptions.bubble.zThreshold) option, and negative
  6246. * bubbles can be visualized by setting
  6247. * [negativeColor](#plotOptions.bubble.negativeColor).
  6248. *
  6249. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  6250. * Negative bubbles
  6251. *
  6252. * @type {boolean}
  6253. * @default true
  6254. * @since 3.0
  6255. * @apioption plotOptions.bubble.displayNegative
  6256. */
  6257. /**
  6258. * @extends plotOptions.series.marker
  6259. * @excluding enabled, enabledThreshold, height, radius, width
  6260. */
  6261. marker: {
  6262. lineColor: null,
  6263. lineWidth: 1,
  6264. /**
  6265. * The fill opacity of the bubble markers.
  6266. */
  6267. fillOpacity: 0.5,
  6268. /**
  6269. * In bubble charts, the radius is overridden and determined based on
  6270. * the point's data value.
  6271. *
  6272. * @ignore-option
  6273. */
  6274. radius: null,
  6275. states: {
  6276. hover: {
  6277. radiusPlus: 0
  6278. }
  6279. },
  6280. /**
  6281. * A predefined shape or symbol for the marker. Possible values are
  6282. * "circle", "square", "diamond", "triangle" and "triangle-down".
  6283. *
  6284. * Additionally, the URL to a graphic can be given on the form
  6285. * `url(graphic.png)`. Note that for the image to be applied to exported
  6286. * charts, its URL needs to be accessible by the export server.
  6287. *
  6288. * Custom callbacks for symbol path generation can also be added to
  6289. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  6290. * used by its method name, as shown in the demo.
  6291. *
  6292. * @sample {highcharts} highcharts/plotoptions/bubble-symbol/
  6293. * Bubble chart with various symbols
  6294. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  6295. * General chart with predefined, graphic and custom markers
  6296. *
  6297. * @type {Highcharts.SymbolKeyValue|string}
  6298. * @since 5.0.11
  6299. */
  6300. symbol: 'circle'
  6301. },
  6302. /**
  6303. * Minimum bubble size. Bubbles will automatically size between the
  6304. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  6305. * Can be either pixels (when no unit is given), or a percentage of
  6306. * the smallest one of the plot width and height.
  6307. *
  6308. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  6309. * Bubble size
  6310. *
  6311. * @type {number|string}
  6312. * @since 3.0
  6313. * @product highcharts highstock
  6314. */
  6315. minSize: 8,
  6316. /**
  6317. * Maximum bubble size. Bubbles will automatically size between the
  6318. * `minSize` and `maxSize` to reflect the `z` value of each bubble.
  6319. * Can be either pixels (when no unit is given), or a percentage of
  6320. * the smallest one of the plot width and height.
  6321. *
  6322. * @sample {highcharts} highcharts/plotoptions/bubble-size/
  6323. * Bubble size
  6324. *
  6325. * @type {number|string}
  6326. * @since 3.0
  6327. * @product highcharts highstock
  6328. */
  6329. maxSize: '20%',
  6330. /**
  6331. * When a point's Z value is below the
  6332. * [zThreshold](#plotOptions.bubble.zThreshold) setting, this color is used.
  6333. *
  6334. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  6335. * Negative bubbles
  6336. *
  6337. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6338. * @since 3.0
  6339. * @product highcharts
  6340. * @apioption plotOptions.bubble.negativeColor
  6341. */
  6342. /**
  6343. * Whether the bubble's value should be represented by the area or the
  6344. * width of the bubble. The default, `area`, corresponds best to the
  6345. * human perception of the size of each bubble.
  6346. *
  6347. * @sample {highcharts} highcharts/plotoptions/bubble-sizeby/
  6348. * Comparison of area and size
  6349. *
  6350. * @type {Highcharts.BubbleSizeByValue}
  6351. * @default area
  6352. * @since 3.0.7
  6353. * @apioption plotOptions.bubble.sizeBy
  6354. */
  6355. /**
  6356. * When this is true, the absolute value of z determines the size of
  6357. * the bubble. This means that with the default `zThreshold` of 0, a
  6358. * bubble of value -1 will have the same size as a bubble of value 1,
  6359. * while a bubble of value 0 will have a smaller size according to
  6360. * `minSize`.
  6361. *
  6362. * @sample {highcharts} highcharts/plotoptions/bubble-sizebyabsolutevalue/
  6363. * Size by absolute value, various thresholds
  6364. *
  6365. * @type {boolean}
  6366. * @default false
  6367. * @since 4.1.9
  6368. * @product highcharts
  6369. * @apioption plotOptions.bubble.sizeByAbsoluteValue
  6370. */
  6371. /**
  6372. * When this is true, the series will not cause the Y axis to cross
  6373. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  6374. * unless the data actually crosses the plane.
  6375. *
  6376. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  6377. * 3 will make the Y axis show negative values according to the `minPadding`
  6378. * option. If `softThreshold` is `true`, the Y axis starts at 0.
  6379. *
  6380. * @since 4.1.9
  6381. * @product highcharts
  6382. */
  6383. softThreshold: false,
  6384. states: {
  6385. hover: {
  6386. halo: {
  6387. size: 5
  6388. }
  6389. }
  6390. },
  6391. tooltip: {
  6392. pointFormat: '({point.x}, {point.y}), Size: {point.z}'
  6393. },
  6394. turboThreshold: 0,
  6395. /**
  6396. * The minimum for the Z value range. Defaults to the highest Z value
  6397. * in the data.
  6398. *
  6399. * @see [zMin](#plotOptions.bubble.zMin)
  6400. *
  6401. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  6402. * Z has a possible range of 0-100
  6403. *
  6404. * @type {number}
  6405. * @since 4.0.3
  6406. * @product highcharts
  6407. * @apioption plotOptions.bubble.zMax
  6408. */
  6409. /**
  6410. * @default z
  6411. * @apioption plotOptions.bubble.colorKey
  6412. */
  6413. /**
  6414. * The minimum for the Z value range. Defaults to the lowest Z value
  6415. * in the data.
  6416. *
  6417. * @see [zMax](#plotOptions.bubble.zMax)
  6418. *
  6419. * @sample {highcharts} highcharts/plotoptions/bubble-zmin-zmax/
  6420. * Z has a possible range of 0-100
  6421. *
  6422. * @type {number}
  6423. * @since 4.0.3
  6424. * @product highcharts
  6425. * @apioption plotOptions.bubble.zMin
  6426. */
  6427. /**
  6428. * When [displayNegative](#plotOptions.bubble.displayNegative) is `false`,
  6429. * bubbles with lower Z values are skipped. When `displayNegative`
  6430. * is `true` and a [negativeColor](#plotOptions.bubble.negativeColor)
  6431. * is given, points with lower Z is colored.
  6432. *
  6433. * @sample {highcharts} highcharts/plotoptions/bubble-negative/
  6434. * Negative bubbles
  6435. *
  6436. * @since 3.0
  6437. * @product highcharts
  6438. */
  6439. zThreshold: 0,
  6440. zoneAxis: 'z'
  6441. // Prototype members
  6442. }, {
  6443. pointArrayMap: ['y', 'z'],
  6444. parallelArrays: ['x', 'y', 'z'],
  6445. trackerGroups: ['group', 'dataLabelsGroup'],
  6446. specialGroup: 'group',
  6447. bubblePadding: true,
  6448. zoneAxis: 'z',
  6449. directTouch: true,
  6450. isBubble: true,
  6451. /* eslint-disable valid-jsdoc */
  6452. /**
  6453. * @private
  6454. */
  6455. pointAttribs: function (point, state) {
  6456. var markerOptions = this.options.marker,
  6457. fillOpacity = markerOptions.fillOpacity,
  6458. attr = Series.prototype.pointAttribs.call(this,
  6459. point,
  6460. state);
  6461. if (fillOpacity !== 1) {
  6462. attr.fill = color(attr.fill)
  6463. .setOpacity(fillOpacity)
  6464. .get('rgba');
  6465. }
  6466. return attr;
  6467. },
  6468. /**
  6469. * Get the radius for each point based on the minSize, maxSize and each
  6470. * point's Z value. This must be done prior to Series.translate because
  6471. * the axis needs to add padding in accordance with the point sizes.
  6472. * @private
  6473. */
  6474. getRadii: function (zMin, zMax, series) {
  6475. var len,
  6476. i,
  6477. zData = this.zData,
  6478. yData = this.yData,
  6479. minSize = series.minPxSize,
  6480. maxSize = series.maxPxSize,
  6481. radii = [],
  6482. value;
  6483. // Set the shape type and arguments to be picked up in drawPoints
  6484. for (i = 0, len = zData.length; i < len; i++) {
  6485. value = zData[i];
  6486. // Separate method to get individual radius for bubbleLegend
  6487. radii.push(this.getRadius(zMin, zMax, minSize, maxSize, value, yData[i]));
  6488. }
  6489. this.radii = radii;
  6490. },
  6491. /**
  6492. * Get the individual radius for one point.
  6493. * @private
  6494. */
  6495. getRadius: function (zMin, zMax, minSize, maxSize, value, yValue) {
  6496. var options = this.options,
  6497. sizeByArea = options.sizeBy !== 'width',
  6498. zThreshold = options.zThreshold,
  6499. zRange = zMax - zMin,
  6500. pos = 0.5;
  6501. // #8608 - bubble should be visible when z is undefined
  6502. if (yValue === null || value === null) {
  6503. return null;
  6504. }
  6505. if (isNumber(value)) {
  6506. // When sizing by threshold, the absolute value of z determines
  6507. // the size of the bubble.
  6508. if (options.sizeByAbsoluteValue) {
  6509. value = Math.abs(value - zThreshold);
  6510. zMax = zRange = Math.max(zMax - zThreshold, Math.abs(zMin - zThreshold));
  6511. zMin = 0;
  6512. }
  6513. // Issue #4419 - if value is less than zMin, push a radius that's
  6514. // always smaller than the minimum size
  6515. if (value < zMin) {
  6516. return minSize / 2 - 1;
  6517. }
  6518. // Relative size, a number between 0 and 1
  6519. if (zRange > 0) {
  6520. pos = (value - zMin) / zRange;
  6521. }
  6522. }
  6523. if (sizeByArea && pos >= 0) {
  6524. pos = Math.sqrt(pos);
  6525. }
  6526. return Math.ceil(minSize + pos * (maxSize - minSize)) / 2;
  6527. },
  6528. /**
  6529. * Perform animation on the bubbles
  6530. * @private
  6531. */
  6532. animate: function (init) {
  6533. if (!init &&
  6534. this.points.length < this.options.animationLimit // #8099
  6535. ) {
  6536. this.points.forEach(function (point) {
  6537. var graphic = point.graphic;
  6538. if (graphic && graphic.width) { // URL symbols don't have width
  6539. // Start values
  6540. if (!this.hasRendered) {
  6541. graphic.attr({
  6542. x: point.plotX,
  6543. y: point.plotY,
  6544. width: 1,
  6545. height: 1
  6546. });
  6547. }
  6548. // Run animation
  6549. graphic.animate(this.markerAttribs(point), this.options.animation);
  6550. }
  6551. }, this);
  6552. }
  6553. },
  6554. /**
  6555. * Define hasData function for non-cartesian series.
  6556. * Returns true if the series has points at all.
  6557. * @private
  6558. */
  6559. hasData: function () {
  6560. return !!this.processedXData.length; // != 0
  6561. },
  6562. /**
  6563. * Extend the base translate method to handle bubble size
  6564. * @private
  6565. */
  6566. translate: function () {
  6567. var i,
  6568. data = this.data,
  6569. point,
  6570. radius,
  6571. radii = this.radii;
  6572. // Run the parent method
  6573. seriesTypes.scatter.prototype.translate.call(this);
  6574. // Set the shape type and arguments to be picked up in drawPoints
  6575. i = data.length;
  6576. while (i--) {
  6577. point = data[i];
  6578. radius = radii ? radii[i] : 0; // #1737
  6579. if (isNumber(radius) && radius >= this.minPxSize / 2) {
  6580. // Shape arguments
  6581. point.marker = extend(point.marker, {
  6582. radius: radius,
  6583. width: 2 * radius,
  6584. height: 2 * radius
  6585. });
  6586. // Alignment box for the data label
  6587. point.dlBox = {
  6588. x: point.plotX - radius,
  6589. y: point.plotY - radius,
  6590. width: 2 * radius,
  6591. height: 2 * radius
  6592. };
  6593. }
  6594. else { // below zThreshold
  6595. // #1691
  6596. point.shapeArgs = point.plotY = point.dlBox = void 0;
  6597. }
  6598. }
  6599. },
  6600. alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
  6601. buildKDTree: noop,
  6602. applyZones: noop
  6603. // Point class
  6604. }, {
  6605. /**
  6606. * @private
  6607. */
  6608. haloPath: function (size) {
  6609. return Point.prototype.haloPath.call(this,
  6610. // #6067
  6611. size === 0 ? 0 : (this.marker ? this.marker.radius || 0 : 0) + size);
  6612. },
  6613. ttBelow: false
  6614. });
  6615. // Add logic to pad each axis with the amount of pixels necessary to avoid the
  6616. // bubbles to overflow.
  6617. Axis.prototype.beforePadding = function () {
  6618. var axis = this,
  6619. axisLength = this.len,
  6620. chart = this.chart,
  6621. pxMin = 0,
  6622. pxMax = axisLength,
  6623. isXAxis = this.isXAxis,
  6624. dataKey = isXAxis ? 'xData' : 'yData',
  6625. min = this.min,
  6626. extremes = {},
  6627. smallestSize = Math.min(chart.plotWidth,
  6628. chart.plotHeight),
  6629. zMin = Number.MAX_VALUE,
  6630. zMax = -Number.MAX_VALUE,
  6631. range = this.max - min,
  6632. transA = axisLength / range,
  6633. activeSeries = [];
  6634. // Handle padding on the second pass, or on redraw
  6635. this.series.forEach(function (series) {
  6636. var seriesOptions = series.options,
  6637. zData;
  6638. if (series.bubblePadding &&
  6639. (series.visible || !chart.options.chart.ignoreHiddenSeries)) {
  6640. // Correction for #1673
  6641. axis.allowZoomOutside = true;
  6642. // Cache it
  6643. activeSeries.push(series);
  6644. if (isXAxis) { // because X axis is evaluated first
  6645. // For each series, translate the size extremes to pixel values
  6646. ['minSize', 'maxSize'].forEach(function (prop) {
  6647. var length = seriesOptions[prop],
  6648. isPercent = /%$/.test(length);
  6649. length = pInt(length);
  6650. extremes[prop] = isPercent ?
  6651. smallestSize * length / 100 :
  6652. length;
  6653. });
  6654. series.minPxSize = extremes.minSize;
  6655. // Prioritize min size if conflict to make sure bubbles are
  6656. // always visible. #5873
  6657. series.maxPxSize = Math.max(extremes.maxSize, extremes.minSize);
  6658. // Find the min and max Z
  6659. zData = series.zData.filter(isNumber);
  6660. if (zData.length) { // #1735
  6661. zMin = pick(seriesOptions.zMin, clamp(arrayMin(zData), seriesOptions.displayNegative === false ?
  6662. seriesOptions.zThreshold :
  6663. -Number.MAX_VALUE, zMin));
  6664. zMax = pick(seriesOptions.zMax, Math.max(zMax, arrayMax(zData)));
  6665. }
  6666. }
  6667. }
  6668. });
  6669. activeSeries.forEach(function (series) {
  6670. var data = series[dataKey],
  6671. i = data.length,
  6672. radius;
  6673. if (isXAxis) {
  6674. series.getRadii(zMin, zMax, series);
  6675. }
  6676. if (range > 0) {
  6677. while (i--) {
  6678. if (isNumber(data[i]) &&
  6679. axis.dataMin <= data[i] &&
  6680. data[i] <= axis.max) {
  6681. radius = series.radii ? series.radii[i] : 0;
  6682. pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
  6683. pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
  6684. }
  6685. }
  6686. }
  6687. });
  6688. // Apply the padding to the min and max properties
  6689. if (activeSeries.length && range > 0 && !this.logarithmic) {
  6690. pxMax -= axisLength;
  6691. transA *= (axisLength +
  6692. Math.max(0, pxMin) - // #8901
  6693. Math.min(pxMax, axisLength)) / axisLength;
  6694. [
  6695. ['min', 'userMin', pxMin],
  6696. ['max', 'userMax', pxMax]
  6697. ].forEach(function (keys) {
  6698. if (typeof pick(axis.options[keys[0]], axis[keys[1]]) === 'undefined') {
  6699. axis[keys[0]] += keys[2] / transA;
  6700. }
  6701. });
  6702. }
  6703. /* eslint-enable valid-jsdoc */
  6704. };
  6705. /**
  6706. * A `bubble` series. If the [type](#series.bubble.type) option is
  6707. * not specified, it is inherited from [chart.type](#chart.type).
  6708. *
  6709. * @extends series,plotOptions.bubble
  6710. * @excluding dataParser, dataURL, stack
  6711. * @product highcharts highstock
  6712. * @requires highcharts-more
  6713. * @apioption series.bubble
  6714. */
  6715. /**
  6716. * An array of data points for the series. For the `bubble` series type,
  6717. * points can be given in the following ways:
  6718. *
  6719. * 1. An array of arrays with 3 or 2 values. In this case, the values correspond
  6720. * to `x,y,z`. If the first value is a string, it is applied as the name of
  6721. * the point, and the `x` value is inferred. The `x` value can also be
  6722. * omitted, in which case the inner arrays should be of length 2\. Then the
  6723. * `x` value is automatically calculated, either starting at 0 and
  6724. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  6725. * series options.
  6726. * ```js
  6727. * data: [
  6728. * [0, 1, 2],
  6729. * [1, 5, 5],
  6730. * [2, 0, 2]
  6731. * ]
  6732. * ```
  6733. *
  6734. * 2. An array of objects with named values. The following snippet shows only a
  6735. * few settings, see the complete options set below. If the total number of
  6736. * data points exceeds the series'
  6737. * [turboThreshold](#series.bubble.turboThreshold), this option is not
  6738. * available.
  6739. * ```js
  6740. * data: [{
  6741. * x: 1,
  6742. * y: 1,
  6743. * z: 1,
  6744. * name: "Point2",
  6745. * color: "#00FF00"
  6746. * }, {
  6747. * x: 1,
  6748. * y: 5,
  6749. * z: 4,
  6750. * name: "Point1",
  6751. * color: "#FF00FF"
  6752. * }]
  6753. * ```
  6754. *
  6755. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  6756. * Arrays of numeric x and y
  6757. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  6758. * Arrays of datetime x and y
  6759. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  6760. * Arrays of point.name and y
  6761. * @sample {highcharts} highcharts/series/data-array-of-objects/
  6762. * Config objects
  6763. *
  6764. * @type {Array<Array<(number|string),number>|Array<(number|string),number,number>|*>}
  6765. * @extends series.line.data
  6766. * @product highcharts
  6767. * @apioption series.bubble.data
  6768. */
  6769. /**
  6770. * @extends series.line.data.marker
  6771. * @excluding enabledThreshold, height, radius, width
  6772. * @product highcharts
  6773. * @apioption series.bubble.data.marker
  6774. */
  6775. /**
  6776. * The size value for each bubble. The bubbles' diameters are computed
  6777. * based on the `z`, and controlled by series options like `minSize`,
  6778. * `maxSize`, `sizeBy`, `zMin` and `zMax`.
  6779. *
  6780. * @type {number|null}
  6781. * @product highcharts
  6782. * @apioption series.bubble.data.z
  6783. */
  6784. /**
  6785. * @excluding enabled, enabledThreshold, height, radius, width
  6786. * @apioption series.bubble.marker
  6787. */
  6788. ''; // adds doclets above to transpiled file
  6789. });
  6790. _registerModule(_modules, 'Series/Networkgraph/DraggableNodes.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, H, U) {
  6791. /* *
  6792. *
  6793. * Networkgraph series
  6794. *
  6795. * (c) 2010-2020 Paweł Fus
  6796. *
  6797. * License: www.highcharts.com/license
  6798. *
  6799. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6800. *
  6801. * */
  6802. var addEvent = U.addEvent;
  6803. /* eslint-disable no-invalid-this, valid-jsdoc */
  6804. H.dragNodesMixin = {
  6805. /**
  6806. * Mouse down action, initializing drag&drop mode.
  6807. *
  6808. * @private
  6809. * @param {Highcharts.Point} point The point that event occured.
  6810. * @param {Highcharts.PointerEventObject} event Browser event, before normalization.
  6811. * @return {void}
  6812. */
  6813. onMouseDown: function (point, event) {
  6814. var normalizedEvent = this.chart.pointer.normalize(event);
  6815. point.fixedPosition = {
  6816. chartX: normalizedEvent.chartX,
  6817. chartY: normalizedEvent.chartY,
  6818. plotX: point.plotX,
  6819. plotY: point.plotY
  6820. };
  6821. point.inDragMode = true;
  6822. },
  6823. /**
  6824. * Mouse move action during drag&drop.
  6825. *
  6826. * @private
  6827. *
  6828. * @param {global.Event} event Browser event, before normalization.
  6829. * @param {Highcharts.Point} point The point that event occured.
  6830. *
  6831. * @return {void}
  6832. */
  6833. onMouseMove: function (point, event) {
  6834. if (point.fixedPosition && point.inDragMode) {
  6835. var series = this,
  6836. chart = series.chart,
  6837. normalizedEvent = chart.pointer.normalize(event),
  6838. diffX = point.fixedPosition.chartX - normalizedEvent.chartX,
  6839. diffY = point.fixedPosition.chartY - normalizedEvent.chartY,
  6840. newPlotX,
  6841. newPlotY,
  6842. graphLayoutsLookup = chart.graphLayoutsLookup;
  6843. // At least 5px to apply change (avoids simple click):
  6844. if (Math.abs(diffX) > 5 || Math.abs(diffY) > 5) {
  6845. newPlotX = point.fixedPosition.plotX - diffX;
  6846. newPlotY = point.fixedPosition.plotY - diffY;
  6847. if (chart.isInsidePlot(newPlotX, newPlotY)) {
  6848. point.plotX = newPlotX;
  6849. point.plotY = newPlotY;
  6850. point.hasDragged = true;
  6851. this.redrawHalo(point);
  6852. graphLayoutsLookup.forEach(function (layout) {
  6853. layout.restartSimulation();
  6854. });
  6855. }
  6856. }
  6857. }
  6858. },
  6859. /**
  6860. * Mouse up action, finalizing drag&drop.
  6861. *
  6862. * @private
  6863. * @param {Highcharts.Point} point The point that event occured.
  6864. * @return {void}
  6865. */
  6866. onMouseUp: function (point, event) {
  6867. if (point.fixedPosition) {
  6868. if (point.hasDragged) {
  6869. if (this.layout.enableSimulation) {
  6870. this.layout.start();
  6871. }
  6872. else {
  6873. this.chart.redraw();
  6874. }
  6875. }
  6876. point.inDragMode = point.hasDragged = false;
  6877. if (!this.options.fixedDraggable) {
  6878. delete point.fixedPosition;
  6879. }
  6880. }
  6881. },
  6882. // Draggable mode:
  6883. /**
  6884. * Redraw halo on mousemove during the drag&drop action.
  6885. *
  6886. * @private
  6887. * @param {Highcharts.Point} point The point that should show halo.
  6888. * @return {void}
  6889. */
  6890. redrawHalo: function (point) {
  6891. if (point && this.halo) {
  6892. this.halo.attr({
  6893. d: point.haloPath(this.options.states.hover.halo.size)
  6894. });
  6895. }
  6896. }
  6897. };
  6898. /*
  6899. * Draggable mode:
  6900. */
  6901. addEvent(Chart, 'load', function () {
  6902. var chart = this,
  6903. mousedownUnbinder,
  6904. mousemoveUnbinder,
  6905. mouseupUnbinder;
  6906. if (chart.container) {
  6907. mousedownUnbinder = addEvent(chart.container, 'mousedown', function (event) {
  6908. var point = chart.hoverPoint;
  6909. if (point &&
  6910. point.series &&
  6911. point.series.hasDraggableNodes &&
  6912. point.series.options.draggable) {
  6913. point.series.onMouseDown(point, event);
  6914. mousemoveUnbinder = addEvent(chart.container, 'mousemove', function (e) {
  6915. return point &&
  6916. point.series &&
  6917. point.series.onMouseMove(point, e);
  6918. });
  6919. mouseupUnbinder = addEvent(chart.container.ownerDocument, 'mouseup', function (e) {
  6920. mousemoveUnbinder();
  6921. mouseupUnbinder();
  6922. return point &&
  6923. point.series &&
  6924. point.series.onMouseUp(point, e);
  6925. });
  6926. }
  6927. });
  6928. }
  6929. addEvent(chart, 'destroy', function () {
  6930. mousedownUnbinder();
  6931. });
  6932. });
  6933. });
  6934. _registerModule(_modules, 'Series/Networkgraph/Integrations.js', [_modules['Core/Globals.js']], function (H) {
  6935. /* *
  6936. *
  6937. * Networkgraph series
  6938. *
  6939. * (c) 2010-2020 Paweł Fus
  6940. *
  6941. * License: www.highcharts.com/license
  6942. *
  6943. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6944. *
  6945. * */
  6946. /* eslint-disable no-invalid-this, valid-jsdoc */
  6947. H.networkgraphIntegrations = {
  6948. verlet: {
  6949. /**
  6950. * Attractive force funtion. Can be replaced by API's
  6951. * `layoutAlgorithm.attractiveForce`
  6952. *
  6953. * @private
  6954. * @param {number} d current distance between two nodes
  6955. * @param {number} k expected distance between two nodes
  6956. * @return {number} force
  6957. */
  6958. attractiveForceFunction: function (d, k) {
  6959. // Used in API:
  6960. return (k - d) / d;
  6961. },
  6962. /**
  6963. * Repulsive force funtion. Can be replaced by API's
  6964. * `layoutAlgorithm.repulsiveForce`
  6965. *
  6966. * @private
  6967. * @param {number} d current distance between two nodes
  6968. * @param {number} k expected distance between two nodes
  6969. * @return {number} force
  6970. */
  6971. repulsiveForceFunction: function (d, k) {
  6972. // Used in API:
  6973. return (k - d) / d * (k > d ? 1 : 0); // Force only for close nodes
  6974. },
  6975. /**
  6976. * Barycenter force. Calculate and applys barycenter forces on the
  6977. * nodes. Making them closer to the center of their barycenter point.
  6978. *
  6979. * In Verlet integration, force is applied on a node immidatelly to it's
  6980. * `plotX` and `plotY` position.
  6981. *
  6982. * @private
  6983. * @return {void}
  6984. */
  6985. barycenter: function () {
  6986. var gravitationalConstant = this.options.gravitationalConstant,
  6987. xFactor = this.barycenter.xFactor,
  6988. yFactor = this.barycenter.yFactor;
  6989. // To consider:
  6990. xFactor = (xFactor - (this.box.left + this.box.width) / 2) *
  6991. gravitationalConstant;
  6992. yFactor = (yFactor - (this.box.top + this.box.height) / 2) *
  6993. gravitationalConstant;
  6994. this.nodes.forEach(function (node) {
  6995. if (!node.fixedPosition) {
  6996. node.plotX -=
  6997. xFactor / node.mass / node.degree;
  6998. node.plotY -=
  6999. yFactor / node.mass / node.degree;
  7000. }
  7001. });
  7002. },
  7003. /**
  7004. * Repulsive force.
  7005. *
  7006. * In Verlet integration, force is applied on a node immidatelly to it's
  7007. * `plotX` and `plotY` position.
  7008. *
  7009. * @private
  7010. * @param {Highcharts.Point} node
  7011. * Node that should be translated by force.
  7012. * @param {number} force
  7013. * Force calcualated in `repulsiveForceFunction`
  7014. * @param {Highcharts.PositionObject} distance
  7015. * Distance between two nodes e.g. `{x, y}`
  7016. * @return {void}
  7017. */
  7018. repulsive: function (node, force, distanceXY) {
  7019. var factor = force * this.diffTemperature / node.mass / node.degree;
  7020. if (!node.fixedPosition) {
  7021. node.plotX += distanceXY.x * factor;
  7022. node.plotY += distanceXY.y * factor;
  7023. }
  7024. },
  7025. /**
  7026. * Attractive force.
  7027. *
  7028. * In Verlet integration, force is applied on a node immidatelly to it's
  7029. * `plotX` and `plotY` position.
  7030. *
  7031. * @private
  7032. * @param {Highcharts.Point} link
  7033. * Link that connects two nodes
  7034. * @param {number} force
  7035. * Force calcualated in `repulsiveForceFunction`
  7036. * @param {Highcharts.PositionObject} distance
  7037. * Distance between two nodes e.g. `{x, y}`
  7038. * @return {void}
  7039. */
  7040. attractive: function (link, force, distanceXY) {
  7041. var massFactor = link.getMass(),
  7042. translatedX = -distanceXY.x * force * this.diffTemperature,
  7043. translatedY = -distanceXY.y * force * this.diffTemperature;
  7044. if (!link.fromNode.fixedPosition) {
  7045. link.fromNode.plotX -=
  7046. translatedX * massFactor.fromNode / link.fromNode.degree;
  7047. link.fromNode.plotY -=
  7048. translatedY * massFactor.fromNode / link.fromNode.degree;
  7049. }
  7050. if (!link.toNode.fixedPosition) {
  7051. link.toNode.plotX +=
  7052. translatedX * massFactor.toNode / link.toNode.degree;
  7053. link.toNode.plotY +=
  7054. translatedY * massFactor.toNode / link.toNode.degree;
  7055. }
  7056. },
  7057. /**
  7058. * Integration method.
  7059. *
  7060. * In Verlet integration, forces are applied on node immidatelly to it's
  7061. * `plotX` and `plotY` position.
  7062. *
  7063. * Verlet without velocity:
  7064. *
  7065. * x(n+1) = 2 * x(n) - x(n-1) + A(T) * deltaT ^ 2
  7066. *
  7067. * where:
  7068. * - x(n+1) - new position
  7069. * - x(n) - current position
  7070. * - x(n-1) - previous position
  7071. *
  7072. * Assuming A(t) = 0 (no acceleration) and (deltaT = 1) we get:
  7073. *
  7074. * x(n+1) = x(n) + (x(n) - x(n-1))
  7075. *
  7076. * where:
  7077. * - (x(n) - x(n-1)) - position change
  7078. *
  7079. * TO DO:
  7080. * Consider Verlet with velocity to support additional
  7081. * forces. Or even Time-Corrected Verlet by Jonathan
  7082. * "lonesock" Dummer
  7083. *
  7084. * @private
  7085. * @param {Highcharts.NetworkgraphLayout} layout layout object
  7086. * @param {Highcharts.Point} node node that should be translated
  7087. * @return {void}
  7088. */
  7089. integrate: function (layout, node) {
  7090. var friction = -layout.options.friction,
  7091. maxSpeed = layout.options.maxSpeed,
  7092. prevX = node.prevX,
  7093. prevY = node.prevY,
  7094. // Apply friciton:
  7095. diffX = ((node.plotX + node.dispX -
  7096. prevX) * friction),
  7097. diffY = ((node.plotY + node.dispY -
  7098. prevY) * friction),
  7099. abs = Math.abs,
  7100. signX = abs(diffX) / (diffX || 1), // need to deal with 0
  7101. signY = abs(diffY) / (diffY || 1);
  7102. // Apply max speed:
  7103. diffX = signX * Math.min(maxSpeed, Math.abs(diffX));
  7104. diffY = signY * Math.min(maxSpeed, Math.abs(diffY));
  7105. // Store for the next iteration:
  7106. node.prevX = node.plotX + node.dispX;
  7107. node.prevY = node.plotY + node.dispY;
  7108. // Update positions:
  7109. node.plotX += diffX;
  7110. node.plotY += diffY;
  7111. node.temperature = layout.vectorLength({
  7112. x: diffX,
  7113. y: diffY
  7114. });
  7115. },
  7116. /**
  7117. * Estiamte the best possible distance between two nodes, making graph
  7118. * readable.
  7119. *
  7120. * @private
  7121. * @param {Highcharts.NetworkgraphLayout} layout layout object
  7122. * @return {number}
  7123. */
  7124. getK: function (layout) {
  7125. return Math.pow(layout.box.width * layout.box.height / layout.nodes.length, 0.5);
  7126. }
  7127. },
  7128. euler: {
  7129. /**
  7130. * Attractive force funtion. Can be replaced by API's
  7131. * `layoutAlgorithm.attractiveForce`
  7132. *
  7133. * Other forces that can be used:
  7134. *
  7135. * basic, not recommended:
  7136. * `function (d, k) { return d / k }`
  7137. *
  7138. * @private
  7139. * @param {number} d current distance between two nodes
  7140. * @param {number} k expected distance between two nodes
  7141. * @return {number} force
  7142. */
  7143. attractiveForceFunction: function (d, k) {
  7144. return d * d / k;
  7145. },
  7146. /**
  7147. * Repulsive force funtion. Can be replaced by API's
  7148. * `layoutAlgorithm.repulsiveForce`.
  7149. *
  7150. * Other forces that can be used:
  7151. *
  7152. * basic, not recommended:
  7153. * `function (d, k) { return k / d }`
  7154. *
  7155. * standard:
  7156. * `function (d, k) { return k * k / d }`
  7157. *
  7158. * grid-variant:
  7159. * `function (d, k) { return k * k / d * (2 * k - d > 0 ? 1 : 0) }`
  7160. *
  7161. * @private
  7162. * @param {number} d current distance between two nodes
  7163. * @param {number} k expected distance between two nodes
  7164. * @return {number} force
  7165. */
  7166. repulsiveForceFunction: function (d, k) {
  7167. return k * k / d;
  7168. },
  7169. /**
  7170. * Barycenter force. Calculate and applys barycenter forces on the
  7171. * nodes. Making them closer to the center of their barycenter point.
  7172. *
  7173. * In Euler integration, force is stored in a node, not changing it's
  7174. * position. Later, in `integrate()` forces are applied on nodes.
  7175. *
  7176. * @private
  7177. * @return {void}
  7178. */
  7179. barycenter: function () {
  7180. var gravitationalConstant = this.options.gravitationalConstant,
  7181. xFactor = this.barycenter.xFactor,
  7182. yFactor = this.barycenter.yFactor;
  7183. this.nodes.forEach(function (node) {
  7184. if (!node.fixedPosition) {
  7185. var degree = node.getDegree(),
  7186. phi = degree * (1 + degree / 2);
  7187. node.dispX += ((xFactor - node.plotX) *
  7188. gravitationalConstant *
  7189. phi / node.degree);
  7190. node.dispY += ((yFactor - node.plotY) *
  7191. gravitationalConstant *
  7192. phi / node.degree);
  7193. }
  7194. });
  7195. },
  7196. /**
  7197. * Repulsive force.
  7198. *
  7199. * @private
  7200. * @param {Highcharts.Point} node
  7201. * Node that should be translated by force.
  7202. * @param {number} force
  7203. * Force calcualated in `repulsiveForceFunction`
  7204. * @param {Highcharts.PositionObject} distanceXY
  7205. * Distance between two nodes e.g. `{x, y}`
  7206. * @return {void}
  7207. */
  7208. repulsive: function (node, force, distanceXY, distanceR) {
  7209. node.dispX +=
  7210. (distanceXY.x / distanceR) * force / node.degree;
  7211. node.dispY +=
  7212. (distanceXY.y / distanceR) * force / node.degree;
  7213. },
  7214. /**
  7215. * Attractive force.
  7216. *
  7217. * In Euler integration, force is stored in a node, not changing it's
  7218. * position. Later, in `integrate()` forces are applied on nodes.
  7219. *
  7220. * @private
  7221. * @param {Highcharts.Point} link
  7222. * Link that connects two nodes
  7223. * @param {number} force
  7224. * Force calcualated in `repulsiveForceFunction`
  7225. * @param {Highcharts.PositionObject} distanceXY
  7226. * Distance between two nodes e.g. `{x, y}`
  7227. * @param {number} distanceR
  7228. * @return {void}
  7229. */
  7230. attractive: function (link, force, distanceXY, distanceR) {
  7231. var massFactor = link.getMass(),
  7232. translatedX = (distanceXY.x / distanceR) * force,
  7233. translatedY = (distanceXY.y / distanceR) * force;
  7234. if (!link.fromNode.fixedPosition) {
  7235. link.fromNode.dispX -=
  7236. translatedX * massFactor.fromNode / link.fromNode.degree;
  7237. link.fromNode.dispY -=
  7238. translatedY * massFactor.fromNode / link.fromNode.degree;
  7239. }
  7240. if (!link.toNode.fixedPosition) {
  7241. link.toNode.dispX +=
  7242. translatedX * massFactor.toNode / link.toNode.degree;
  7243. link.toNode.dispY +=
  7244. translatedY * massFactor.toNode / link.toNode.degree;
  7245. }
  7246. },
  7247. /**
  7248. * Integration method.
  7249. *
  7250. * In Euler integration, force were stored in a node, not changing it's
  7251. * position. Now, in the integrator method, we apply changes.
  7252. *
  7253. * Euler:
  7254. *
  7255. * Basic form: `x(n+1) = x(n) + v(n)`
  7256. *
  7257. * With Rengoild-Fruchterman we get:
  7258. * `x(n+1) = x(n) + v(n) / length(v(n)) * min(v(n), temperature(n))`
  7259. * where:
  7260. * - `x(n+1)`: next position
  7261. * - `x(n)`: current position
  7262. * - `v(n)`: velocity (comes from net force)
  7263. * - `temperature(n)`: current temperature
  7264. *
  7265. * Known issues:
  7266. * Oscillations when force vector has the same magnitude but opposite
  7267. * direction in the next step. Potentially solved by decreasing force by
  7268. * `v * (1 / node.degree)`
  7269. *
  7270. * Note:
  7271. * Actually `min(v(n), temperature(n))` replaces simulated annealing.
  7272. *
  7273. * @private
  7274. * @param {Highcharts.NetworkgraphLayout} layout
  7275. * Layout object
  7276. * @param {Highcharts.Point} node
  7277. * Node that should be translated
  7278. * @return {void}
  7279. */
  7280. integrate: function (layout, node) {
  7281. var distanceR;
  7282. node.dispX +=
  7283. node.dispX * layout.options.friction;
  7284. node.dispY +=
  7285. node.dispY * layout.options.friction;
  7286. distanceR = node.temperature = layout.vectorLength({
  7287. x: node.dispX,
  7288. y: node.dispY
  7289. });
  7290. if (distanceR !== 0) {
  7291. node.plotX += (node.dispX / distanceR *
  7292. Math.min(Math.abs(node.dispX), layout.temperature));
  7293. node.plotY += (node.dispY / distanceR *
  7294. Math.min(Math.abs(node.dispY), layout.temperature));
  7295. }
  7296. },
  7297. /**
  7298. * Estiamte the best possible distance between two nodes, making graph
  7299. * readable.
  7300. *
  7301. * @private
  7302. * @param {object} layout layout object
  7303. * @return {number}
  7304. */
  7305. getK: function (layout) {
  7306. return Math.pow(layout.box.width * layout.box.height / layout.nodes.length, 0.3);
  7307. }
  7308. }
  7309. };
  7310. });
  7311. _registerModule(_modules, 'Series/Networkgraph/QuadTree.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7312. /* *
  7313. *
  7314. * Networkgraph series
  7315. *
  7316. * (c) 2010-2020 Paweł Fus
  7317. *
  7318. * License: www.highcharts.com/license
  7319. *
  7320. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7321. *
  7322. * */
  7323. var extend = U.extend;
  7324. /* eslint-disable no-invalid-this, valid-jsdoc */
  7325. /**
  7326. * The QuadTree node class. Used in Networkgraph chart as a base for Barnes-Hut
  7327. * approximation.
  7328. *
  7329. * @private
  7330. * @class
  7331. * @name Highcharts.QuadTreeNode
  7332. *
  7333. * @param {Highcharts.Dictionary<number>} box Available space for the node
  7334. */
  7335. var QuadTreeNode = H.QuadTreeNode = function (box) {
  7336. /**
  7337. * Read only. The available space for node.
  7338. *
  7339. * @name Highcharts.QuadTreeNode#box
  7340. * @type {Highcharts.Dictionary<number>}
  7341. */
  7342. this.box = box;
  7343. /**
  7344. * Read only. The minium of width and height values.
  7345. *
  7346. * @name Highcharts.QuadTreeNode#boxSize
  7347. * @type {number}
  7348. */
  7349. this.boxSize = Math.min(box.width, box.height);
  7350. /**
  7351. * Read only. Array of subnodes. Empty if QuadTreeNode has just one Point.
  7352. * When added another Point to this QuadTreeNode, array is filled with four
  7353. * subnodes.
  7354. *
  7355. * @name Highcharts.QuadTreeNode#nodes
  7356. * @type {Array<Highcharts.QuadTreeNode>}
  7357. */
  7358. this.nodes = [];
  7359. /**
  7360. * Read only. Flag to determine if QuadTreeNode is internal (and has
  7361. * subnodes with mass and central position) or external (bound to Point).
  7362. *
  7363. * @name Highcharts.QuadTreeNode#isInternal
  7364. * @type {boolean}
  7365. */
  7366. this.isInternal = false;
  7367. /**
  7368. * Read only. If QuadTreeNode is an external node, Point is stored in
  7369. * `this.body`.
  7370. *
  7371. * @name Highcharts.QuadTreeNode#body
  7372. * @type {boolean|Highcharts.Point}
  7373. */
  7374. this.body = false;
  7375. /**
  7376. * Read only. Internal nodes when created are empty to reserve the space. If
  7377. * Point is added to this QuadTreeNode, QuadTreeNode is no longer empty.
  7378. *
  7379. * @name Highcharts.QuadTreeNode#isEmpty
  7380. * @type {boolean}
  7381. */
  7382. this.isEmpty = true;
  7383. };
  7384. extend(QuadTreeNode.prototype,
  7385. /** @lends Highcharts.QuadTreeNode.prototype */
  7386. {
  7387. /**
  7388. * Insert recursively point(node) into the QuadTree. If the given
  7389. * quadrant is already occupied, divide it into smaller quadrants.
  7390. *
  7391. * @param {Highcharts.Point} point
  7392. * Point/node to be inserted
  7393. * @param {number} depth
  7394. * Max depth of the QuadTree
  7395. */
  7396. insert: function (point, depth) {
  7397. var newQuadTreeNode;
  7398. if (this.isInternal) {
  7399. // Internal node:
  7400. this.nodes[this.getBoxPosition(point)].insert(point, depth - 1);
  7401. }
  7402. else {
  7403. this.isEmpty = false;
  7404. if (!this.body) {
  7405. // First body in a quadrant:
  7406. this.isInternal = false;
  7407. this.body = point;
  7408. }
  7409. else {
  7410. if (depth) {
  7411. // Every other body in a quadrant:
  7412. this.isInternal = true;
  7413. this.divideBox();
  7414. // Reinsert main body only once:
  7415. if (this.body !== true) {
  7416. this.nodes[this.getBoxPosition(this.body)]
  7417. .insert(this.body, depth - 1);
  7418. this.body = true;
  7419. }
  7420. // Add second body:
  7421. this.nodes[this.getBoxPosition(point)]
  7422. .insert(point, depth - 1);
  7423. }
  7424. else {
  7425. // We are below max allowed depth. That means either:
  7426. // - really huge number of points
  7427. // - falling two points into exactly the same position
  7428. // In this case, create another node in the QuadTree.
  7429. //
  7430. // Alternatively we could add some noise to the
  7431. // position, but that could result in different
  7432. // rendered chart in exporting.
  7433. newQuadTreeNode = new QuadTreeNode({
  7434. top: point.plotX,
  7435. left: point.plotY,
  7436. // Width/height below 1px
  7437. width: 0.1,
  7438. height: 0.1
  7439. });
  7440. newQuadTreeNode.body = point;
  7441. newQuadTreeNode.isInternal = false;
  7442. this.nodes.push(newQuadTreeNode);
  7443. }
  7444. }
  7445. }
  7446. },
  7447. /**
  7448. * Each quad node requires it's mass and center position. That mass and
  7449. * position is used to imitate real node in the layout by approximation.
  7450. */
  7451. updateMassAndCenter: function () {
  7452. var mass = 0,
  7453. plotX = 0,
  7454. plotY = 0;
  7455. if (this.isInternal) {
  7456. // Calcualte weightened mass of the quad node:
  7457. this.nodes.forEach(function (pointMass) {
  7458. if (!pointMass.isEmpty) {
  7459. mass += pointMass.mass;
  7460. plotX +=
  7461. pointMass.plotX * pointMass.mass;
  7462. plotY +=
  7463. pointMass.plotY * pointMass.mass;
  7464. }
  7465. });
  7466. plotX /= mass;
  7467. plotY /= mass;
  7468. }
  7469. else if (this.body) {
  7470. // Just one node, use coordinates directly:
  7471. mass = this.body.mass;
  7472. plotX = this.body.plotX;
  7473. plotY = this.body.plotY;
  7474. }
  7475. // Store details:
  7476. this.mass = mass;
  7477. this.plotX = plotX;
  7478. this.plotY = plotY;
  7479. },
  7480. /**
  7481. * When inserting another node into the box, that already hove one node,
  7482. * divide the available space into another four quadrants.
  7483. *
  7484. * Indexes of quadrants are:
  7485. * ```
  7486. * ------------- -------------
  7487. * | | | | |
  7488. * | | | 0 | 1 |
  7489. * | | divide() | | |
  7490. * | 1 | -----------> -------------
  7491. * | | | | |
  7492. * | | | 3 | 2 |
  7493. * | | | | |
  7494. * ------------- -------------
  7495. * ```
  7496. */
  7497. divideBox: function () {
  7498. var halfWidth = this.box.width / 2,
  7499. halfHeight = this.box.height / 2;
  7500. // Top left
  7501. this.nodes[0] = new QuadTreeNode({
  7502. left: this.box.left,
  7503. top: this.box.top,
  7504. width: halfWidth,
  7505. height: halfHeight
  7506. });
  7507. // Top right
  7508. this.nodes[1] = new QuadTreeNode({
  7509. left: this.box.left + halfWidth,
  7510. top: this.box.top,
  7511. width: halfWidth,
  7512. height: halfHeight
  7513. });
  7514. // Bottom right
  7515. this.nodes[2] = new QuadTreeNode({
  7516. left: this.box.left + halfWidth,
  7517. top: this.box.top + halfHeight,
  7518. width: halfWidth,
  7519. height: halfHeight
  7520. });
  7521. // Bottom left
  7522. this.nodes[3] = new QuadTreeNode({
  7523. left: this.box.left,
  7524. top: this.box.top + halfHeight,
  7525. width: halfWidth,
  7526. height: halfHeight
  7527. });
  7528. },
  7529. /**
  7530. * Determine which of the quadrants should be used when placing node in
  7531. * the QuadTree. Returned index is always in range `< 0 , 3 >`.
  7532. *
  7533. * @param {Highcharts.Point} point
  7534. * @return {number}
  7535. */
  7536. getBoxPosition: function (point) {
  7537. var left = point.plotX < this.box.left + this.box.width / 2,
  7538. top = point.plotY < this.box.top + this.box.height / 2,
  7539. index;
  7540. if (left) {
  7541. if (top) {
  7542. // Top left
  7543. index = 0;
  7544. }
  7545. else {
  7546. // Bottom left
  7547. index = 3;
  7548. }
  7549. }
  7550. else {
  7551. if (top) {
  7552. // Top right
  7553. index = 1;
  7554. }
  7555. else {
  7556. // Bottom right
  7557. index = 2;
  7558. }
  7559. }
  7560. return index;
  7561. }
  7562. });
  7563. /**
  7564. * The QuadTree class. Used in Networkgraph chart as a base for Barnes-Hut
  7565. * approximation.
  7566. *
  7567. * @private
  7568. * @class
  7569. * @name Highcharts.QuadTree
  7570. *
  7571. * @param {number} x left position of the plotting area
  7572. * @param {number} y top position of the plotting area
  7573. * @param {number} width width of the plotting area
  7574. * @param {number} height height of the plotting area
  7575. */
  7576. var QuadTree = H.QuadTree = function (x,
  7577. y,
  7578. width,
  7579. height) {
  7580. // Boundary rectangle:
  7581. this.box = {
  7582. left: x,
  7583. top: y,
  7584. width: width,
  7585. height: height
  7586. };
  7587. this.maxDepth = 25;
  7588. this.root = new QuadTreeNode(this.box, '0');
  7589. this.root.isInternal = true;
  7590. this.root.isRoot = true;
  7591. this.root.divideBox();
  7592. };
  7593. extend(QuadTree.prototype,
  7594. /** @lends Highcharts.QuadTree.prototype */
  7595. {
  7596. /**
  7597. * Insert nodes into the QuadTree
  7598. *
  7599. * @param {Array<Highcharts.Point>} points
  7600. */
  7601. insertNodes: function (points) {
  7602. points.forEach(function (point) {
  7603. this.root.insert(point, this.maxDepth);
  7604. }, this);
  7605. },
  7606. /**
  7607. * Depfth first treversal (DFS). Using `before` and `after` callbacks,
  7608. * we can get two results: preorder and postorder traversals, reminder:
  7609. *
  7610. * ```
  7611. * (a)
  7612. * / \
  7613. * (b) (c)
  7614. * / \
  7615. * (d) (e)
  7616. * ```
  7617. *
  7618. * DFS (preorder): `a -> b -> d -> e -> c`
  7619. *
  7620. * DFS (postorder): `d -> e -> b -> c -> a`
  7621. *
  7622. * @param {Highcharts.QuadTreeNode|null} node
  7623. * @param {Function} [beforeCallback] function to be called before
  7624. * visiting children nodes
  7625. * @param {Function} [afterCallback] function to be called after
  7626. * visiting children nodes
  7627. */
  7628. visitNodeRecursive: function (node, beforeCallback, afterCallback) {
  7629. var goFurther;
  7630. if (!node) {
  7631. node = this.root;
  7632. }
  7633. if (node === this.root && beforeCallback) {
  7634. goFurther = beforeCallback(node);
  7635. }
  7636. if (goFurther === false) {
  7637. return;
  7638. }
  7639. node.nodes.forEach(function (qtNode) {
  7640. if (qtNode.isInternal) {
  7641. if (beforeCallback) {
  7642. goFurther = beforeCallback(qtNode);
  7643. }
  7644. if (goFurther === false) {
  7645. return;
  7646. }
  7647. this.visitNodeRecursive(qtNode, beforeCallback, afterCallback);
  7648. }
  7649. else if (qtNode.body) {
  7650. if (beforeCallback) {
  7651. beforeCallback(qtNode.body);
  7652. }
  7653. }
  7654. if (afterCallback) {
  7655. afterCallback(qtNode);
  7656. }
  7657. }, this);
  7658. if (node === this.root && afterCallback) {
  7659. afterCallback(node);
  7660. }
  7661. },
  7662. /**
  7663. * Calculate mass of the each QuadNode in the tree.
  7664. */
  7665. calculateMassAndCenter: function () {
  7666. this.visitNodeRecursive(null, null, function (node) {
  7667. node.updateMassAndCenter();
  7668. });
  7669. }
  7670. });
  7671. });
  7672. _registerModule(_modules, 'Series/Networkgraph/Layouts.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Chart, A, H, U) {
  7673. /* *
  7674. *
  7675. * Networkgraph series
  7676. *
  7677. * (c) 2010-2020 Paweł Fus
  7678. *
  7679. * License: www.highcharts.com/license
  7680. *
  7681. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7682. *
  7683. * */
  7684. var setAnimation = A.setAnimation;
  7685. var addEvent = U.addEvent,
  7686. clamp = U.clamp,
  7687. defined = U.defined,
  7688. extend = U.extend,
  7689. isFunction = U.isFunction,
  7690. pick = U.pick;
  7691. /* eslint-disable no-invalid-this, valid-jsdoc */
  7692. H.layouts = {
  7693. 'reingold-fruchterman': function () {
  7694. }
  7695. };
  7696. extend(
  7697. /**
  7698. * Reingold-Fruchterman algorithm from
  7699. * "Graph Drawing by Force-directed Placement" paper.
  7700. * @private
  7701. */
  7702. H.layouts['reingold-fruchterman'].prototype, {
  7703. init: function (options) {
  7704. this.options = options;
  7705. this.nodes = [];
  7706. this.links = [];
  7707. this.series = [];
  7708. this.box = {
  7709. x: 0,
  7710. y: 0,
  7711. width: 0,
  7712. height: 0
  7713. };
  7714. this.setInitialRendering(true);
  7715. this.integration =
  7716. H.networkgraphIntegrations[options.integration];
  7717. this.enableSimulation = options.enableSimulation;
  7718. this.attractiveForce = pick(options.attractiveForce, this.integration.attractiveForceFunction);
  7719. this.repulsiveForce = pick(options.repulsiveForce, this.integration.repulsiveForceFunction);
  7720. this.approximation = options.approximation;
  7721. },
  7722. updateSimulation: function (enable) {
  7723. this.enableSimulation = pick(enable, this.options.enableSimulation);
  7724. },
  7725. start: function () {
  7726. var layout = this,
  7727. series = this.series,
  7728. options = this.options;
  7729. layout.currentStep = 0;
  7730. layout.forces = series[0] && series[0].forces || [];
  7731. layout.chart = series[0] && series[0].chart;
  7732. if (layout.initialRendering) {
  7733. layout.initPositions();
  7734. // Render elements in initial positions:
  7735. series.forEach(function (s) {
  7736. s.finishedAnimating = true; // #13169
  7737. s.render();
  7738. });
  7739. }
  7740. layout.setK();
  7741. layout.resetSimulation(options);
  7742. if (layout.enableSimulation) {
  7743. layout.step();
  7744. }
  7745. },
  7746. step: function () {
  7747. var layout = this,
  7748. series = this.series,
  7749. options = this.options;
  7750. // Algorithm:
  7751. layout.currentStep++;
  7752. if (layout.approximation === 'barnes-hut') {
  7753. layout.createQuadTree();
  7754. layout.quadTree.calculateMassAndCenter();
  7755. }
  7756. layout.forces.forEach(function (forceName) {
  7757. layout[forceName + 'Forces'](layout.temperature);
  7758. });
  7759. // Limit to the plotting area and cool down:
  7760. layout.applyLimits(layout.temperature);
  7761. // Cool down the system:
  7762. layout.temperature = layout.coolDown(layout.startTemperature, layout.diffTemperature, layout.currentStep);
  7763. layout.prevSystemTemperature = layout.systemTemperature;
  7764. layout.systemTemperature = layout.getSystemTemperature();
  7765. if (layout.enableSimulation) {
  7766. series.forEach(function (s) {
  7767. // Chart could be destroyed during the simulation
  7768. if (s.chart) {
  7769. s.render();
  7770. }
  7771. });
  7772. if (layout.maxIterations-- &&
  7773. isFinite(layout.temperature) &&
  7774. !layout.isStable()) {
  7775. if (layout.simulation) {
  7776. H.win.cancelAnimationFrame(layout.simulation);
  7777. }
  7778. layout.simulation = H.win.requestAnimationFrame(function () {
  7779. layout.step();
  7780. });
  7781. }
  7782. else {
  7783. layout.simulation = false;
  7784. }
  7785. }
  7786. },
  7787. stop: function () {
  7788. if (this.simulation) {
  7789. H.win.cancelAnimationFrame(this.simulation);
  7790. }
  7791. },
  7792. setArea: function (x, y, w, h) {
  7793. this.box = {
  7794. left: x,
  7795. top: y,
  7796. width: w,
  7797. height: h
  7798. };
  7799. },
  7800. setK: function () {
  7801. // Optimal distance between nodes,
  7802. // available space around the node:
  7803. this.k = this.options.linkLength || this.integration.getK(this);
  7804. },
  7805. addElementsToCollection: function (elements, collection) {
  7806. elements.forEach(function (elem) {
  7807. if (collection.indexOf(elem) === -1) {
  7808. collection.push(elem);
  7809. }
  7810. });
  7811. },
  7812. removeElementFromCollection: function (element, collection) {
  7813. var index = collection.indexOf(element);
  7814. if (index !== -1) {
  7815. collection.splice(index, 1);
  7816. }
  7817. },
  7818. clear: function () {
  7819. this.nodes.length = 0;
  7820. this.links.length = 0;
  7821. this.series.length = 0;
  7822. this.resetSimulation();
  7823. },
  7824. resetSimulation: function () {
  7825. this.forcedStop = false;
  7826. this.systemTemperature = 0;
  7827. this.setMaxIterations();
  7828. this.setTemperature();
  7829. this.setDiffTemperature();
  7830. },
  7831. restartSimulation: function () {
  7832. if (!this.simulation) {
  7833. // When dragging nodes, we don't need to calculate
  7834. // initial positions and rendering nodes:
  7835. this.setInitialRendering(false);
  7836. // Start new simulation:
  7837. if (!this.enableSimulation) {
  7838. // Run only one iteration to speed things up:
  7839. this.setMaxIterations(1);
  7840. }
  7841. else {
  7842. this.start();
  7843. }
  7844. if (this.chart) {
  7845. this.chart.redraw();
  7846. }
  7847. // Restore defaults:
  7848. this.setInitialRendering(true);
  7849. }
  7850. else {
  7851. // Extend current simulation:
  7852. this.resetSimulation();
  7853. }
  7854. },
  7855. setMaxIterations: function (maxIterations) {
  7856. this.maxIterations = pick(maxIterations, this.options.maxIterations);
  7857. },
  7858. setTemperature: function () {
  7859. this.temperature = this.startTemperature =
  7860. Math.sqrt(this.nodes.length);
  7861. },
  7862. setDiffTemperature: function () {
  7863. this.diffTemperature = this.startTemperature /
  7864. (this.options.maxIterations + 1);
  7865. },
  7866. setInitialRendering: function (enable) {
  7867. this.initialRendering = enable;
  7868. },
  7869. createQuadTree: function () {
  7870. this.quadTree = new H.QuadTree(this.box.left, this.box.top, this.box.width, this.box.height);
  7871. this.quadTree.insertNodes(this.nodes);
  7872. },
  7873. initPositions: function () {
  7874. var initialPositions = this.options.initialPositions;
  7875. if (isFunction(initialPositions)) {
  7876. initialPositions.call(this);
  7877. this.nodes.forEach(function (node) {
  7878. if (!defined(node.prevX)) {
  7879. node.prevX = node.plotX;
  7880. }
  7881. if (!defined(node.prevY)) {
  7882. node.prevY = node.plotY;
  7883. }
  7884. node.dispX = 0;
  7885. node.dispY = 0;
  7886. });
  7887. }
  7888. else if (initialPositions === 'circle') {
  7889. this.setCircularPositions();
  7890. }
  7891. else {
  7892. this.setRandomPositions();
  7893. }
  7894. },
  7895. setCircularPositions: function () {
  7896. var box = this.box,
  7897. nodes = this.nodes,
  7898. nodesLength = nodes.length + 1,
  7899. angle = 2 * Math.PI / nodesLength,
  7900. rootNodes = nodes.filter(function (node) {
  7901. return node.linksTo.length === 0;
  7902. }), sortedNodes = [], visitedNodes = {}, radius = this.options.initialPositionRadius;
  7903. /**
  7904. * @private
  7905. */
  7906. function addToNodes(node) {
  7907. node.linksFrom.forEach(function (link) {
  7908. if (!visitedNodes[link.toNode.id]) {
  7909. visitedNodes[link.toNode.id] = true;
  7910. sortedNodes.push(link.toNode);
  7911. addToNodes(link.toNode);
  7912. }
  7913. });
  7914. }
  7915. // Start with identified root nodes an sort the nodes by their
  7916. // hierarchy. In trees, this ensures that branches don't cross
  7917. // eachother.
  7918. rootNodes.forEach(function (rootNode) {
  7919. sortedNodes.push(rootNode);
  7920. addToNodes(rootNode);
  7921. });
  7922. // Cyclic tree, no root node found
  7923. if (!sortedNodes.length) {
  7924. sortedNodes = nodes;
  7925. // Dangling, cyclic trees
  7926. }
  7927. else {
  7928. nodes.forEach(function (node) {
  7929. if (sortedNodes.indexOf(node) === -1) {
  7930. sortedNodes.push(node);
  7931. }
  7932. });
  7933. }
  7934. // Initial positions are laid out along a small circle, appearing
  7935. // as a cluster in the middle
  7936. sortedNodes.forEach(function (node, index) {
  7937. node.plotX = node.prevX = pick(node.plotX, box.width / 2 + radius * Math.cos(index * angle));
  7938. node.plotY = node.prevY = pick(node.plotY, box.height / 2 + radius * Math.sin(index * angle));
  7939. node.dispX = 0;
  7940. node.dispY = 0;
  7941. });
  7942. },
  7943. setRandomPositions: function () {
  7944. var box = this.box,
  7945. nodes = this.nodes,
  7946. nodesLength = nodes.length + 1;
  7947. /**
  7948. * Return a repeatable, quasi-random number based on an integer
  7949. * input. For the initial positions
  7950. * @private
  7951. */
  7952. function unrandom(n) {
  7953. var rand = n * n / Math.PI;
  7954. rand = rand - Math.floor(rand);
  7955. return rand;
  7956. }
  7957. // Initial positions:
  7958. nodes.forEach(function (node, index) {
  7959. node.plotX = node.prevX = pick(node.plotX, box.width * unrandom(index));
  7960. node.plotY = node.prevY = pick(node.plotY, box.height * unrandom(nodesLength + index));
  7961. node.dispX = 0;
  7962. node.dispY = 0;
  7963. });
  7964. },
  7965. force: function (name) {
  7966. this.integration[name].apply(this, Array.prototype.slice.call(arguments, 1));
  7967. },
  7968. barycenterForces: function () {
  7969. this.getBarycenter();
  7970. this.force('barycenter');
  7971. },
  7972. getBarycenter: function () {
  7973. var systemMass = 0,
  7974. cx = 0,
  7975. cy = 0;
  7976. this.nodes.forEach(function (node) {
  7977. cx += node.plotX * node.mass;
  7978. cy += node.plotY * node.mass;
  7979. systemMass += node.mass;
  7980. });
  7981. this.barycenter = {
  7982. x: cx,
  7983. y: cy,
  7984. xFactor: cx / systemMass,
  7985. yFactor: cy / systemMass
  7986. };
  7987. return this.barycenter;
  7988. },
  7989. barnesHutApproximation: function (node, quadNode) {
  7990. var layout = this,
  7991. distanceXY = layout.getDistXY(node,
  7992. quadNode),
  7993. distanceR = layout.vectorLength(distanceXY),
  7994. goDeeper,
  7995. force;
  7996. if (node !== quadNode && distanceR !== 0) {
  7997. if (quadNode.isInternal) {
  7998. // Internal node:
  7999. if (quadNode.boxSize / distanceR <
  8000. layout.options.theta &&
  8001. distanceR !== 0) {
  8002. // Treat as an external node:
  8003. force = layout.repulsiveForce(distanceR, layout.k);
  8004. layout.force('repulsive', node, force * quadNode.mass, distanceXY, distanceR);
  8005. goDeeper = false;
  8006. }
  8007. else {
  8008. // Go deeper:
  8009. goDeeper = true;
  8010. }
  8011. }
  8012. else {
  8013. // External node, direct force:
  8014. force = layout.repulsiveForce(distanceR, layout.k);
  8015. layout.force('repulsive', node, force * quadNode.mass, distanceXY, distanceR);
  8016. }
  8017. }
  8018. return goDeeper;
  8019. },
  8020. repulsiveForces: function () {
  8021. var layout = this;
  8022. if (layout.approximation === 'barnes-hut') {
  8023. layout.nodes.forEach(function (node) {
  8024. layout.quadTree.visitNodeRecursive(null, function (quadNode) {
  8025. return layout.barnesHutApproximation(node, quadNode);
  8026. });
  8027. });
  8028. }
  8029. else {
  8030. layout.nodes.forEach(function (node) {
  8031. layout.nodes.forEach(function (repNode) {
  8032. var force,
  8033. distanceR,
  8034. distanceXY;
  8035. if (
  8036. // Node can not repulse itself:
  8037. node !== repNode &&
  8038. // Only close nodes affect each other:
  8039. // layout.getDistR(node, repNode) < 2 * k &&
  8040. // Not dragged:
  8041. !node.fixedPosition) {
  8042. distanceXY = layout.getDistXY(node, repNode);
  8043. distanceR = layout.vectorLength(distanceXY);
  8044. if (distanceR !== 0) {
  8045. force = layout.repulsiveForce(distanceR, layout.k);
  8046. layout.force('repulsive', node, force * repNode.mass, distanceXY, distanceR);
  8047. }
  8048. }
  8049. });
  8050. });
  8051. }
  8052. },
  8053. attractiveForces: function () {
  8054. var layout = this,
  8055. distanceXY,
  8056. distanceR,
  8057. force;
  8058. layout.links.forEach(function (link) {
  8059. if (link.fromNode && link.toNode) {
  8060. distanceXY = layout.getDistXY(link.fromNode, link.toNode);
  8061. distanceR = layout.vectorLength(distanceXY);
  8062. if (distanceR !== 0) {
  8063. force = layout.attractiveForce(distanceR, layout.k);
  8064. layout.force('attractive', link, force, distanceXY, distanceR);
  8065. }
  8066. }
  8067. });
  8068. },
  8069. applyLimits: function () {
  8070. var layout = this,
  8071. nodes = layout.nodes;
  8072. nodes.forEach(function (node) {
  8073. if (node.fixedPosition) {
  8074. return;
  8075. }
  8076. layout.integration.integrate(layout, node);
  8077. layout.applyLimitBox(node, layout.box);
  8078. // Reset displacement:
  8079. node.dispX = 0;
  8080. node.dispY = 0;
  8081. });
  8082. },
  8083. /**
  8084. * External box that nodes should fall. When hitting an edge, node
  8085. * should stop or bounce.
  8086. * @private
  8087. */
  8088. applyLimitBox: function (node, box) {
  8089. var radius = node.radius;
  8090. /*
  8091. TO DO: Consider elastic collision instead of stopping.
  8092. o' means end position when hitting plotting area edge:
  8093. - "inelastic":
  8094. o
  8095. \
  8096. ______
  8097. | o'
  8098. | \
  8099. | \
  8100. - "elastic"/"bounced":
  8101. o
  8102. \
  8103. ______
  8104. | ^
  8105. | / \
  8106. |o' \
  8107. Euler sample:
  8108. if (plotX < 0) {
  8109. plotX = 0;
  8110. dispX *= -1;
  8111. }
  8112. if (plotX > box.width) {
  8113. plotX = box.width;
  8114. dispX *= -1;
  8115. }
  8116. */
  8117. // Limit X-coordinates:
  8118. node.plotX = clamp(node.plotX, box.left + radius, box.width - radius);
  8119. // Limit Y-coordinates:
  8120. node.plotY = clamp(node.plotY, box.top + radius, box.height - radius);
  8121. },
  8122. /**
  8123. * From "A comparison of simulated annealing cooling strategies" by
  8124. * Nourani and Andresen work.
  8125. * @private
  8126. */
  8127. coolDown: function (temperature, temperatureStep, currentStep) {
  8128. // Logarithmic:
  8129. /*
  8130. return Math.sqrt(this.nodes.length) -
  8131. Math.log(
  8132. currentStep * layout.diffTemperature
  8133. );
  8134. */
  8135. // Exponential:
  8136. /*
  8137. var alpha = 0.1;
  8138. layout.temperature = Math.sqrt(layout.nodes.length) *
  8139. Math.pow(alpha, layout.diffTemperature);
  8140. */
  8141. // Linear:
  8142. return temperature - temperatureStep * currentStep;
  8143. },
  8144. isStable: function () {
  8145. return Math.abs(this.systemTemperature -
  8146. this.prevSystemTemperature) < 0.00001 || this.temperature <= 0;
  8147. },
  8148. getSystemTemperature: function () {
  8149. return this.nodes.reduce(function (value, node) {
  8150. return value + node.temperature;
  8151. }, 0);
  8152. },
  8153. vectorLength: function (vector) {
  8154. return Math.sqrt(vector.x * vector.x + vector.y * vector.y);
  8155. },
  8156. getDistR: function (nodeA, nodeB) {
  8157. var distance = this.getDistXY(nodeA,
  8158. nodeB);
  8159. return this.vectorLength(distance);
  8160. },
  8161. getDistXY: function (nodeA, nodeB) {
  8162. var xDist = nodeA.plotX - nodeB.plotX,
  8163. yDist = nodeA.plotY - nodeB.plotY;
  8164. return {
  8165. x: xDist,
  8166. y: yDist,
  8167. absX: Math.abs(xDist),
  8168. absY: Math.abs(yDist)
  8169. };
  8170. }
  8171. });
  8172. /* ************************************************************************** *
  8173. * Multiple series support:
  8174. * ************************************************************************** */
  8175. // Clear previous layouts
  8176. addEvent(Chart, 'predraw', function () {
  8177. if (this.graphLayoutsLookup) {
  8178. this.graphLayoutsLookup.forEach(function (layout) {
  8179. layout.stop();
  8180. });
  8181. }
  8182. });
  8183. addEvent(Chart, 'render', function () {
  8184. var systemsStable,
  8185. afterRender = false;
  8186. /**
  8187. * @private
  8188. */
  8189. function layoutStep(layout) {
  8190. if (layout.maxIterations-- &&
  8191. isFinite(layout.temperature) &&
  8192. !layout.isStable() &&
  8193. !layout.enableSimulation) {
  8194. // Hook similar to build-in addEvent, but instead of
  8195. // creating whole events logic, use just a function.
  8196. // It's faster which is important for rAF code.
  8197. // Used e.g. in packed-bubble series for bubble radius
  8198. // calculations
  8199. if (layout.beforeStep) {
  8200. layout.beforeStep();
  8201. }
  8202. layout.step();
  8203. systemsStable = false;
  8204. afterRender = true;
  8205. }
  8206. }
  8207. if (this.graphLayoutsLookup) {
  8208. setAnimation(false, this);
  8209. // Start simulation
  8210. this.graphLayoutsLookup.forEach(function (layout) {
  8211. layout.start();
  8212. });
  8213. // Just one sync step, to run different layouts similar to
  8214. // async mode.
  8215. while (!systemsStable) {
  8216. systemsStable = true;
  8217. this.graphLayoutsLookup.forEach(layoutStep);
  8218. }
  8219. if (afterRender) {
  8220. this.series.forEach(function (s) {
  8221. if (s && s.layout) {
  8222. s.render();
  8223. }
  8224. });
  8225. }
  8226. }
  8227. });
  8228. // disable simulation before print if enabled
  8229. addEvent(Chart, 'beforePrint', function () {
  8230. if (this.graphLayoutsLookup) {
  8231. this.graphLayoutsLookup.forEach(function (layout) {
  8232. layout.updateSimulation(false);
  8233. });
  8234. this.redraw();
  8235. }
  8236. });
  8237. // re-enable simulation after print
  8238. addEvent(Chart, 'afterPrint', function () {
  8239. if (this.graphLayoutsLookup) {
  8240. this.graphLayoutsLookup.forEach(function (layout) {
  8241. // return to default simulation
  8242. layout.updateSimulation();
  8243. });
  8244. }
  8245. this.redraw();
  8246. });
  8247. });
  8248. _registerModule(_modules, 'Series/PackedBubbleSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (BaseSeries, Chart, Color, H, Point, U) {
  8249. /* *
  8250. *
  8251. * (c) 2010-2018 Grzegorz Blachlinski, Sebastian Bochan
  8252. *
  8253. * License: www.highcharts.com/license
  8254. *
  8255. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8256. *
  8257. * */
  8258. var color = Color.parse;
  8259. var addEvent = U.addEvent,
  8260. clamp = U.clamp,
  8261. defined = U.defined,
  8262. extend = U.extend,
  8263. extendClass = U.extendClass,
  8264. fireEvent = U.fireEvent,
  8265. isArray = U.isArray,
  8266. isNumber = U.isNumber,
  8267. merge = U.merge,
  8268. pick = U.pick;
  8269. var Series = H.Series,
  8270. Reingold = H.layouts['reingold-fruchterman'],
  8271. dragNodesMixin = H.dragNodesMixin;
  8272. /**
  8273. * Formatter callback function.
  8274. *
  8275. * @callback Highcharts.SeriesPackedBubbleDataLabelsFormatterCallbackFunction
  8276. *
  8277. * @param {Highcharts.SeriesPackedBubbleDataLabelsFormatterContextObject} this
  8278. * Data label context to format
  8279. *
  8280. * @return {string}
  8281. * Formatted data label text
  8282. */
  8283. /**
  8284. * Context for the formatter function.
  8285. *
  8286. * @interface Highcharts.SeriesPackedBubbleDataLabelsFormatterContextObject
  8287. * @extends Highcharts.PointLabelObject
  8288. * @since 7.0.0
  8289. */ /**
  8290. * The color of the node.
  8291. * @name Highcharts.SeriesPackedBubbleDataLabelsFormatterContextObject#color
  8292. * @type {Highcharts.ColorString}
  8293. * @since 7.0.0
  8294. */ /**
  8295. * The point (node) object. The node name, if defined, is available through
  8296. * `this.point.name`. Arrays: `this.point.linksFrom` and `this.point.linksTo`
  8297. * contains all nodes connected to this point.
  8298. * @name Highcharts.SeriesPackedBubbleDataLabelsFormatterContextObject#point
  8299. * @type {Highcharts.Point}
  8300. * @since 7.0.0
  8301. */ /**
  8302. * The ID of the node.
  8303. * @name Highcharts.SeriesPackedBubbleDataLabelsFormatterContextObject#key
  8304. * @type {string}
  8305. * @since 7.0.0
  8306. */
  8307. ''; // detach doclets above
  8308. Chart.prototype.getSelectedParentNodes = function () {
  8309. var chart = this,
  8310. series = chart.series,
  8311. selectedParentsNodes = [];
  8312. series.forEach(function (series) {
  8313. if (series.parentNode && series.parentNode.selected) {
  8314. selectedParentsNodes.push(series.parentNode);
  8315. }
  8316. });
  8317. return selectedParentsNodes;
  8318. };
  8319. H.networkgraphIntegrations.packedbubble = {
  8320. repulsiveForceFunction: function (d, k, node, repNode) {
  8321. return Math.min(d, (node.marker.radius + repNode.marker.radius) / 2);
  8322. },
  8323. barycenter: function () {
  8324. var layout = this,
  8325. gravitationalConstant = layout.options.gravitationalConstant,
  8326. box = layout.box,
  8327. nodes = layout.nodes,
  8328. centerX,
  8329. centerY;
  8330. nodes.forEach(function (node) {
  8331. if (layout.options.splitSeries && !node.isParentNode) {
  8332. centerX = node.series.parentNode.plotX;
  8333. centerY = node.series.parentNode.plotY;
  8334. }
  8335. else {
  8336. centerX = box.width / 2;
  8337. centerY = box.height / 2;
  8338. }
  8339. if (!node.fixedPosition) {
  8340. node.plotX -=
  8341. (node.plotX - centerX) *
  8342. gravitationalConstant /
  8343. (node.mass * Math.sqrt(nodes.length));
  8344. node.plotY -=
  8345. (node.plotY - centerY) *
  8346. gravitationalConstant /
  8347. (node.mass * Math.sqrt(nodes.length));
  8348. }
  8349. });
  8350. },
  8351. repulsive: function (node, force, distanceXY, repNode) {
  8352. var factor = (force * this.diffTemperature / node.mass /
  8353. node.degree),
  8354. x = distanceXY.x * factor,
  8355. y = distanceXY.y * factor;
  8356. if (!node.fixedPosition) {
  8357. node.plotX += x;
  8358. node.plotY += y;
  8359. }
  8360. if (!repNode.fixedPosition) {
  8361. repNode.plotX -= x;
  8362. repNode.plotY -= y;
  8363. }
  8364. },
  8365. integrate: H.networkgraphIntegrations.verlet.integrate,
  8366. getK: H.noop
  8367. };
  8368. H.layouts.packedbubble = extendClass(Reingold, {
  8369. beforeStep: function () {
  8370. if (this.options.marker) {
  8371. this.series.forEach(function (series) {
  8372. if (series) {
  8373. series.calculateParentRadius();
  8374. }
  8375. });
  8376. }
  8377. },
  8378. setCircularPositions: function () {
  8379. var layout = this,
  8380. box = layout.box,
  8381. nodes = layout.nodes,
  8382. nodesLength = nodes.length + 1,
  8383. angle = 2 * Math.PI / nodesLength,
  8384. centerX,
  8385. centerY,
  8386. radius = layout.options.initialPositionRadius;
  8387. nodes.forEach(function (node, index) {
  8388. if (layout.options.splitSeries &&
  8389. !node.isParentNode) {
  8390. centerX = node.series.parentNode.plotX;
  8391. centerY = node.series.parentNode.plotY;
  8392. }
  8393. else {
  8394. centerX = box.width / 2;
  8395. centerY = box.height / 2;
  8396. }
  8397. node.plotX = node.prevX = pick(node.plotX, centerX +
  8398. radius * Math.cos(node.index || index * angle));
  8399. node.plotY = node.prevY = pick(node.plotY, centerY +
  8400. radius * Math.sin(node.index || index * angle));
  8401. node.dispX = 0;
  8402. node.dispY = 0;
  8403. });
  8404. },
  8405. repulsiveForces: function () {
  8406. var layout = this,
  8407. force,
  8408. distanceR,
  8409. distanceXY,
  8410. bubblePadding = layout.options.bubblePadding;
  8411. layout.nodes.forEach(function (node) {
  8412. node.degree = node.mass;
  8413. node.neighbours = 0;
  8414. layout.nodes.forEach(function (repNode) {
  8415. force = 0;
  8416. if (
  8417. // Node can not repulse itself:
  8418. node !== repNode &&
  8419. // Only close nodes affect each other:
  8420. // Not dragged:
  8421. !node.fixedPosition &&
  8422. (layout.options.seriesInteraction ||
  8423. node.series === repNode.series)) {
  8424. distanceXY = layout.getDistXY(node, repNode);
  8425. distanceR = (layout.vectorLength(distanceXY) -
  8426. (node.marker.radius +
  8427. repNode.marker.radius +
  8428. bubblePadding));
  8429. // TODO padding configurable
  8430. if (distanceR < 0) {
  8431. node.degree += 0.01;
  8432. node.neighbours++;
  8433. force = layout.repulsiveForce(-distanceR / Math.sqrt(node.neighbours), layout.k, node, repNode);
  8434. }
  8435. layout.force('repulsive', node, force * repNode.mass, distanceXY, repNode, distanceR);
  8436. }
  8437. });
  8438. });
  8439. },
  8440. applyLimitBox: function (node) {
  8441. var layout = this,
  8442. distanceXY,
  8443. distanceR,
  8444. factor = 0.01;
  8445. // parentNodeLimit should be used together
  8446. // with seriesInteraction: false
  8447. if (layout.options.splitSeries &&
  8448. !node.isParentNode &&
  8449. layout.options.parentNodeLimit) {
  8450. distanceXY = layout.getDistXY(node, node.series.parentNode);
  8451. distanceR = (node.series.parentNodeRadius -
  8452. node.marker.radius -
  8453. layout.vectorLength(distanceXY));
  8454. if (distanceR < 0 &&
  8455. distanceR > -2 * node.marker.radius) {
  8456. node.plotX -= distanceXY.x * factor;
  8457. node.plotY -= distanceXY.y * factor;
  8458. }
  8459. }
  8460. Reingold.prototype.applyLimitBox.apply(this, arguments);
  8461. }
  8462. });
  8463. /**
  8464. * @private
  8465. * @class
  8466. * @name Highcharts.seriesTypes.packedbubble
  8467. *
  8468. * @extends Highcharts.Series
  8469. */
  8470. BaseSeries.seriesType('packedbubble', 'bubble',
  8471. /**
  8472. * A packed bubble series is a two dimensional series type, where each point
  8473. * renders a value in X, Y position. Each point is drawn as a bubble
  8474. * where the bubbles don't overlap with each other and the radius
  8475. * of the bubble relates to the value.
  8476. *
  8477. * @sample highcharts/demo/packed-bubble/
  8478. * Packed bubble chart
  8479. * @sample highcharts/demo/packed-bubble-split/
  8480. * Split packed bubble chart
  8481. * @extends plotOptions.bubble
  8482. * @excluding connectEnds, connectNulls, cropThreshold, dragDrop, jitter,
  8483. * keys, pointPlacement, sizeByAbsoluteValue, step, xAxis,
  8484. * yAxis, zMax, zMin, dataSorting, boostThreshold,
  8485. * boostBlending
  8486. * @product highcharts
  8487. * @since 7.0.0
  8488. * @requires highcharts-more
  8489. * @optionparent plotOptions.packedbubble
  8490. */
  8491. {
  8492. /**
  8493. * Minimum bubble size. Bubbles will automatically size between the
  8494. * `minSize` and `maxSize` to reflect the value of each bubble.
  8495. * Can be either pixels (when no unit is given), or a percentage of
  8496. * the smallest one of the plot width and height, divided by the square
  8497. * root of total number of points.
  8498. *
  8499. * @sample highcharts/plotoptions/bubble-size/
  8500. * Bubble size
  8501. *
  8502. * @type {number|string}
  8503. *
  8504. * @private
  8505. */
  8506. minSize: '10%',
  8507. /**
  8508. * Maximum bubble size. Bubbles will automatically size between the
  8509. * `minSize` and `maxSize` to reflect the value of each bubble.
  8510. * Can be either pixels (when no unit is given), or a percentage of
  8511. * the smallest one of the plot width and height, divided by the square
  8512. * root of total number of points.
  8513. *
  8514. * @sample highcharts/plotoptions/bubble-size/
  8515. * Bubble size
  8516. *
  8517. * @type {number|string}
  8518. *
  8519. * @private
  8520. */
  8521. maxSize: '50%',
  8522. sizeBy: 'area',
  8523. zoneAxis: 'y',
  8524. crisp: false,
  8525. tooltip: {
  8526. pointFormat: 'Value: {point.value}'
  8527. },
  8528. /**
  8529. * Flag to determine if nodes are draggable or not. Available for
  8530. * graph with useSimulation set to true only.
  8531. *
  8532. * @since 7.1.0
  8533. *
  8534. * @private
  8535. */
  8536. draggable: true,
  8537. /**
  8538. * An option is giving a possibility to choose between using simulation
  8539. * for calculating bubble positions. These reflects in both animation
  8540. * and final position of bubbles. Simulation is also adding options to
  8541. * the series graph based on used layout. In case of big data sets, with
  8542. * any performance issues, it is possible to disable animation and pack
  8543. * bubble in a simple circular way.
  8544. *
  8545. * @sample highcharts/series-packedbubble/spiral/
  8546. * useSimulation set to false
  8547. *
  8548. * @since 7.1.0
  8549. *
  8550. * @private
  8551. */
  8552. useSimulation: true,
  8553. /**
  8554. * Series options for parent nodes.
  8555. *
  8556. * @since 8.1.1
  8557. *
  8558. * @private
  8559. */
  8560. parentNode: {
  8561. /**
  8562. * Allow this series' parent nodes to be selected
  8563. * by clicking on the graph.
  8564. *
  8565. * @since 8.1.1
  8566. */
  8567. allowPointSelect: false
  8568. },
  8569. /**
  8570. /**
  8571. *
  8572. * @declare Highcharts.SeriesPackedBubbleDataLabelsOptionsObject
  8573. *
  8574. * @private
  8575. */
  8576. dataLabels: {
  8577. /**
  8578. * The
  8579. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  8580. * specifying what to show for _node_ in the networkgraph. In v7.0
  8581. * defaults to `{key}`, since v7.1 defaults to `undefined` and
  8582. * `formatter` is used instead.
  8583. *
  8584. * @type {string}
  8585. * @since 7.0.0
  8586. * @apioption plotOptions.packedbubble.dataLabels.format
  8587. */
  8588. // eslint-disable-next-line valid-jsdoc
  8589. /**
  8590. * Callback JavaScript function to format the data label for a node.
  8591. * Note that if a `format` is defined, the format takes precedence
  8592. * and the formatter is ignored.
  8593. *
  8594. * @type {Highcharts.SeriesPackedBubbleDataLabelsFormatterCallbackFunction}
  8595. * @since 7.0.0
  8596. */
  8597. formatter: function () {
  8598. return this.point.value;
  8599. },
  8600. /**
  8601. * @type {string}
  8602. * @since 7.1.0
  8603. * @apioption plotOptions.packedbubble.dataLabels.parentNodeFormat
  8604. */
  8605. // eslint-disable-next-line valid-jsdoc
  8606. /**
  8607. * @type {Highcharts.SeriesPackedBubbleDataLabelsFormatterCallbackFunction}
  8608. * @since 7.1.0
  8609. */
  8610. parentNodeFormatter: function () {
  8611. return this.name;
  8612. },
  8613. /**
  8614. * @sample {highcharts} highcharts/series-packedbubble/packed-dashboard
  8615. * Dashboard with dataLabels on parentNodes
  8616. *
  8617. * @declare Highcharts.SeriesPackedBubbleDataLabelsTextPathOptionsObject
  8618. * @since 7.1.0
  8619. */
  8620. parentNodeTextPath: {
  8621. /**
  8622. * Presentation attributes for the text path.
  8623. *
  8624. * @type {Highcharts.SVGAttributes}
  8625. * @since 7.1.0
  8626. * @apioption plotOptions.packedbubble.dataLabels.attributes
  8627. */
  8628. /**
  8629. * Enable or disable `textPath` option for link's or marker's
  8630. * data labels.
  8631. *
  8632. * @since 7.1.0
  8633. */
  8634. enabled: true
  8635. },
  8636. /**
  8637. * Options for a _node_ label text which should follow marker's
  8638. * shape.
  8639. *
  8640. * **Note:** Only SVG-based renderer supports this option.
  8641. *
  8642. * @extends plotOptions.series.dataLabels.textPath
  8643. * @apioption plotOptions.packedbubble.dataLabels.textPath
  8644. */
  8645. padding: 0,
  8646. style: {
  8647. transition: 'opacity 2000ms'
  8648. }
  8649. },
  8650. /**
  8651. * Options for layout algorithm when simulation is enabled. Inside there
  8652. * are options to change the speed, padding, initial bubbles positions
  8653. * and more.
  8654. *
  8655. * @extends plotOptions.networkgraph.layoutAlgorithm
  8656. * @excluding approximation, attractiveForce, repulsiveForce, theta
  8657. * @since 7.1.0
  8658. *
  8659. * @private
  8660. */
  8661. layoutAlgorithm: {
  8662. /**
  8663. * Initial layout algorithm for positioning nodes. Can be one of
  8664. * the built-in options ("circle", "random") or a function where
  8665. * positions should be set on each node (`this.nodes`) as
  8666. * `node.plotX` and `node.plotY`.
  8667. *
  8668. * @sample highcharts/series-networkgraph/initial-positions/
  8669. * Initial positions with callback
  8670. *
  8671. * @type {"circle"|"random"|Function}
  8672. */
  8673. initialPositions: 'circle',
  8674. /**
  8675. * @sample highcharts/series-packedbubble/initial-radius/
  8676. * Initial radius set to 200
  8677. *
  8678. * @extends plotOptions.networkgraph.layoutAlgorithm.initialPositionRadius
  8679. * @excluding states
  8680. */
  8681. initialPositionRadius: 20,
  8682. /**
  8683. * The distance between two bubbles, when the algorithm starts to
  8684. * treat two bubbles as overlapping. The `bubblePadding` is also the
  8685. * expected distance between all the bubbles on simulation end.
  8686. */
  8687. bubblePadding: 5,
  8688. /**
  8689. * Whether bubbles should interact with their parentNode to keep
  8690. * them inside.
  8691. */
  8692. parentNodeLimit: false,
  8693. /**
  8694. * Whether series should interact with each other or not. When
  8695. * `parentNodeLimit` is set to true, thi option should be set to
  8696. * false to avoid sticking points in wrong series parentNode.
  8697. */
  8698. seriesInteraction: true,
  8699. /**
  8700. * In case of split series, this option allows user to drag and
  8701. * drop points between series, for changing point related series.
  8702. *
  8703. * @sample highcharts/series-packedbubble/packed-dashboard/
  8704. * Example of drag'n drop bubbles for bubble kanban
  8705. */
  8706. dragBetweenSeries: false,
  8707. /**
  8708. * Layout algorithm options for parent nodes.
  8709. *
  8710. * @extends plotOptions.networkgraph.layoutAlgorithm
  8711. * @excluding approximation, attractiveForce, enableSimulation,
  8712. * repulsiveForce, theta
  8713. */
  8714. parentNodeOptions: {
  8715. maxIterations: 400,
  8716. gravitationalConstant: 0.03,
  8717. maxSpeed: 50,
  8718. initialPositionRadius: 100,
  8719. seriesInteraction: true,
  8720. /**
  8721. * Styling options for parentNodes markers. Similar to
  8722. * line.marker options.
  8723. *
  8724. * @sample highcharts/series-packedbubble/parentnode-style/
  8725. * Bubble size
  8726. *
  8727. * @extends plotOptions.series.marker
  8728. * @excluding states
  8729. */
  8730. marker: {
  8731. fillColor: null,
  8732. fillOpacity: 1,
  8733. lineWidth: 1,
  8734. lineColor: null,
  8735. symbol: 'circle'
  8736. }
  8737. },
  8738. enableSimulation: true,
  8739. /**
  8740. * Type of the algorithm used when positioning bubbles.
  8741. * @ignore-option
  8742. */
  8743. type: 'packedbubble',
  8744. /**
  8745. * Integration type. Integration determines how forces are applied
  8746. * on particles. The `packedbubble` integration is based on
  8747. * the networkgraph `verlet` integration, where the new position
  8748. * is based on a previous position without velocity:
  8749. * `newPosition += previousPosition - newPosition`.
  8750. *
  8751. * @sample highcharts/series-networkgraph/forces/
  8752. *
  8753. * @ignore-option
  8754. */
  8755. integration: 'packedbubble',
  8756. maxIterations: 1000,
  8757. /**
  8758. * Whether to split series into individual groups or to mix all
  8759. * series together.
  8760. *
  8761. * @since 7.1.0
  8762. * @default false
  8763. */
  8764. splitSeries: false,
  8765. /**
  8766. * Max speed that node can get in one iteration. In terms of
  8767. * simulation, it's a maximum translation (in pixels) that a node
  8768. * can move (in both, x and y, dimensions). While `friction` is
  8769. * applied on all nodes, max speed is applied only for nodes that
  8770. * move very fast, for example small or disconnected ones.
  8771. *
  8772. * @see [layoutAlgorithm.integration](#series.networkgraph.layoutAlgorithm.integration)
  8773. *
  8774. * @see [layoutAlgorithm.friction](#series.networkgraph.layoutAlgorithm.friction)
  8775. */
  8776. maxSpeed: 5,
  8777. gravitationalConstant: 0.01,
  8778. friction: -0.981
  8779. }
  8780. }, {
  8781. /**
  8782. * An internal option used for allowing nodes dragging.
  8783. * @private
  8784. */
  8785. hasDraggableNodes: true,
  8786. /**
  8787. * Array of internal forces. Each force should be later defined in
  8788. * integrations.js.
  8789. * @private
  8790. */
  8791. forces: ['barycenter', 'repulsive'],
  8792. pointArrayMap: ['value'],
  8793. trackerGroups: ['group', 'dataLabelsGroup', 'parentNodesGroup'],
  8794. pointValKey: 'value',
  8795. isCartesian: false,
  8796. requireSorting: false,
  8797. directTouch: true,
  8798. axisTypes: [],
  8799. noSharedTooltip: true,
  8800. // solving #12287
  8801. searchPoint: H.noop,
  8802. /* eslint-disable no-invalid-this, valid-jsdoc */
  8803. /**
  8804. * Create a single array of all points from all series
  8805. * @private
  8806. * @param {Highcharts.Series} series Array of all series objects
  8807. * @return {Array<Highcharts.PackedBubbleData>} Returns the array of all points.
  8808. */
  8809. accumulateAllPoints: function (series) {
  8810. var chart = series.chart,
  8811. allDataPoints = [],
  8812. i,
  8813. j;
  8814. for (i = 0; i < chart.series.length; i++) {
  8815. series = chart.series[i];
  8816. if (series.is('packedbubble') && // #13574
  8817. series.visible ||
  8818. !chart.options.chart.ignoreHiddenSeries) {
  8819. // add data to array only if series is visible
  8820. for (j = 0; j < series.yData.length; j++) {
  8821. allDataPoints.push([
  8822. null, null,
  8823. series.yData[j],
  8824. series.index,
  8825. j,
  8826. {
  8827. id: j,
  8828. marker: {
  8829. radius: 0
  8830. }
  8831. }
  8832. ]);
  8833. }
  8834. }
  8835. }
  8836. return allDataPoints;
  8837. },
  8838. init: function () {
  8839. Series.prototype.init.apply(this, arguments);
  8840. // When one series is modified, the others need to be recomputed
  8841. addEvent(this, 'updatedData', function () {
  8842. this.chart.series.forEach(function (s) {
  8843. if (s.type === this.type) {
  8844. s.isDirty = true;
  8845. }
  8846. }, this);
  8847. });
  8848. return this;
  8849. },
  8850. render: function () {
  8851. var series = this,
  8852. dataLabels = [];
  8853. Series.prototype.render.apply(this, arguments);
  8854. // #10823 - dataLabels should stay visible
  8855. // when enabled allowOverlap.
  8856. if (!series.options.dataLabels.allowOverlap) {
  8857. series.data.forEach(function (point) {
  8858. if (isArray(point.dataLabels)) {
  8859. point.dataLabels.forEach(function (dataLabel) {
  8860. dataLabels.push(dataLabel);
  8861. });
  8862. }
  8863. });
  8864. // Only hide overlapping dataLabels for layouts that
  8865. // use simulation. Spiral packedbubble don't need
  8866. // additional dataLabel hiding on every simulation step
  8867. if (series.options.useSimulation) {
  8868. series.chart.hideOverlappingLabels(dataLabels);
  8869. }
  8870. }
  8871. },
  8872. // Needed because of z-indexing issue if point is added in series.group
  8873. setVisible: function () {
  8874. var series = this;
  8875. Series.prototype.setVisible.apply(series, arguments);
  8876. if (series.parentNodeLayout && series.graph) {
  8877. if (series.visible) {
  8878. series.graph.show();
  8879. if (series.parentNode.dataLabel) {
  8880. series.parentNode.dataLabel.show();
  8881. }
  8882. }
  8883. else {
  8884. series.graph.hide();
  8885. series.parentNodeLayout
  8886. .removeElementFromCollection(series.parentNode, series.parentNodeLayout.nodes);
  8887. if (series.parentNode.dataLabel) {
  8888. series.parentNode.dataLabel.hide();
  8889. }
  8890. }
  8891. }
  8892. else if (series.layout) {
  8893. if (series.visible) {
  8894. series.layout.addElementsToCollection(series.points, series.layout.nodes);
  8895. }
  8896. else {
  8897. series.points.forEach(function (node) {
  8898. series.layout.removeElementFromCollection(node, series.layout.nodes);
  8899. });
  8900. }
  8901. }
  8902. },
  8903. // Packedbubble has two separate collecions of nodes if split, render
  8904. // dataLabels for both sets:
  8905. drawDataLabels: function () {
  8906. var textPath = this.options.dataLabels.textPath,
  8907. points = this.points;
  8908. // Render node labels:
  8909. Series.prototype.drawDataLabels.apply(this, arguments);
  8910. // Render parentNode labels:
  8911. if (this.parentNode) {
  8912. this.parentNode.formatPrefix = 'parentNode';
  8913. this.points = [this.parentNode];
  8914. this.options.dataLabels.textPath =
  8915. this.options.dataLabels.parentNodeTextPath;
  8916. Series.prototype.drawDataLabels.apply(this, arguments);
  8917. // Restore nodes
  8918. this.points = points;
  8919. this.options.dataLabels.textPath = textPath;
  8920. }
  8921. },
  8922. /**
  8923. * The function responsible for calculating series bubble' s bBox.
  8924. * Needed because of exporting failure when useSimulation
  8925. * is set to false
  8926. * @private
  8927. */
  8928. seriesBox: function () {
  8929. var series = this,
  8930. chart = series.chart,
  8931. data = series.data,
  8932. max = Math.max,
  8933. min = Math.min,
  8934. radius,
  8935. // bBox = [xMin, xMax, yMin, yMax]
  8936. bBox = [
  8937. chart.plotLeft,
  8938. chart.plotLeft + chart.plotWidth,
  8939. chart.plotTop,
  8940. chart.plotTop + chart.plotHeight
  8941. ];
  8942. data.forEach(function (p) {
  8943. if (defined(p.plotX) &&
  8944. defined(p.plotY) &&
  8945. p.marker.radius) {
  8946. radius = p.marker.radius;
  8947. bBox[0] = min(bBox[0], p.plotX - radius);
  8948. bBox[1] = max(bBox[1], p.plotX + radius);
  8949. bBox[2] = min(bBox[2], p.plotY - radius);
  8950. bBox[3] = max(bBox[3], p.plotY + radius);
  8951. }
  8952. });
  8953. return isNumber(bBox.width / bBox.height) ?
  8954. bBox :
  8955. null;
  8956. },
  8957. /**
  8958. * The function responsible for calculating the parent node radius
  8959. * based on the total surface of iniside-bubbles and the group BBox
  8960. * @private
  8961. */
  8962. calculateParentRadius: function () {
  8963. var series = this,
  8964. bBox,
  8965. parentPadding = 20,
  8966. minParentRadius = 20;
  8967. bBox = series.seriesBox();
  8968. series.parentNodeRadius = clamp(Math.sqrt(2 * series.parentNodeMass / Math.PI) + parentPadding, minParentRadius, bBox ?
  8969. Math.max(Math.sqrt(Math.pow(bBox.width, 2) +
  8970. Math.pow(bBox.height, 2)) / 2 + parentPadding, minParentRadius) :
  8971. Math.sqrt(2 * series.parentNodeMass / Math.PI) + parentPadding);
  8972. if (series.parentNode) {
  8973. series.parentNode.marker.radius =
  8974. series.parentNode.radius = series.parentNodeRadius;
  8975. }
  8976. },
  8977. // Create Background/Parent Nodes for split series.
  8978. drawGraph: function () {
  8979. // if the series is not using layout, don't add parent nodes
  8980. if (!this.layout || !this.layout.options.splitSeries) {
  8981. return;
  8982. }
  8983. var series = this,
  8984. chart = series.chart,
  8985. parentAttribs = {},
  8986. nodeMarker = this.layout.options.parentNodeOptions.marker,
  8987. parentOptions = {
  8988. fill: nodeMarker.fillColor || color(series.color).brighten(0.4).get(),
  8989. opacity: nodeMarker.fillOpacity,
  8990. stroke: nodeMarker.lineColor || series.color,
  8991. 'stroke-width': nodeMarker.lineWidth
  8992. },
  8993. visibility = series.visible ? 'inherit' : 'hidden';
  8994. // create the group for parent Nodes if doesn't exist
  8995. if (!this.parentNodesGroup) {
  8996. series.parentNodesGroup = series.plotGroup('parentNodesGroup', 'parentNode', visibility, 0.1, chart.seriesGroup);
  8997. series.group.attr({
  8998. zIndex: 2
  8999. });
  9000. }
  9001. this.calculateParentRadius();
  9002. parentAttribs = merge({
  9003. x: series.parentNode.plotX -
  9004. series.parentNodeRadius,
  9005. y: series.parentNode.plotY -
  9006. series.parentNodeRadius,
  9007. width: series.parentNodeRadius * 2,
  9008. height: series.parentNodeRadius * 2
  9009. }, parentOptions);
  9010. if (!series.parentNode.graphic) {
  9011. series.graph = series.parentNode.graphic =
  9012. chart.renderer.symbol(parentOptions.symbol)
  9013. .add(series.parentNodesGroup);
  9014. }
  9015. series.parentNode.graphic.attr(parentAttribs);
  9016. },
  9017. /**
  9018. * Creating parent nodes for split series, in which all the bubbles
  9019. * are rendered.
  9020. * @private
  9021. */
  9022. createParentNodes: function () {
  9023. var series = this,
  9024. chart = series.chart,
  9025. parentNodeLayout = series.parentNodeLayout,
  9026. nodeAdded,
  9027. parentNode = series.parentNode,
  9028. PackedBubblePoint = series.pointClass;
  9029. series.parentNodeMass = 0;
  9030. series.points.forEach(function (p) {
  9031. series.parentNodeMass +=
  9032. Math.PI * Math.pow(p.marker.radius, 2);
  9033. });
  9034. series.calculateParentRadius();
  9035. parentNodeLayout.nodes.forEach(function (node) {
  9036. if (node.seriesIndex === series.index) {
  9037. nodeAdded = true;
  9038. }
  9039. });
  9040. parentNodeLayout.setArea(0, 0, chart.plotWidth, chart.plotHeight);
  9041. if (!nodeAdded) {
  9042. if (!parentNode) {
  9043. parentNode = (new PackedBubblePoint()).init(this, {
  9044. mass: series.parentNodeRadius / 2,
  9045. marker: {
  9046. radius: series.parentNodeRadius
  9047. },
  9048. dataLabels: {
  9049. inside: false
  9050. },
  9051. dataLabelOnNull: true,
  9052. degree: series.parentNodeRadius,
  9053. isParentNode: true,
  9054. seriesIndex: series.index
  9055. });
  9056. }
  9057. if (series.parentNode) {
  9058. parentNode.plotX = series.parentNode.plotX;
  9059. parentNode.plotY = series.parentNode.plotY;
  9060. }
  9061. series.parentNode = parentNode;
  9062. parentNodeLayout.addElementsToCollection([series], parentNodeLayout.series);
  9063. parentNodeLayout.addElementsToCollection([parentNode], parentNodeLayout.nodes);
  9064. }
  9065. },
  9066. drawTracker: function () {
  9067. var series = this,
  9068. chart = series.chart,
  9069. pointer = chart.pointer,
  9070. onMouseOver = function (e) {
  9071. var point = pointer.getPointFromEvent(e);
  9072. // undefined on graph in scatterchart
  9073. if (typeof point !== 'undefined') {
  9074. pointer.isDirectTouch = true;
  9075. point.onMouseOver(e);
  9076. }
  9077. }, parentNode = series.parentNode;
  9078. var dataLabels;
  9079. H.TrackerMixin.drawTrackerPoint.call(this);
  9080. // Add reference to the point
  9081. if (parentNode) {
  9082. dataLabels = (isArray(parentNode.dataLabels) ?
  9083. parentNode.dataLabels :
  9084. (parentNode.dataLabel ? [parentNode.dataLabel] : []));
  9085. if (parentNode.graphic) {
  9086. parentNode.graphic.element.point = parentNode;
  9087. }
  9088. dataLabels.forEach(function (dataLabel) {
  9089. if (dataLabel.div) {
  9090. dataLabel.div.point = parentNode;
  9091. }
  9092. else {
  9093. dataLabel.element.point = parentNode;
  9094. }
  9095. });
  9096. }
  9097. },
  9098. /**
  9099. * Function responsible for adding series layout, used for parent nodes.
  9100. * @private
  9101. */
  9102. addSeriesLayout: function () {
  9103. var series = this,
  9104. layoutOptions = series.options.layoutAlgorithm,
  9105. graphLayoutsStorage = series.chart.graphLayoutsStorage,
  9106. graphLayoutsLookup = series.chart.graphLayoutsLookup,
  9107. parentNodeOptions = merge(layoutOptions,
  9108. layoutOptions.parentNodeOptions, {
  9109. enableSimulation: series.layout.options.enableSimulation
  9110. }),
  9111. parentNodeLayout;
  9112. parentNodeLayout = graphLayoutsStorage[layoutOptions.type + '-series'];
  9113. if (!parentNodeLayout) {
  9114. graphLayoutsStorage[layoutOptions.type + '-series'] =
  9115. parentNodeLayout =
  9116. new H.layouts[layoutOptions.type]();
  9117. parentNodeLayout.init(parentNodeOptions);
  9118. graphLayoutsLookup.splice(parentNodeLayout.index, 0, parentNodeLayout);
  9119. }
  9120. series.parentNodeLayout = parentNodeLayout;
  9121. this.createParentNodes();
  9122. },
  9123. /**
  9124. * Adding the basic layout to series points.
  9125. * @private
  9126. */
  9127. addLayout: function () {
  9128. var series = this,
  9129. layoutOptions = series.options.layoutAlgorithm,
  9130. graphLayoutsStorage = series.chart.graphLayoutsStorage,
  9131. graphLayoutsLookup = series.chart.graphLayoutsLookup,
  9132. chartOptions = series.chart.options.chart,
  9133. layout;
  9134. if (!graphLayoutsStorage) {
  9135. series.chart.graphLayoutsStorage = graphLayoutsStorage = {};
  9136. series.chart.graphLayoutsLookup = graphLayoutsLookup = [];
  9137. }
  9138. layout = graphLayoutsStorage[layoutOptions.type];
  9139. if (!layout) {
  9140. layoutOptions.enableSimulation =
  9141. !defined(chartOptions.forExport) ?
  9142. layoutOptions.enableSimulation :
  9143. !chartOptions.forExport;
  9144. graphLayoutsStorage[layoutOptions.type] = layout =
  9145. new H.layouts[layoutOptions.type]();
  9146. layout.init(layoutOptions);
  9147. graphLayoutsLookup.splice(layout.index, 0, layout);
  9148. }
  9149. series.layout = layout;
  9150. series.points.forEach(function (node) {
  9151. node.mass = 2;
  9152. node.degree = 1;
  9153. node.collisionNmb = 1;
  9154. });
  9155. layout.setArea(0, 0, series.chart.plotWidth, series.chart.plotHeight);
  9156. layout.addElementsToCollection([series], layout.series);
  9157. layout.addElementsToCollection(series.points, layout.nodes);
  9158. },
  9159. /**
  9160. * Function responsible for adding all the layouts to the chart.
  9161. * @private
  9162. */
  9163. deferLayout: function () {
  9164. // TODO split layouts to independent methods
  9165. var series = this,
  9166. layoutOptions = series.options.layoutAlgorithm;
  9167. if (!series.visible) {
  9168. return;
  9169. }
  9170. // layout is using nodes for position calculation
  9171. series.addLayout();
  9172. if (layoutOptions.splitSeries) {
  9173. series.addSeriesLayout();
  9174. }
  9175. },
  9176. /**
  9177. * Extend the base translate method to handle bubble size,
  9178. * and correct positioning them.
  9179. * @private
  9180. */
  9181. translate: function () {
  9182. var series = this,
  9183. chart = series.chart,
  9184. data = series.data,
  9185. index = series.index,
  9186. point,
  9187. radius,
  9188. positions,
  9189. i,
  9190. useSimulation = series.options.useSimulation;
  9191. series.processedXData = series.xData;
  9192. series.generatePoints();
  9193. // merged data is an array with all of the data from all series
  9194. if (!defined(chart.allDataPoints)) {
  9195. chart.allDataPoints = series.accumulateAllPoints(series);
  9196. // calculate radius for all added data
  9197. series.getPointRadius();
  9198. }
  9199. // after getting initial radius, calculate bubble positions
  9200. if (useSimulation) {
  9201. positions = chart.allDataPoints;
  9202. }
  9203. else {
  9204. positions = series.placeBubbles(chart.allDataPoints);
  9205. series.options.draggable = false;
  9206. }
  9207. // Set the shape and arguments to be picked up in drawPoints
  9208. for (i = 0; i < positions.length; i++) {
  9209. if (positions[i][3] === index) {
  9210. // update the series points with the val from positions
  9211. // array
  9212. point = data[positions[i][4]];
  9213. radius = positions[i][2];
  9214. if (!useSimulation) {
  9215. point.plotX = (positions[i][0] - chart.plotLeft +
  9216. chart.diffX);
  9217. point.plotY = (positions[i][1] - chart.plotTop +
  9218. chart.diffY);
  9219. }
  9220. point.marker = extend(point.marker, {
  9221. radius: radius,
  9222. width: 2 * radius,
  9223. height: 2 * radius
  9224. });
  9225. point.radius = radius;
  9226. }
  9227. }
  9228. if (useSimulation) {
  9229. series.deferLayout();
  9230. }
  9231. fireEvent(series, 'afterTranslate');
  9232. },
  9233. /**
  9234. * Check if two bubbles overlaps.
  9235. * @private
  9236. * @param {Array} first bubble
  9237. * @param {Array} second bubble
  9238. * @return {Boolean} overlap or not
  9239. */
  9240. checkOverlap: function (bubble1, bubble2) {
  9241. var diffX = bubble1[0] - bubble2[0], // diff of X center values
  9242. diffY = bubble1[1] - bubble2[1], // diff of Y center values
  9243. sumRad = bubble1[2] + bubble2[2]; // sum of bubble radius
  9244. return (Math.sqrt(diffX * diffX + diffY * diffY) -
  9245. Math.abs(sumRad)) < -0.001;
  9246. },
  9247. /**
  9248. * Function that is adding one bubble based on positions and sizes of
  9249. * two other bubbles, lastBubble is the last added bubble, newOrigin is
  9250. * the bubble for positioning new bubbles. nextBubble is the curently
  9251. * added bubble for which we are calculating positions
  9252. * @private
  9253. * @param {Array<number>} lastBubble The closest last bubble
  9254. * @param {Array<number>} newOrigin New bubble
  9255. * @param {Array<number>} nextBubble The closest next bubble
  9256. * @return {Array<number>} Bubble with correct positions
  9257. */
  9258. positionBubble: function (lastBubble, newOrigin, nextBubble) {
  9259. var sqrt = Math.sqrt,
  9260. asin = Math.asin,
  9261. acos = Math.acos,
  9262. pow = Math.pow,
  9263. abs = Math.abs,
  9264. distance = sqrt(// dist between lastBubble and newOrigin
  9265. pow((lastBubble[0] - newOrigin[0]), 2) +
  9266. pow((lastBubble[1] - newOrigin[1]), 2)),
  9267. alfa = acos(
  9268. // from cosinus theorem: alfa is an angle used for
  9269. // calculating correct position
  9270. (pow(distance, 2) +
  9271. pow(nextBubble[2] + newOrigin[2], 2) -
  9272. pow(nextBubble[2] + lastBubble[2], 2)) / (2 * (nextBubble[2] + newOrigin[2]) * distance)),
  9273. beta = asin(// from sinus theorem.
  9274. abs(lastBubble[0] - newOrigin[0]) /
  9275. distance),
  9276. // providing helping variables, related to angle between
  9277. // lastBubble and newOrigin
  9278. gamma = (lastBubble[1] - newOrigin[1]) < 0 ? 0 : Math.PI,
  9279. // if new origin y is smaller than last bubble y value
  9280. // (2 and 3 quarter),
  9281. // add Math.PI to final angle
  9282. delta = (lastBubble[0] - newOrigin[0]) *
  9283. (lastBubble[1] - newOrigin[1]) < 0 ?
  9284. 1 : -1, // (1st and 3rd quarter)
  9285. finalAngle = gamma + alfa + beta * delta,
  9286. cosA = Math.cos(finalAngle),
  9287. sinA = Math.sin(finalAngle),
  9288. posX = newOrigin[0] + (newOrigin[2] + nextBubble[2]) * sinA,
  9289. // center of new origin + (radius1 + radius2) * sinus A
  9290. posY = newOrigin[1] - (newOrigin[2] + nextBubble[2]) * cosA;
  9291. return [
  9292. posX,
  9293. posY,
  9294. nextBubble[2],
  9295. nextBubble[3],
  9296. nextBubble[4]
  9297. ]; // the same as described before
  9298. },
  9299. /**
  9300. * This is the main function responsible
  9301. * for positioning all of the bubbles
  9302. * allDataPoints - bubble array, in format [pixel x value,
  9303. * pixel y value, radius,
  9304. * related series index, related point index]
  9305. * @private
  9306. * @param {Array<Highcharts.PackedBubbleData>} allDataPoints All points from all series
  9307. * @return {Array<Highcharts.PackedBubbleData>} Positions of all bubbles
  9308. */
  9309. placeBubbles: function (allDataPoints) {
  9310. var series = this,
  9311. checkOverlap = series.checkOverlap,
  9312. positionBubble = series.positionBubble,
  9313. bubblePos = [],
  9314. stage = 1,
  9315. j = 0,
  9316. k = 0,
  9317. calculatedBubble,
  9318. sortedArr,
  9319. arr = [],
  9320. i;
  9321. // sort all points
  9322. sortedArr = allDataPoints.sort(function (a, b) {
  9323. return b[2] - a[2];
  9324. });
  9325. if (sortedArr.length) {
  9326. // create first bubble in the middle of the chart
  9327. bubblePos.push([
  9328. [
  9329. 0,
  9330. 0,
  9331. sortedArr[0][2],
  9332. sortedArr[0][3],
  9333. sortedArr[0][4]
  9334. ] // point index
  9335. ]); // 0 level bubble
  9336. if (sortedArr.length > 1) {
  9337. bubblePos.push([
  9338. [
  9339. 0,
  9340. (0 - sortedArr[1][2] -
  9341. sortedArr[0][2]),
  9342. // move bubble above first one
  9343. sortedArr[1][2],
  9344. sortedArr[1][3],
  9345. sortedArr[1][4]
  9346. ]
  9347. ]); // 1 level 1st bubble
  9348. // first two already positioned so starting from 2
  9349. for (i = 2; i < sortedArr.length; i++) {
  9350. sortedArr[i][2] = sortedArr[i][2] || 1;
  9351. // in case if radius is calculated as 0.
  9352. calculatedBubble = positionBubble(bubblePos[stage][j], bubblePos[stage - 1][k], sortedArr[i]); // calculate initial bubble position
  9353. if (checkOverlap(calculatedBubble, bubblePos[stage][0])) {
  9354. /* if new bubble is overlapping with first bubble
  9355. * in current level (stage)
  9356. */
  9357. bubblePos.push([]);
  9358. k = 0;
  9359. /* reset index of bubble, used for
  9360. * positioning the bubbles around it,
  9361. * we are starting from first bubble in next
  9362. * stage because we are changing level to higher
  9363. */
  9364. bubblePos[stage + 1].push(positionBubble(bubblePos[stage][j], bubblePos[stage][0], sortedArr[i]));
  9365. // (last bubble, 1. from curr stage, new bubble)
  9366. stage++; // the new level is created, above current
  9367. j = 0; // set the index of bubble in curr level to 0
  9368. }
  9369. else if (stage > 1 &&
  9370. bubblePos[stage - 1][k + 1] &&
  9371. checkOverlap(calculatedBubble, bubblePos[stage - 1][k + 1])) {
  9372. /* if new bubble is overlapping with one of the prev
  9373. * stage bubbles, it means that - bubble, used for
  9374. * positioning the bubbles around it has changed
  9375. * so we need to recalculate it
  9376. */
  9377. k++;
  9378. bubblePos[stage].push(positionBubble(bubblePos[stage][j], bubblePos[stage - 1][k], sortedArr[i]));
  9379. // (last bubble, prev stage bubble, new bubble)
  9380. j++;
  9381. }
  9382. else { // simply add calculated bubble
  9383. j++;
  9384. bubblePos[stage].push(calculatedBubble);
  9385. }
  9386. }
  9387. }
  9388. series.chart.stages = bubblePos;
  9389. // it may not be necessary but adding it just in case -
  9390. // it is containing all of the bubble levels
  9391. series.chart.rawPositions =
  9392. []
  9393. .concat.apply([], bubblePos);
  9394. // bubble positions merged into one array
  9395. series.resizeRadius();
  9396. arr = series.chart.rawPositions;
  9397. }
  9398. return arr;
  9399. },
  9400. /**
  9401. * The function responsible for resizing the bubble radius.
  9402. * In shortcut: it is taking the initially
  9403. * calculated positions of bubbles. Then it is calculating the min max
  9404. * of both dimensions, creating something in shape of bBox.
  9405. * The comparison of bBox and the size of plotArea
  9406. * (later it may be also the size set by customer) is giving the
  9407. * value how to recalculate the radius so it will match the size
  9408. * @private
  9409. */
  9410. resizeRadius: function () {
  9411. var chart = this.chart,
  9412. positions = chart.rawPositions,
  9413. min = Math.min,
  9414. max = Math.max,
  9415. plotLeft = chart.plotLeft,
  9416. plotTop = chart.plotTop,
  9417. chartHeight = chart.plotHeight,
  9418. chartWidth = chart.plotWidth,
  9419. minX,
  9420. maxX,
  9421. minY,
  9422. maxY,
  9423. radius,
  9424. bBox,
  9425. spaceRatio,
  9426. smallerDimension,
  9427. i;
  9428. minX = minY = Number.POSITIVE_INFINITY; // set initial values
  9429. maxX = maxY = Number.NEGATIVE_INFINITY;
  9430. for (i = 0; i < positions.length; i++) {
  9431. radius = positions[i][2];
  9432. minX = min(minX, positions[i][0] - radius);
  9433. // (x center-radius) is the min x value used by specific bubble
  9434. maxX = max(maxX, positions[i][0] + radius);
  9435. minY = min(minY, positions[i][1] - radius);
  9436. maxY = max(maxY, positions[i][1] + radius);
  9437. }
  9438. bBox = [maxX - minX, maxY - minY];
  9439. spaceRatio = [
  9440. (chartWidth - plotLeft) / bBox[0],
  9441. (chartHeight - plotTop) / bBox[1]
  9442. ];
  9443. smallerDimension = min.apply([], spaceRatio);
  9444. if (Math.abs(smallerDimension - 1) > 1e-10) {
  9445. // if bBox is considered not the same width as possible size
  9446. for (i = 0; i < positions.length; i++) {
  9447. positions[i][2] *= smallerDimension;
  9448. }
  9449. this.placeBubbles(positions);
  9450. }
  9451. else {
  9452. /** if no radius recalculation is needed, we need to position
  9453. * the whole bubbles in center of chart plotarea
  9454. * for this, we are adding two parameters,
  9455. * diffY and diffX, that are related to differences
  9456. * between the initial center and the bounding box
  9457. */
  9458. chart.diffY = chartHeight / 2 +
  9459. plotTop - minY - (maxY - minY) / 2;
  9460. chart.diffX = chartWidth / 2 +
  9461. plotLeft - minX - (maxX - minX) / 2;
  9462. }
  9463. },
  9464. /**
  9465. * Calculate min and max bubble value for radius calculation.
  9466. * @private
  9467. */
  9468. calculateZExtremes: function () {
  9469. var chart = this.chart,
  9470. zMin = this.options.zMin,
  9471. zMax = this.options.zMax,
  9472. valMin = Infinity,
  9473. valMax = -Infinity;
  9474. if (zMin && zMax) {
  9475. return [zMin, zMax];
  9476. }
  9477. // it is needed to deal with null
  9478. // and undefined values
  9479. chart.series.forEach(function (s) {
  9480. s.yData.forEach(function (p) {
  9481. if (defined(p)) {
  9482. if (p > valMax) {
  9483. valMax = p;
  9484. }
  9485. if (p < valMin) {
  9486. valMin = p;
  9487. }
  9488. }
  9489. });
  9490. });
  9491. zMin = pick(zMin, valMin);
  9492. zMax = pick(zMax, valMax);
  9493. return [zMin, zMax];
  9494. },
  9495. /**
  9496. * Calculate radius of bubbles in series.
  9497. * @private
  9498. */
  9499. getPointRadius: function () {
  9500. var series = this,
  9501. chart = series.chart,
  9502. plotWidth = chart.plotWidth,
  9503. plotHeight = chart.plotHeight,
  9504. seriesOptions = series.options,
  9505. useSimulation = seriesOptions.useSimulation,
  9506. smallestSize = Math.min(plotWidth,
  9507. plotHeight),
  9508. extremes = {},
  9509. radii = [],
  9510. allDataPoints = chart.allDataPoints,
  9511. minSize,
  9512. maxSize,
  9513. value,
  9514. radius,
  9515. zExtremes;
  9516. ['minSize', 'maxSize'].forEach(function (prop) {
  9517. var length = parseInt(seriesOptions[prop], 10),
  9518. isPercent = /%$/.test(seriesOptions[prop]);
  9519. extremes[prop] = isPercent ?
  9520. smallestSize * length / 100 :
  9521. length * Math.sqrt(allDataPoints.length);
  9522. });
  9523. chart.minRadius = minSize = extremes.minSize /
  9524. Math.sqrt(allDataPoints.length);
  9525. chart.maxRadius = maxSize = extremes.maxSize /
  9526. Math.sqrt(allDataPoints.length);
  9527. zExtremes = useSimulation ?
  9528. series.calculateZExtremes() :
  9529. [minSize, maxSize];
  9530. (allDataPoints || []).forEach(function (point, i) {
  9531. value = useSimulation ?
  9532. clamp(point[2], zExtremes[0], zExtremes[1]) :
  9533. point[2];
  9534. radius = series.getRadius(zExtremes[0], zExtremes[1], minSize, maxSize, value);
  9535. if (radius === 0) {
  9536. radius = null;
  9537. }
  9538. allDataPoints[i][2] = radius;
  9539. radii.push(radius);
  9540. });
  9541. series.radii = radii;
  9542. },
  9543. // Draggable mode:
  9544. /**
  9545. * Redraw halo on mousemove during the drag&drop action.
  9546. * @private
  9547. * @param {Highcharts.Point} point The point that should show halo.
  9548. */
  9549. redrawHalo: dragNodesMixin.redrawHalo,
  9550. /**
  9551. * Mouse down action, initializing drag&drop mode.
  9552. * @private
  9553. * @param {global.Event} event Browser event, before normalization.
  9554. * @param {Highcharts.Point} point The point that event occured.
  9555. */
  9556. onMouseDown: dragNodesMixin.onMouseDown,
  9557. /**
  9558. * Mouse move action during drag&drop.
  9559. * @private
  9560. * @param {global.Event} event Browser event, before normalization.
  9561. * @param {Highcharts.Point} point The point that event occured.
  9562. */
  9563. onMouseMove: dragNodesMixin.onMouseMove,
  9564. /**
  9565. * Mouse up action, finalizing drag&drop.
  9566. * @private
  9567. * @param {Highcharts.Point} point The point that event occured.
  9568. */
  9569. onMouseUp: function (point) {
  9570. if (point.fixedPosition && !point.removed) {
  9571. var distanceXY,
  9572. distanceR,
  9573. layout = this.layout,
  9574. parentNodeLayout = this.parentNodeLayout;
  9575. if (parentNodeLayout && layout.options.dragBetweenSeries) {
  9576. parentNodeLayout.nodes.forEach(function (node) {
  9577. if (point && point.marker &&
  9578. node !== point.series.parentNode) {
  9579. distanceXY = layout.getDistXY(point, node);
  9580. distanceR = (layout.vectorLength(distanceXY) -
  9581. node.marker.radius -
  9582. point.marker.radius);
  9583. if (distanceR < 0) {
  9584. node.series.addPoint(merge(point.options, {
  9585. plotX: point.plotX,
  9586. plotY: point.plotY
  9587. }), false);
  9588. layout.removeElementFromCollection(point, layout.nodes);
  9589. point.remove();
  9590. }
  9591. }
  9592. });
  9593. }
  9594. dragNodesMixin.onMouseUp.apply(this, arguments);
  9595. }
  9596. },
  9597. destroy: function () {
  9598. // Remove the series from all layouts series collections #11469
  9599. if (this.chart.graphLayoutsLookup) {
  9600. this.chart.graphLayoutsLookup.forEach(function (layout) {
  9601. layout.removeElementFromCollection(this, layout.series);
  9602. }, this);
  9603. }
  9604. if (this.parentNode) {
  9605. this.parentNodeLayout.removeElementFromCollection(this.parentNode, this.parentNodeLayout.nodes);
  9606. if (this.parentNode.dataLabel) {
  9607. this.parentNode.dataLabel =
  9608. this.parentNode.dataLabel.destroy();
  9609. }
  9610. }
  9611. H.Series.prototype.destroy.apply(this, arguments);
  9612. },
  9613. alignDataLabel: H.Series.prototype.alignDataLabel
  9614. }, {
  9615. /**
  9616. * Destroy point.
  9617. * Then remove point from the layout.
  9618. * @private
  9619. * @return {undefined}
  9620. */
  9621. destroy: function () {
  9622. if (this.series.layout) {
  9623. this.series.layout.removeElementFromCollection(this, this.series.layout.nodes);
  9624. }
  9625. return Point.prototype.destroy.apply(this, arguments);
  9626. },
  9627. firePointEvent: function (eventType, eventArgs, defaultFunction) {
  9628. var point = this,
  9629. series = this.series,
  9630. seriesOptions = series.options;
  9631. if (this.isParentNode && seriesOptions.parentNode) {
  9632. var temp = seriesOptions.allowPointSelect;
  9633. seriesOptions.allowPointSelect = seriesOptions.parentNode.allowPointSelect;
  9634. Point.prototype.firePointEvent.apply(this, arguments);
  9635. seriesOptions.allowPointSelect = temp;
  9636. }
  9637. else {
  9638. Point.prototype.firePointEvent.apply(this, arguments);
  9639. }
  9640. },
  9641. select: function (selected, accumulate) {
  9642. var point = this,
  9643. series = this.series,
  9644. chart = series.chart;
  9645. if (point.isParentNode) {
  9646. chart.getSelectedPoints = chart.getSelectedParentNodes;
  9647. Point.prototype.select.apply(this, arguments);
  9648. chart.getSelectedPoints = Chart.prototype.getSelectedPoints;
  9649. }
  9650. else {
  9651. Point.prototype.select.apply(this, arguments);
  9652. }
  9653. }
  9654. });
  9655. // Remove accumulated data points to redistribute all of them again
  9656. // (i.e after hiding series by legend)
  9657. addEvent(Chart, 'beforeRedraw', function () {
  9658. if (this.allDataPoints) {
  9659. delete this.allDataPoints;
  9660. }
  9661. });
  9662. /* eslint-enable no-invalid-this, valid-jsdoc */
  9663. /**
  9664. * A `packedbubble` series. If the [type](#series.packedbubble.type) option is
  9665. * not specified, it is inherited from [chart.type](#chart.type).
  9666. *
  9667. * @type {Object}
  9668. * @extends series,plotOptions.packedbubble
  9669. * @excluding cropThreshold, dataParser, dataSorting, dataURL, dragDrop, stack,
  9670. * boostThreshold, boostBlending
  9671. * @product highcharts
  9672. * @requires highcharts-more
  9673. * @apioption series.packedbubble
  9674. */
  9675. /**
  9676. * An array of data points for the series. For the `packedbubble` series type,
  9677. * points can be given in the following ways:
  9678. *
  9679. * 1. An array of `values`.
  9680. *
  9681. * ```js
  9682. * data: [5, 1, 20]
  9683. * ```
  9684. *
  9685. * 2. An array of objects with named values. The objects are point
  9686. * configuration objects as seen below. If the total number of data points
  9687. * exceeds the series' [turboThreshold](#series.packedbubble.turboThreshold),
  9688. * this option is not available.
  9689. *
  9690. * ```js
  9691. * data: [{
  9692. * value: 1,
  9693. * name: "Point2",
  9694. * color: "#00FF00"
  9695. * }, {
  9696. * value: 5,
  9697. * name: "Point1",
  9698. * color: "#FF00FF"
  9699. * }]
  9700. * ```
  9701. *
  9702. * @type {Array<Object|Array>}
  9703. * @extends series.line.data
  9704. * @excluding marker, x, y
  9705. * @sample {highcharts} highcharts/series/data-array-of-objects/
  9706. * Config objects
  9707. * @product highcharts
  9708. * @apioption series.packedbubble.data
  9709. */
  9710. /**
  9711. * @type {Highcharts.SeriesPackedBubbleDataLabelsOptionsObject|Array<Highcharts.SeriesPackedBubbleDataLabelsOptionsObject>}
  9712. * @product highcharts
  9713. * @apioption series.packedbubble.data.dataLabels
  9714. */
  9715. /**
  9716. * @excluding enabled,enabledThreshold,height,radius,width
  9717. * @product highcharts
  9718. * @apioption series.packedbubble.marker
  9719. */
  9720. ''; // adds doclets above to transpiled file
  9721. });
  9722. _registerModule(_modules, 'Extensions/Polar.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Extensions/Pane.js'], _modules['Core/Pointer.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (A, Chart, H, Pane, Pointer, SVGRenderer, U) {
  9723. /* *
  9724. *
  9725. * (c) 2010-2020 Torstein Honsi
  9726. *
  9727. * License: www.highcharts.com/license
  9728. *
  9729. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9730. *
  9731. * */
  9732. var animObject = A.animObject;
  9733. var addEvent = U.addEvent,
  9734. defined = U.defined,
  9735. find = U.find,
  9736. isNumber = U.isNumber,
  9737. pick = U.pick,
  9738. splat = U.splat,
  9739. uniqueKey = U.uniqueKey,
  9740. wrap = U.wrap;
  9741. // Extensions for polar charts. Additionally, much of the geometry required for
  9742. // polar charts is gathered in RadialAxes.js.
  9743. var Series = H.Series,
  9744. seriesTypes = H.seriesTypes,
  9745. seriesProto = Series.prototype,
  9746. pointerProto = Pointer.prototype,
  9747. colProto,
  9748. arearangeProto;
  9749. /* eslint-disable no-invalid-this, valid-jsdoc */
  9750. /**
  9751. * Search a k-d tree by the point angle, used for shared tooltips in polar
  9752. * charts
  9753. * @private
  9754. */
  9755. seriesProto.searchPointByAngle = function (e) {
  9756. var series = this,
  9757. chart = series.chart,
  9758. xAxis = series.xAxis,
  9759. center = xAxis.pane.center,
  9760. plotX = e.chartX - center[0] - chart.plotLeft,
  9761. plotY = e.chartY - center[1] - chart.plotTop;
  9762. return this.searchKDTree({
  9763. clientX: 180 + (Math.atan2(plotX, plotY) * (-180 / Math.PI))
  9764. });
  9765. };
  9766. /**
  9767. * #6212 Calculate connectors for spline series in polar chart.
  9768. * @private
  9769. * @param {boolean} calculateNeighbours
  9770. * Check if connectors should be calculated for neighbour points as
  9771. * well allows short recurence
  9772. */
  9773. seriesProto.getConnectors = function (segment, index, calculateNeighbours, connectEnds) {
  9774. var i,
  9775. prevPointInd,
  9776. nextPointInd,
  9777. previousPoint,
  9778. nextPoint,
  9779. previousX,
  9780. previousY,
  9781. nextX,
  9782. nextY,
  9783. plotX,
  9784. plotY,
  9785. ret,
  9786. // 1 means control points midway between points, 2 means 1/3 from
  9787. // the point, 3 is 1/4 etc;
  9788. smoothing = 1.5, denom = smoothing + 1, leftContX, leftContY, rightContX, rightContY, dLControlPoint, // distance left control point
  9789. dRControlPoint, leftContAngle, rightContAngle, jointAngle, addedNumber = connectEnds ? 1 : 0;
  9790. // Calculate final index of points depending on the initial index value.
  9791. // Because of calculating neighbours, index may be outisde segment
  9792. // array.
  9793. if (index >= 0 && index <= segment.length - 1) {
  9794. i = index;
  9795. }
  9796. else if (index < 0) {
  9797. i = segment.length - 1 + index;
  9798. }
  9799. else {
  9800. i = 0;
  9801. }
  9802. prevPointInd = (i - 1 < 0) ? segment.length - (1 + addedNumber) : i - 1;
  9803. nextPointInd = (i + 1 > segment.length - 1) ? addedNumber : i + 1;
  9804. previousPoint = segment[prevPointInd];
  9805. nextPoint = segment[nextPointInd];
  9806. previousX = previousPoint.plotX;
  9807. previousY = previousPoint.plotY;
  9808. nextX = nextPoint.plotX;
  9809. nextY = nextPoint.plotY;
  9810. plotX = segment[i].plotX; // actual point
  9811. plotY = segment[i].plotY;
  9812. leftContX = (smoothing * plotX + previousX) / denom;
  9813. leftContY = (smoothing * plotY + previousY) / denom;
  9814. rightContX = (smoothing * plotX + nextX) / denom;
  9815. rightContY = (smoothing * plotY + nextY) / denom;
  9816. dLControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
  9817. dRControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
  9818. leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX);
  9819. rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX);
  9820. jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2);
  9821. // Ensure the right direction, jointAngle should be in the same quadrant
  9822. // as leftContAngle
  9823. if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) {
  9824. jointAngle -= Math.PI;
  9825. }
  9826. // Find the corrected control points for a spline straight through the
  9827. // point
  9828. leftContX = plotX + Math.cos(jointAngle) * dLControlPoint;
  9829. leftContY = plotY + Math.sin(jointAngle) * dLControlPoint;
  9830. rightContX = plotX + Math.cos(Math.PI + jointAngle) * dRControlPoint;
  9831. rightContY = plotY + Math.sin(Math.PI + jointAngle) * dRControlPoint;
  9832. // push current point's connectors into returned object
  9833. ret = {
  9834. rightContX: rightContX,
  9835. rightContY: rightContY,
  9836. leftContX: leftContX,
  9837. leftContY: leftContY,
  9838. plotX: plotX,
  9839. plotY: plotY
  9840. };
  9841. // calculate connectors for previous and next point and push them inside
  9842. // returned object
  9843. if (calculateNeighbours) {
  9844. ret.prevPointCont = this.getConnectors(segment, prevPointInd, false, connectEnds);
  9845. }
  9846. return ret;
  9847. };
  9848. /**
  9849. * Translate a point's plotX and plotY from the internal angle and radius
  9850. * measures to true plotX, plotY coordinates
  9851. * @private
  9852. */
  9853. seriesProto.toXY = function (point) {
  9854. var xy,
  9855. chart = this.chart,
  9856. xAxis = this.xAxis,
  9857. yAxis = this.yAxis,
  9858. plotX = point.plotX,
  9859. plotY = point.plotY,
  9860. series = point.series,
  9861. inverted = chart.inverted,
  9862. pointY = point.y,
  9863. radius = inverted ? plotX : yAxis.len - plotY,
  9864. clientX;
  9865. // Corrected y position of inverted series other than column
  9866. if (inverted && series && !series.isRadialBar) {
  9867. point.plotY = plotY =
  9868. typeof pointY === 'number' ? (yAxis.translate(pointY) || 0) : 0;
  9869. }
  9870. // Save rectangular plotX, plotY for later computation
  9871. point.rectPlotX = plotX;
  9872. point.rectPlotY = plotY;
  9873. if (yAxis.center) {
  9874. radius += yAxis.center[3] / 2;
  9875. }
  9876. // Find the polar plotX and plotY
  9877. xy = inverted ? yAxis.postTranslate(plotY, radius) :
  9878. xAxis.postTranslate(plotX, radius);
  9879. point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
  9880. point.plotY = point.polarPlotY = xy.y - chart.plotTop;
  9881. // If shared tooltip, record the angle in degrees in order to align X
  9882. // points. Otherwise, use a standard k-d tree to get the nearest point
  9883. // in two dimensions.
  9884. if (this.kdByAngle) {
  9885. clientX = ((plotX / Math.PI * 180) +
  9886. xAxis.pane.options.startAngle) % 360;
  9887. if (clientX < 0) { // #2665
  9888. clientX += 360;
  9889. }
  9890. point.clientX = clientX;
  9891. }
  9892. else {
  9893. point.clientX = point.plotX;
  9894. }
  9895. };
  9896. if (seriesTypes.spline) {
  9897. /**
  9898. * Overridden method for calculating a spline from one point to the next
  9899. * @private
  9900. */
  9901. wrap(seriesTypes.spline.prototype, 'getPointSpline', function (proceed, segment, point, i) {
  9902. var ret,
  9903. connectors;
  9904. if (this.chart.polar) {
  9905. // moveTo or lineTo
  9906. if (!i) {
  9907. ret = ['M', point.plotX, point.plotY];
  9908. }
  9909. else { // curve from last point to this
  9910. connectors = this.getConnectors(segment, i, true, this.connectEnds);
  9911. ret = [
  9912. 'C',
  9913. connectors.prevPointCont.rightContX,
  9914. connectors.prevPointCont.rightContY,
  9915. connectors.leftContX,
  9916. connectors.leftContY,
  9917. connectors.plotX,
  9918. connectors.plotY
  9919. ];
  9920. }
  9921. }
  9922. else {
  9923. ret = proceed.call(this, segment, point, i);
  9924. }
  9925. return ret;
  9926. });
  9927. // #6430 Areasplinerange series use unwrapped getPointSpline method, so
  9928. // we need to set this method again.
  9929. if (seriesTypes.areasplinerange) {
  9930. seriesTypes.areasplinerange.prototype.getPointSpline =
  9931. seriesTypes.spline.prototype.getPointSpline;
  9932. }
  9933. }
  9934. /**
  9935. * Extend translate. The plotX and plotY values are computed as if the polar
  9936. * chart were a cartesian plane, where plotX denotes the angle in radians
  9937. * and (yAxis.len - plotY) is the pixel distance from center.
  9938. * @private
  9939. */
  9940. addEvent(Series, 'afterTranslate', function () {
  9941. var series = this;
  9942. var chart = series.chart;
  9943. if (chart.polar && series.xAxis) {
  9944. // Prepare k-d-tree handling. It searches by angle (clientX) in
  9945. // case of shared tooltip, and by two dimensional distance in case
  9946. // of non-shared.
  9947. series.kdByAngle = chart.tooltip && chart.tooltip.shared;
  9948. if (series.kdByAngle) {
  9949. series.searchPoint = series.searchPointByAngle;
  9950. }
  9951. else {
  9952. series.options.findNearestPointBy = 'xy';
  9953. }
  9954. // Postprocess plot coordinates
  9955. if (!series.preventPostTranslate) {
  9956. var points = series.points;
  9957. var i = points.length;
  9958. while (i--) {
  9959. // Translate plotX, plotY from angle and radius to true plot
  9960. // coordinates
  9961. series.toXY(points[i]);
  9962. // Treat points below Y axis min as null (#10082)
  9963. if (!chart.hasParallelCoordinates &&
  9964. !series.yAxis.reversed &&
  9965. points[i].y < series.yAxis.min) {
  9966. points[i].isNull = true;
  9967. }
  9968. }
  9969. }
  9970. // Perform clip after render
  9971. if (!this.hasClipCircleSetter) {
  9972. this.hasClipCircleSetter = !!series.eventsToUnbind.push(addEvent(series, 'afterRender', function () {
  9973. var circ;
  9974. if (chart.polar) {
  9975. // For clipping purposes there is a need for
  9976. // coordinates from the absolute center
  9977. circ = this.yAxis.pane.center;
  9978. if (!this.clipCircle) {
  9979. this.clipCircle = chart.renderer.clipCircle(circ[0], circ[1], circ[2] / 2, circ[3] / 2);
  9980. }
  9981. else {
  9982. this.clipCircle.animate({
  9983. x: circ[0],
  9984. y: circ[1],
  9985. r: circ[2] / 2,
  9986. innerR: circ[3] / 2
  9987. });
  9988. }
  9989. this.group.clip(this.clipCircle);
  9990. this.setClip = H.noop;
  9991. }
  9992. }));
  9993. }
  9994. }
  9995. }, { order: 2 }); // Run after translation of ||-coords
  9996. /**
  9997. * Extend getSegmentPath to allow connecting ends across 0 to provide a
  9998. * closed circle in line-like series.
  9999. * @private
  10000. */
  10001. wrap(seriesProto, 'getGraphPath', function (proceed, points) {
  10002. var series = this,
  10003. i,
  10004. firstValid,
  10005. popLastPoint;
  10006. // Connect the path
  10007. if (this.chart.polar) {
  10008. points = points || this.points;
  10009. // Append first valid point in order to connect the ends
  10010. for (i = 0; i < points.length; i++) {
  10011. if (!points[i].isNull) {
  10012. firstValid = i;
  10013. break;
  10014. }
  10015. }
  10016. /**
  10017. * Polar charts only. Whether to connect the ends of a line series
  10018. * plot across the extremes.
  10019. *
  10020. * @sample {highcharts} highcharts/plotoptions/line-connectends-false/
  10021. * Do not connect
  10022. *
  10023. * @type {boolean}
  10024. * @since 2.3.0
  10025. * @product highcharts
  10026. * @apioption plotOptions.series.connectEnds
  10027. */
  10028. if (this.options.connectEnds !== false &&
  10029. typeof firstValid !== 'undefined') {
  10030. this.connectEnds = true; // re-used in splines
  10031. points.splice(points.length, 0, points[firstValid]);
  10032. popLastPoint = true;
  10033. }
  10034. // For area charts, pseudo points are added to the graph, now we
  10035. // need to translate these
  10036. points.forEach(function (point) {
  10037. if (typeof point.polarPlotY === 'undefined') {
  10038. series.toXY(point);
  10039. }
  10040. });
  10041. }
  10042. // Run uber method
  10043. var ret = proceed.apply(this,
  10044. [].slice.call(arguments, 1));
  10045. // #6212 points.splice method is adding points to an array. In case of
  10046. // areaspline getGraphPath method is used two times and in both times
  10047. // points are added to an array. That is why points.pop is used, to get
  10048. // unmodified points.
  10049. if (popLastPoint) {
  10050. points.pop();
  10051. }
  10052. return ret;
  10053. });
  10054. var polarAnimate = function (proceed,
  10055. init) {
  10056. var series = this,
  10057. chart = this.chart,
  10058. animation = this.options.animation,
  10059. group = this.group,
  10060. markerGroup = this.markerGroup,
  10061. center = this.xAxis.center,
  10062. plotLeft = chart.plotLeft,
  10063. plotTop = chart.plotTop,
  10064. attribs,
  10065. paneInnerR,
  10066. graphic,
  10067. shapeArgs,
  10068. r,
  10069. innerR;
  10070. // Specific animation for polar charts
  10071. if (chart.polar) {
  10072. if (series.isRadialBar) {
  10073. if (!init) {
  10074. // Run the pie animation for radial bars
  10075. series.startAngleRad = pick(series.translatedThreshold, series.xAxis.startAngleRad);
  10076. H.seriesTypes.pie.prototype.animate.call(series, init);
  10077. }
  10078. }
  10079. else {
  10080. // Enable animation on polar charts only in SVG. In VML, the scaling
  10081. // is different, plus animation would be so slow it would't matter.
  10082. if (chart.renderer.isSVG) {
  10083. animation = animObject(animation);
  10084. // A different animation needed for column like series
  10085. if (series.is('column')) {
  10086. if (!init) {
  10087. paneInnerR = center[3] / 2;
  10088. series.points.forEach(function (point) {
  10089. graphic = point.graphic;
  10090. shapeArgs = point.shapeArgs;
  10091. r = shapeArgs && shapeArgs.r;
  10092. innerR = shapeArgs && shapeArgs.innerR;
  10093. if (graphic && shapeArgs) {
  10094. // start values
  10095. graphic.attr({
  10096. r: paneInnerR,
  10097. innerR: paneInnerR
  10098. });
  10099. // animate
  10100. graphic.animate({
  10101. r: r,
  10102. innerR: innerR
  10103. }, series.options.animation);
  10104. }
  10105. });
  10106. }
  10107. }
  10108. else {
  10109. // Initialize the animation
  10110. if (init) {
  10111. // Scale down the group and place it in the center
  10112. attribs = {
  10113. translateX: center[0] + plotLeft,
  10114. translateY: center[1] + plotTop,
  10115. scaleX: 0.001,
  10116. scaleY: 0.001
  10117. };
  10118. group.attr(attribs);
  10119. if (markerGroup) {
  10120. markerGroup.attr(attribs);
  10121. }
  10122. // Run the animation
  10123. }
  10124. else {
  10125. attribs = {
  10126. translateX: plotLeft,
  10127. translateY: plotTop,
  10128. scaleX: 1,
  10129. scaleY: 1
  10130. };
  10131. group.animate(attribs, animation);
  10132. if (markerGroup) {
  10133. markerGroup.animate(attribs, animation);
  10134. }
  10135. }
  10136. }
  10137. }
  10138. }
  10139. // For non-polar charts, revert to the basic animation
  10140. }
  10141. else {
  10142. proceed.call(this, init);
  10143. }
  10144. };
  10145. // Define the animate method for regular series
  10146. wrap(seriesProto, 'animate', polarAnimate);
  10147. if (seriesTypes.column) {
  10148. arearangeProto = seriesTypes.arearange.prototype;
  10149. colProto = seriesTypes.column.prototype;
  10150. colProto.polarArc = function (low, high, start, end) {
  10151. var center = this.xAxis.center,
  10152. len = this.yAxis.len,
  10153. paneInnerR = center[3] / 2,
  10154. r = len - high + paneInnerR,
  10155. innerR = len - pick(low,
  10156. len) + paneInnerR;
  10157. // Prevent columns from shooting through the pane's center
  10158. if (this.yAxis.reversed) {
  10159. if (r < 0) {
  10160. r = paneInnerR;
  10161. }
  10162. if (innerR < 0) {
  10163. innerR = paneInnerR;
  10164. }
  10165. }
  10166. // Return a new shapeArgs
  10167. return {
  10168. x: center[0],
  10169. y: center[1],
  10170. r: r,
  10171. innerR: innerR,
  10172. start: start,
  10173. end: end
  10174. };
  10175. };
  10176. /**
  10177. * Define the animate method for columnseries
  10178. * @private
  10179. */
  10180. wrap(colProto, 'animate', polarAnimate);
  10181. /**
  10182. * Extend the column prototype's translate method
  10183. * @private
  10184. */
  10185. wrap(colProto, 'translate', function (proceed) {
  10186. var series = this,
  10187. options = series.options,
  10188. threshold = options.threshold,
  10189. stacking = options.stacking,
  10190. chart = series.chart,
  10191. xAxis = series.xAxis,
  10192. yAxis = series.yAxis,
  10193. reversed = yAxis.reversed,
  10194. center = yAxis.center,
  10195. startAngleRad = xAxis.startAngleRad,
  10196. endAngleRad = xAxis.endAngleRad,
  10197. visibleRange = endAngleRad - startAngleRad,
  10198. thresholdAngleRad,
  10199. points,
  10200. point,
  10201. i,
  10202. yMin,
  10203. yMax,
  10204. start,
  10205. end,
  10206. tooltipPos,
  10207. pointX,
  10208. pointY,
  10209. stackValues,
  10210. stack,
  10211. barX,
  10212. innerR,
  10213. r;
  10214. series.preventPostTranslate = true;
  10215. // Run uber method
  10216. proceed.call(series);
  10217. // Postprocess plot coordinates
  10218. if (xAxis.isRadial) {
  10219. points = series.points;
  10220. i = points.length;
  10221. yMin = yAxis.translate(yAxis.min);
  10222. yMax = yAxis.translate(yAxis.max);
  10223. threshold = options.threshold || 0;
  10224. if (chart.inverted) {
  10225. // Finding a correct threshold
  10226. if (isNumber(threshold)) {
  10227. thresholdAngleRad = yAxis.translate(threshold);
  10228. // Checks if threshold is outside the visible range
  10229. if (defined(thresholdAngleRad)) {
  10230. if (thresholdAngleRad < 0) {
  10231. thresholdAngleRad = 0;
  10232. }
  10233. else if (thresholdAngleRad > visibleRange) {
  10234. thresholdAngleRad = visibleRange;
  10235. }
  10236. // Adding start angle offset
  10237. series.translatedThreshold =
  10238. thresholdAngleRad + startAngleRad;
  10239. }
  10240. }
  10241. }
  10242. while (i--) {
  10243. point = points[i];
  10244. barX = point.barX;
  10245. pointX = point.x;
  10246. pointY = point.y;
  10247. point.shapeType = 'arc';
  10248. if (chart.inverted) {
  10249. point.plotY = yAxis.translate(pointY);
  10250. if (stacking && yAxis.stacking) {
  10251. stack = yAxis.stacking.stacks[(pointY < 0 ? '-' : '') +
  10252. series.stackKey];
  10253. if (series.visible && stack && stack[pointX]) {
  10254. if (!point.isNull) {
  10255. stackValues = stack[pointX].points[series.getStackIndicator(void 0, pointX, series.index).key];
  10256. // Translating to radial values
  10257. start = yAxis.translate(stackValues[0]);
  10258. end = yAxis.translate(stackValues[1]);
  10259. // If starting point is beyond the
  10260. // range, set it to 0
  10261. if (defined(start)) {
  10262. start = U.clamp(start, 0, visibleRange);
  10263. }
  10264. }
  10265. }
  10266. }
  10267. else {
  10268. // Initial start and end angles for radial bar
  10269. start = thresholdAngleRad;
  10270. end = point.plotY;
  10271. }
  10272. if (start > end) {
  10273. // Swapping start and end
  10274. end = [start, start = end][0];
  10275. }
  10276. // Prevent from rendering point outside the
  10277. // acceptable circular range
  10278. if (!reversed) {
  10279. if (start < yMin) {
  10280. start = yMin;
  10281. }
  10282. else if (end > yMax) {
  10283. end = yMax;
  10284. }
  10285. else if (end < yMin || start > yMax) {
  10286. start = end = 0;
  10287. }
  10288. }
  10289. else {
  10290. if (end > yMin) {
  10291. end = yMin;
  10292. }
  10293. else if (start < yMax) {
  10294. start = yMax;
  10295. }
  10296. else if (start > yMin || end < yMax) {
  10297. start = end = visibleRange;
  10298. }
  10299. }
  10300. if (yAxis.min > yAxis.max) {
  10301. start = end = reversed ? visibleRange : 0;
  10302. }
  10303. start += startAngleRad;
  10304. end += startAngleRad;
  10305. if (center) {
  10306. point.barX = barX += center[3] / 2;
  10307. }
  10308. // In case when radius, inner radius or both are
  10309. // negative, a point is rendered but partially or as
  10310. // a center point
  10311. innerR = Math.max(barX, 0);
  10312. r = Math.max(barX + point.pointWidth, 0);
  10313. point.shapeArgs = {
  10314. x: center && center[0],
  10315. y: center && center[1],
  10316. r: r,
  10317. innerR: innerR,
  10318. start: start,
  10319. end: end
  10320. };
  10321. // Fade out the points if not inside the polar "plot area"
  10322. point.opacity = start === end ? 0 : void 0;
  10323. // A correct value for stacked or not fully visible
  10324. // point
  10325. point.plotY = (defined(series.translatedThreshold) &&
  10326. (start < series.translatedThreshold ? start : end)) -
  10327. startAngleRad;
  10328. }
  10329. else {
  10330. start = barX + startAngleRad;
  10331. // Changed the way polar columns are drawn in order to make
  10332. // it more consistent with the drawing of inverted columns
  10333. // (they are using the same function now). Also, it was
  10334. // essential to make the animation work correctly (the
  10335. // scaling of the group) is replaced by animating each
  10336. // element separately.
  10337. point.shapeArgs = series.polarArc(point.yBottom, point.plotY, start, start + point.pointWidth);
  10338. }
  10339. // Provided a correct coordinates for the tooltip
  10340. series.toXY(point);
  10341. if (chart.inverted) {
  10342. tooltipPos = yAxis.postTranslate(point.rectPlotY, barX + point.pointWidth / 2);
  10343. point.tooltipPos = [
  10344. tooltipPos.x - chart.plotLeft,
  10345. tooltipPos.y - chart.plotTop
  10346. ];
  10347. }
  10348. else {
  10349. point.tooltipPos = [point.plotX, point.plotY];
  10350. }
  10351. if (center) {
  10352. point.ttBelow = point.plotY > center[1];
  10353. }
  10354. }
  10355. }
  10356. });
  10357. /**
  10358. * Find correct align and vertical align based on an angle in polar chart
  10359. * @private
  10360. */
  10361. colProto.findAlignments = function (angle, options) {
  10362. var align,
  10363. verticalAlign;
  10364. if (options.align === null) {
  10365. if (angle > 20 && angle < 160) {
  10366. align = 'left'; // right hemisphere
  10367. }
  10368. else if (angle > 200 && angle < 340) {
  10369. align = 'right'; // left hemisphere
  10370. }
  10371. else {
  10372. align = 'center'; // top or bottom
  10373. }
  10374. options.align = align;
  10375. }
  10376. if (options.verticalAlign === null) {
  10377. if (angle < 45 || angle > 315) {
  10378. verticalAlign = 'bottom'; // top part
  10379. }
  10380. else if (angle > 135 && angle < 225) {
  10381. verticalAlign = 'top'; // bottom part
  10382. }
  10383. else {
  10384. verticalAlign = 'middle'; // left or right
  10385. }
  10386. options.verticalAlign = verticalAlign;
  10387. }
  10388. return options;
  10389. };
  10390. if (arearangeProto) {
  10391. arearangeProto.findAlignments = colProto.findAlignments;
  10392. }
  10393. /**
  10394. * Align column data labels outside the columns. #1199.
  10395. * @private
  10396. */
  10397. wrap(colProto, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo, isNew) {
  10398. var chart = this.chart,
  10399. inside = pick(options.inside, !!this.options.stacking),
  10400. angle,
  10401. shapeArgs,
  10402. labelPos;
  10403. if (chart.polar) {
  10404. angle = point.rectPlotX / Math.PI * 180;
  10405. if (!chart.inverted) {
  10406. // Align nicely outside the perimeter of the columns
  10407. if (this.findAlignments) {
  10408. options = this.findAlignments(angle, options);
  10409. }
  10410. }
  10411. else { // Required corrections for data labels of inverted bars
  10412. // The plotX and plotY are correctly set therefore they
  10413. // don't need to be swapped (inverted argument is false)
  10414. this.forceDL = chart.isInsidePlot(point.plotX, Math.round(point.plotY), false);
  10415. // Checks if labels should be positioned inside
  10416. if (inside && point.shapeArgs) {
  10417. shapeArgs = point.shapeArgs;
  10418. // Calculates pixel positions for a data label to be
  10419. // inside
  10420. labelPos =
  10421. this.yAxis.postTranslate(
  10422. // angle
  10423. (shapeArgs.start + shapeArgs.end) / 2 -
  10424. this
  10425. .xAxis.startAngleRad,
  10426. // radius
  10427. point.barX +
  10428. point.pointWidth / 2);
  10429. alignTo = {
  10430. x: labelPos.x - chart.plotLeft,
  10431. y: labelPos.y - chart.plotTop
  10432. };
  10433. }
  10434. else if (point.tooltipPos) {
  10435. alignTo = {
  10436. x: point.tooltipPos[0],
  10437. y: point.tooltipPos[1]
  10438. };
  10439. }
  10440. options.align = pick(options.align, 'center');
  10441. options.verticalAlign =
  10442. pick(options.verticalAlign, 'middle');
  10443. }
  10444. seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  10445. // Hide label of a point (only inverted) that is outside the
  10446. // visible y range
  10447. if (this.isRadialBar && point.shapeArgs &&
  10448. point.shapeArgs.start === point.shapeArgs.end) {
  10449. dataLabel.hide(true);
  10450. }
  10451. }
  10452. else {
  10453. proceed.call(this, point, dataLabel, options, alignTo, isNew);
  10454. }
  10455. });
  10456. }
  10457. /**
  10458. * Extend getCoordinates to prepare for polar axis values
  10459. * @private
  10460. */
  10461. wrap(pointerProto, 'getCoordinates', function (proceed, e) {
  10462. var chart = this.chart,
  10463. ret = {
  10464. xAxis: [],
  10465. yAxis: []
  10466. };
  10467. if (chart.polar) {
  10468. chart.axes.forEach(function (axis) {
  10469. var isXAxis = axis.isXAxis,
  10470. center = axis.center,
  10471. x,
  10472. y;
  10473. // Skip colorAxis
  10474. if (axis.coll === 'colorAxis') {
  10475. return;
  10476. }
  10477. x = e.chartX - center[0] - chart.plotLeft;
  10478. y = e.chartY - center[1] - chart.plotTop;
  10479. ret[isXAxis ? 'xAxis' : 'yAxis'].push({
  10480. axis: axis,
  10481. value: axis.translate(isXAxis ?
  10482. Math.PI - Math.atan2(x, y) : // angle
  10483. // distance from center
  10484. Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), true)
  10485. });
  10486. });
  10487. }
  10488. else {
  10489. ret = proceed.call(this, e);
  10490. }
  10491. return ret;
  10492. });
  10493. SVGRenderer.prototype.clipCircle = function (x, y, r, innerR) {
  10494. var wrapper,
  10495. id = uniqueKey(),
  10496. clipPath = this.createElement('clipPath').attr({
  10497. id: id
  10498. }).add(this.defs);
  10499. wrapper = innerR ?
  10500. this.arc(x, y, r, innerR, 0, 2 * Math.PI).add(clipPath) :
  10501. this.circle(x, y, r).add(clipPath);
  10502. wrapper.id = id;
  10503. wrapper.clipPath = clipPath;
  10504. return wrapper;
  10505. };
  10506. addEvent(Chart, 'getAxes', function () {
  10507. if (!this.pane) {
  10508. this.pane = [];
  10509. }
  10510. splat(this.options.pane).forEach(function (paneOptions) {
  10511. new Pane(// eslint-disable-line no-new
  10512. paneOptions, this);
  10513. }, this);
  10514. });
  10515. addEvent(Chart, 'afterDrawChartBox', function () {
  10516. this.pane.forEach(function (pane) {
  10517. pane.render();
  10518. });
  10519. });
  10520. addEvent(H.Series, 'afterInit', function () {
  10521. var chart = this.chart;
  10522. // Add flags that identifies radial inverted series
  10523. if (chart.inverted && chart.polar) {
  10524. this.isRadialSeries = true;
  10525. if (this.is('column')) {
  10526. this.isRadialBar = true;
  10527. }
  10528. }
  10529. });
  10530. /**
  10531. * Extend chart.get to also search in panes. Used internally in
  10532. * responsiveness and chart.update.
  10533. * @private
  10534. */
  10535. wrap(Chart.prototype, 'get', function (proceed, id) {
  10536. return find(this.pane, function (pane) {
  10537. return pane.options.id === id;
  10538. }) || proceed.call(this, id);
  10539. });
  10540. });
  10541. _registerModule(_modules, 'masters/highcharts-more.src.js', [], function () {
  10542. });
  10543. }));