highcharts-more.src.js 452 KB

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