highcharts-3d.src.js 225 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330
  1. /**
  2. * @license Highcharts JS v9.1.0 (2021-05-04)
  3. *
  4. * 3D features for Highcharts JS
  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-3d', ['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/Math3D.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  30. /* *
  31. *
  32. * (c) 2010-2021 Torstein Honsi
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var pick = U.pick;
  40. // Mathematical Functionility
  41. var deg2rad = H.deg2rad;
  42. /* eslint-disable max-len */
  43. /**
  44. * Apply 3-D rotation
  45. * Euler Angles (XYZ):
  46. * cosA = cos(Alfa|Roll)
  47. * cosB = cos(Beta|Pitch)
  48. * cosG = cos(Gamma|Yaw)
  49. *
  50. * Composite rotation:
  51. * | cosB * cosG | cosB * sinG | -sinB |
  52. * | sinA * sinB * cosG - cosA * sinG | sinA * sinB * sinG + cosA * cosG | sinA * cosB |
  53. * | cosA * sinB * cosG + sinA * sinG | cosA * sinB * sinG - sinA * cosG | cosA * cosB |
  54. *
  55. * Now, Gamma/Yaw is not used (angle=0), so we assume cosG = 1 and sinG = 0, so
  56. * we get:
  57. * | cosB | 0 | - sinB |
  58. * | sinA * sinB | cosA | sinA * cosB |
  59. * | cosA * sinB | - sinA | cosA * cosB |
  60. *
  61. * But in browsers, y is reversed, so we get sinA => -sinA. The general result
  62. * is:
  63. * | cosB | 0 | - sinB | | x | | px |
  64. * | - sinA * sinB | cosA | - sinA * cosB | x | y | = | py |
  65. * | cosA * sinB | sinA | cosA * cosB | | z | | pz |
  66. *
  67. * @private
  68. * @function rotate3D
  69. */
  70. /* eslint-enable max-len */
  71. /**
  72. * @private
  73. * @param {number} x
  74. * X coordinate
  75. * @param {number} y
  76. * Y coordinate
  77. * @param {number} z
  78. * Z coordinate
  79. * @param {Highcharts.Rotation3dObject} angles
  80. * Rotation angles
  81. * @return {Highcharts.Rotation3dObject}
  82. * Rotated position
  83. */
  84. function rotate3D(x, y, z, angles) {
  85. return {
  86. x: angles.cosB * x - angles.sinB * z,
  87. y: -angles.sinA * angles.sinB * x + angles.cosA * y -
  88. angles.cosB * angles.sinA * z,
  89. z: angles.cosA * angles.sinB * x + angles.sinA * y +
  90. angles.cosA * angles.cosB * z
  91. };
  92. }
  93. /**
  94. * Perspective3D function is available in global Highcharts scope because is
  95. * needed also outside of perspective() function (#8042).
  96. * @private
  97. * @function Highcharts.perspective3D
  98. *
  99. * @param {Highcharts.Position3DObject} coordinate
  100. * 3D position
  101. *
  102. * @param {Highcharts.Position3DObject} origin
  103. * 3D root position
  104. *
  105. * @param {number} distance
  106. * Perspective distance
  107. *
  108. * @return {Highcharts.PositionObject}
  109. * Perspective 3D Position
  110. *
  111. * @requires highcharts-3d
  112. */
  113. function perspective3D(coordinate, origin, distance) {
  114. var projection = ((distance > 0) && (distance < Number.POSITIVE_INFINITY)) ?
  115. distance / (coordinate.z + origin.z + distance) :
  116. 1;
  117. return {
  118. x: coordinate.x * projection,
  119. y: coordinate.y * projection
  120. };
  121. }
  122. H.perspective3D = perspective3D;
  123. /**
  124. * Transforms a given array of points according to the angles in chart.options.
  125. *
  126. * @private
  127. * @function Highcharts.perspective
  128. *
  129. * @param {Array<Highcharts.Position3DObject>} points
  130. * The array of points
  131. *
  132. * @param {Highcharts.Chart} chart
  133. * The chart
  134. *
  135. * @param {boolean} [insidePlotArea]
  136. * Whether to verify that the points are inside the plotArea
  137. *
  138. * @param {boolean} [useInvertedPersp]
  139. * Whether to use inverted perspective in calculations
  140. *
  141. * @return {Array<Highcharts.Position3DObject>}
  142. * An array of transformed points
  143. *
  144. * @requires highcharts-3d
  145. */
  146. function perspective(points, chart, insidePlotArea, useInvertedPersp) {
  147. var options3d = chart.options.chart.options3d,
  148. /* The useInvertedPersp argument is used for
  149. * inverted charts with already inverted elements,
  150. * such as dataLabels or tooltip positions.
  151. */
  152. inverted = pick(useInvertedPersp,
  153. insidePlotArea ? chart.inverted : false),
  154. origin = {
  155. x: chart.plotWidth / 2,
  156. y: chart.plotHeight / 2,
  157. z: options3d.depth / 2,
  158. vd: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0)
  159. },
  160. scale = chart.scale3d || 1,
  161. beta = deg2rad * options3d.beta * (inverted ? -1 : 1),
  162. alpha = deg2rad * options3d.alpha * (inverted ? -1 : 1),
  163. angles = {
  164. cosA: Math.cos(alpha),
  165. cosB: Math.cos(-beta),
  166. sinA: Math.sin(alpha),
  167. sinB: Math.sin(-beta)
  168. };
  169. if (!insidePlotArea) {
  170. origin.x += chart.plotLeft;
  171. origin.y += chart.plotTop;
  172. }
  173. // Transform each point
  174. return points.map(function (point) {
  175. var rotated = rotate3D((inverted ? point.y : point.x) - origin.x, (inverted ? point.x : point.y) - origin.y, (point.z || 0) - origin.z,
  176. angles),
  177. // Apply perspective
  178. coordinate = perspective3D(rotated,
  179. origin,
  180. origin.vd);
  181. // Apply translation
  182. coordinate.x = coordinate.x * scale + origin.x;
  183. coordinate.y = coordinate.y * scale + origin.y;
  184. coordinate.z = rotated.z * scale + origin.z;
  185. return {
  186. x: (inverted ? coordinate.y : coordinate.x),
  187. y: (inverted ? coordinate.x : coordinate.y),
  188. z: coordinate.z
  189. };
  190. });
  191. }
  192. H.perspective = perspective;
  193. /**
  194. * Calculate a distance from camera to points - made for calculating zIndex of
  195. * scatter points.
  196. *
  197. * @private
  198. * @function Highcharts.pointCameraDistance
  199. *
  200. * @param {Highcharts.Dictionary<number>} coordinates
  201. * Coordinates of the specific point
  202. *
  203. * @param {Highcharts.Chart} chart
  204. * Related chart
  205. *
  206. * @return {number}
  207. * Distance from camera to point
  208. *
  209. * @requires highcharts-3d
  210. */
  211. function pointCameraDistance(coordinates, chart) {
  212. var options3d = chart.options.chart.options3d,
  213. cameraPosition = {
  214. x: chart.plotWidth / 2,
  215. y: chart.plotHeight / 2,
  216. z: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0) +
  217. options3d.depth
  218. },
  219. // Added support for objects with plotX or x coordinates.
  220. distance = Math.sqrt(Math.pow(cameraPosition.x - pick(coordinates.plotX,
  221. coordinates.x), 2) +
  222. Math.pow(cameraPosition.y - pick(coordinates.plotY,
  223. coordinates.y), 2) +
  224. Math.pow(cameraPosition.z - pick(coordinates.plotZ,
  225. coordinates.z), 2));
  226. return distance;
  227. }
  228. H.pointCameraDistance = pointCameraDistance;
  229. /**
  230. * Calculate area of a 2D polygon using Shoelace algorithm
  231. * https://en.wikipedia.org/wiki/Shoelace_formula
  232. *
  233. * @private
  234. * @function Highcharts.shapeArea
  235. *
  236. * @param {Array<Highcharts.PositionObject>} vertexes
  237. * 2D Polygon
  238. *
  239. * @return {number}
  240. * Calculated area
  241. *
  242. * @requires highcharts-3d
  243. */
  244. function shapeArea(vertexes) {
  245. var area = 0,
  246. i,
  247. j;
  248. for (i = 0; i < vertexes.length; i++) {
  249. j = (i + 1) % vertexes.length;
  250. area += vertexes[i].x * vertexes[j].y - vertexes[j].x * vertexes[i].y;
  251. }
  252. return area / 2;
  253. }
  254. H.shapeArea = shapeArea;
  255. /**
  256. * Calculate area of a 3D polygon after perspective projection
  257. *
  258. * @private
  259. * @function Highcharts.shapeArea3d
  260. *
  261. * @param {Array<Highcharts.Position3DObject>} vertexes
  262. * 3D Polygon
  263. *
  264. * @param {Highcharts.Chart} chart
  265. * Related chart
  266. *
  267. * @param {boolean} [insidePlotArea]
  268. * Whether to verify that the points are inside the plotArea
  269. *
  270. * @return {number}
  271. * Calculated area
  272. *
  273. * @requires highcharts-3d
  274. */
  275. function shapeArea3D(vertexes, chart, insidePlotArea) {
  276. return shapeArea(perspective(vertexes, chart, insidePlotArea));
  277. }
  278. H.shapeArea3d = shapeArea3D;
  279. var mathModule = {
  280. perspective: perspective,
  281. perspective3D: perspective3D,
  282. pointCameraDistance: pointCameraDistance,
  283. shapeArea: shapeArea,
  284. shapeArea3D: shapeArea3D
  285. };
  286. return mathModule;
  287. });
  288. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement3D.js', [_modules['Core/Color/Color.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (Color, SVGElement, U) {
  289. /* *
  290. *
  291. * (c) 2010-2021 Torstein Honsi
  292. *
  293. * Extensions to the SVGRenderer class to enable 3D shapes
  294. *
  295. * License: www.highcharts.com/license
  296. *
  297. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  298. *
  299. * */
  300. var color = Color.parse;
  301. var defined = U.defined,
  302. merge = U.merge,
  303. objectEach = U.objectEach,
  304. pick = U.pick;
  305. /* *
  306. *
  307. * Namespace
  308. *
  309. * */
  310. var SVGElement3D;
  311. (function (SVGElement3D) {
  312. /* *
  313. *
  314. * Functions
  315. *
  316. * */
  317. /* eslint-disable valid-jsdoc */
  318. SVGElement3D.base = {
  319. /**
  320. * The init is used by base - renderer.Element
  321. * @private
  322. */
  323. initArgs: function (args) {
  324. var elem3d = this,
  325. renderer = elem3d.renderer,
  326. paths = renderer[elem3d.pathType + 'Path'](args),
  327. zIndexes = paths.zIndexes;
  328. // build parts
  329. elem3d.parts.forEach(function (part) {
  330. elem3d[part] = renderer.path(paths[part]).attr({
  331. 'class': 'highcharts-3d-' + part,
  332. zIndex: zIndexes[part] || 0
  333. }).add(elem3d);
  334. });
  335. elem3d.attr({
  336. 'stroke-linejoin': 'round',
  337. zIndex: zIndexes.group
  338. });
  339. // store original destroy
  340. elem3d.originalDestroy = elem3d.destroy;
  341. elem3d.destroy = elem3d.destroyParts;
  342. // Store information if any side of element was rendered by force.
  343. elem3d.forcedSides = paths.forcedSides;
  344. },
  345. /**
  346. * Single property setter that applies options to each part
  347. * @private
  348. */
  349. singleSetterForParts: function (prop, val, values, verb, duration, complete) {
  350. var elem3d = this,
  351. newAttr = {},
  352. optionsToApply = [null,
  353. null, (verb || 'attr'),
  354. duration,
  355. complete],
  356. hasZIndexes = values && values.zIndexes;
  357. if (!values) {
  358. newAttr[prop] = val;
  359. optionsToApply[0] = newAttr;
  360. }
  361. else {
  362. // It is needed to deal with the whole group zIndexing
  363. // in case of graph rotation
  364. if (hasZIndexes && hasZIndexes.group) {
  365. this.attr({
  366. zIndex: hasZIndexes.group
  367. });
  368. }
  369. objectEach(values, function (partVal, part) {
  370. newAttr[part] = {};
  371. newAttr[part][prop] = partVal;
  372. // include zIndexes if provided
  373. if (hasZIndexes) {
  374. newAttr[part].zIndex = values.zIndexes[part] || 0;
  375. }
  376. });
  377. optionsToApply[1] = newAttr;
  378. }
  379. return elem3d.processParts.apply(elem3d, optionsToApply);
  380. },
  381. /**
  382. * Calls function for each part. Used for attr, animate and destroy.
  383. * @private
  384. */
  385. processParts: function (props, partsProps, verb, duration, complete) {
  386. var elem3d = this;
  387. elem3d.parts.forEach(function (part) {
  388. // if different props for different parts
  389. if (partsProps) {
  390. props = pick(partsProps[part], false);
  391. }
  392. // only if something to set, but allow undefined
  393. if (props !== false) {
  394. elem3d[part][verb](props, duration, complete);
  395. }
  396. });
  397. return elem3d;
  398. },
  399. /**
  400. * Destroy all parts
  401. * @private
  402. */
  403. destroyParts: function () {
  404. this.processParts(null, null, 'destroy');
  405. return this.originalDestroy();
  406. }
  407. };
  408. SVGElement3D.cuboid = merge(SVGElement3D.base, {
  409. parts: ['front', 'top', 'side'],
  410. pathType: 'cuboid',
  411. attr: function (args, val, complete, continueAnimation) {
  412. // Resolve setting attributes by string name
  413. if (typeof args === 'string' && typeof val !== 'undefined') {
  414. var key = args;
  415. args = {};
  416. args[key] = val;
  417. }
  418. if (args.shapeArgs || defined(args.x)) {
  419. return this.singleSetterForParts('d', null, this.renderer[this.pathType + 'Path'](args.shapeArgs || args));
  420. }
  421. return SVGElement.prototype.attr.call(this, args, void 0, complete, continueAnimation);
  422. },
  423. animate: function (args, duration, complete) {
  424. if (defined(args.x) && defined(args.y)) {
  425. var paths = this.renderer[this.pathType + 'Path'](args),
  426. forcedSides = paths.forcedSides;
  427. this.singleSetterForParts('d', null, paths, 'animate', duration, complete);
  428. this.attr({
  429. zIndex: paths.zIndexes.group
  430. });
  431. // If sides that are forced to render changed, recalculate
  432. // colors.
  433. if (forcedSides !== this.forcedSides) {
  434. this.forcedSides = forcedSides;
  435. SVGElement3D.cuboid.fillSetter.call(this, this.fill);
  436. }
  437. }
  438. else {
  439. SVGElement.prototype.animate.call(this, args, duration, complete);
  440. }
  441. return this;
  442. },
  443. fillSetter: function (fill) {
  444. var elem3d = this;
  445. elem3d.forcedSides = elem3d.forcedSides || [];
  446. elem3d.singleSetterForParts('fill', null, {
  447. front: fill,
  448. // Do not change color if side was forced to render.
  449. top: color(fill).brighten(elem3d.forcedSides.indexOf('top') >= 0 ? 0 : 0.1).get(),
  450. side: color(fill).brighten(elem3d.forcedSides.indexOf('side') >= 0 ? 0 : -0.1).get()
  451. });
  452. // fill for animation getter (#6776)
  453. elem3d.color = elem3d.fill = fill;
  454. return elem3d;
  455. }
  456. });
  457. /* eslint-enable valid-jsdoc */
  458. })(SVGElement3D || (SVGElement3D = {}));
  459. return SVGElement3D;
  460. });
  461. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer3D.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Extensions/Math3D.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGElement3D.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (A, Color, H, Math3D, SVGElement, SVGElement3D, SVGRenderer, U) {
  462. /* *
  463. *
  464. * (c) 2010-2021 Torstein Honsi
  465. *
  466. * Extensions to the SVGRenderer class to enable 3D shapes
  467. *
  468. * License: www.highcharts.com/license
  469. *
  470. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  471. *
  472. * */
  473. var animObject = A.animObject;
  474. var color = Color.parse;
  475. var charts = H.charts,
  476. deg2rad = H.deg2rad;
  477. var perspective = Math3D.perspective,
  478. shapeArea = Math3D.shapeArea;
  479. var defined = U.defined,
  480. extend = U.extend,
  481. merge = U.merge,
  482. pick = U.pick;
  483. /* *
  484. *
  485. * Constants
  486. *
  487. * */
  488. var cos = Math.cos,
  489. sin = Math.sin,
  490. PI = Math.PI,
  491. dFactor = (4 * (Math.sqrt(2) - 1) / 3) / (PI / 2);
  492. /* *
  493. *
  494. * Functions
  495. *
  496. * */
  497. /* eslint-disable valid-jsdoc */
  498. /**
  499. * Method to construct a curved path. Can 'wrap' around more then 180 degrees.
  500. * @private
  501. */
  502. function curveTo(cx, cy, rx, ry, start, end, dx, dy) {
  503. var result = [],
  504. arcAngle = end - start;
  505. if ((end > start) && (end - start > Math.PI / 2 + 0.0001)) {
  506. result = result.concat(curveTo(cx, cy, rx, ry, start, start + (Math.PI / 2), dx, dy));
  507. result = result.concat(curveTo(cx, cy, rx, ry, start + (Math.PI / 2), end, dx, dy));
  508. return result;
  509. }
  510. if ((end < start) && (start - end > Math.PI / 2 + 0.0001)) {
  511. result = result.concat(curveTo(cx, cy, rx, ry, start, start - (Math.PI / 2), dx, dy));
  512. result = result.concat(curveTo(cx, cy, rx, ry, start - (Math.PI / 2), end, dx, dy));
  513. return result;
  514. }
  515. return [[
  516. 'C',
  517. cx + (rx * Math.cos(start)) -
  518. ((rx * dFactor * arcAngle) * Math.sin(start)) + dx,
  519. cy + (ry * Math.sin(start)) +
  520. ((ry * dFactor * arcAngle) * Math.cos(start)) + dy,
  521. cx + (rx * Math.cos(end)) +
  522. ((rx * dFactor * arcAngle) * Math.sin(end)) + dx,
  523. cy + (ry * Math.sin(end)) -
  524. ((ry * dFactor * arcAngle) * Math.cos(end)) + dy,
  525. cx + (rx * Math.cos(end)) + dx,
  526. cy + (ry * Math.sin(end)) + dy
  527. ]];
  528. }
  529. /* *
  530. *
  531. * Composition
  532. *
  533. * */
  534. SVGRenderer.prototype.elements3d = SVGElement3D;
  535. SVGRenderer.prototype.toLinePath = function (points, closed) {
  536. var result = [];
  537. // Put "L x y" for each point
  538. points.forEach(function (point) {
  539. result.push(['L', point.x, point.y]);
  540. });
  541. if (points.length) {
  542. // Set the first element to M
  543. result[0][0] = 'M';
  544. // If it is a closed line, add Z
  545. if (closed) {
  546. result.push(['Z']);
  547. }
  548. }
  549. return result;
  550. };
  551. SVGRenderer.prototype.toLineSegments = function (points) {
  552. var result = [],
  553. m = true;
  554. points.forEach(function (point) {
  555. result.push(m ? ['M', point.x, point.y] : ['L', point.x, point.y]);
  556. m = !m;
  557. });
  558. return result;
  559. };
  560. // A 3-D Face is defined by it's 3D vertexes, and is only visible if it's
  561. // vertexes are counter-clockwise (Back-face culling). It is used as a
  562. // polyhedron Element
  563. SVGRenderer.prototype.face3d = function (args) {
  564. var renderer = this,
  565. ret = this.createElement('path');
  566. ret.vertexes = [];
  567. ret.insidePlotArea = false;
  568. ret.enabled = true;
  569. /* eslint-disable no-invalid-this */
  570. ret.attr = function (hash) {
  571. if (typeof hash === 'object' &&
  572. (defined(hash.enabled) ||
  573. defined(hash.vertexes) ||
  574. defined(hash.insidePlotArea))) {
  575. this.enabled = pick(hash.enabled, this.enabled);
  576. this.vertexes = pick(hash.vertexes, this.vertexes);
  577. this.insidePlotArea = pick(hash.insidePlotArea, this.insidePlotArea);
  578. delete hash.enabled;
  579. delete hash.vertexes;
  580. delete hash.insidePlotArea;
  581. var chart = charts[renderer.chartIndex],
  582. vertexes2d = perspective(this.vertexes,
  583. chart,
  584. this.insidePlotArea),
  585. path = renderer.toLinePath(vertexes2d,
  586. true),
  587. area = shapeArea(vertexes2d);
  588. hash.d = path;
  589. hash.visibility = (this.enabled && area > 0) ? 'visible' : 'hidden';
  590. }
  591. return SVGElement.prototype.attr.apply(this, arguments);
  592. };
  593. ret.animate = function (params) {
  594. if (typeof params === 'object' &&
  595. (defined(params.enabled) ||
  596. defined(params.vertexes) ||
  597. defined(params.insidePlotArea))) {
  598. this.enabled = pick(params.enabled, this.enabled);
  599. this.vertexes = pick(params.vertexes, this.vertexes);
  600. this.insidePlotArea = pick(params.insidePlotArea, this.insidePlotArea);
  601. delete params.enabled;
  602. delete params.vertexes;
  603. delete params.insidePlotArea;
  604. var chart = charts[renderer.chartIndex],
  605. vertexes2d = perspective(this.vertexes,
  606. chart,
  607. this.insidePlotArea),
  608. path = renderer.toLinePath(vertexes2d,
  609. true),
  610. area = shapeArea(vertexes2d),
  611. visibility = (this.enabled && area > 0) ? 'visible' : 'hidden';
  612. params.d = path;
  613. this.attr('visibility', visibility);
  614. }
  615. return SVGElement.prototype.animate.apply(this, arguments);
  616. };
  617. /* eslint-enable no-invalid-this */
  618. return ret.attr(args);
  619. };
  620. // A Polyhedron is a handy way of defining a group of 3-D faces. It's only
  621. // attribute is `faces`, an array of attributes of each one of it's Face3D
  622. // instances.
  623. SVGRenderer.prototype.polyhedron = function (args) {
  624. var renderer = this,
  625. result = this.g(),
  626. destroy = result.destroy;
  627. if (!this.styledMode) {
  628. result.attr({
  629. 'stroke-linejoin': 'round'
  630. });
  631. }
  632. result.faces = [];
  633. /* eslint-disable no-invalid-this */
  634. // destroy all children
  635. result.destroy = function () {
  636. for (var i = 0; i < result.faces.length; i++) {
  637. result.faces[i].destroy();
  638. }
  639. return destroy.call(this);
  640. };
  641. result.attr = function (hash, val, complete, continueAnimation) {
  642. if (typeof hash === 'object' && defined(hash.faces)) {
  643. while (result.faces.length > hash.faces.length) {
  644. result.faces.pop().destroy();
  645. }
  646. while (result.faces.length < hash.faces.length) {
  647. result.faces.push(renderer.face3d().add(result));
  648. }
  649. for (var i = 0; i < hash.faces.length; i++) {
  650. if (renderer.styledMode) {
  651. delete hash.faces[i].fill;
  652. }
  653. result.faces[i].attr(hash.faces[i], null, complete, continueAnimation);
  654. }
  655. delete hash.faces;
  656. }
  657. return SVGElement.prototype.attr.apply(this, arguments);
  658. };
  659. result.animate = function (params, duration, complete) {
  660. if (params && params.faces) {
  661. while (result.faces.length > params.faces.length) {
  662. result.faces.pop().destroy();
  663. }
  664. while (result.faces.length < params.faces.length) {
  665. result.faces.push(renderer.face3d().add(result));
  666. }
  667. for (var i = 0; i < params.faces.length; i++) {
  668. result.faces[i].animate(params.faces[i], duration, complete);
  669. }
  670. delete params.faces;
  671. }
  672. return SVGElement.prototype.animate.apply(this, arguments);
  673. };
  674. /* eslint-enable no-invalid-this */
  675. return result.attr(args);
  676. };
  677. /**
  678. * return result, generalization
  679. * @private
  680. * @requires highcharts-3d
  681. */
  682. SVGRenderer.prototype.element3d = function (type, shapeArgs) {
  683. // base
  684. var ret = this.g();
  685. // extend
  686. extend(ret, this.elements3d[type]);
  687. // init
  688. ret.initArgs(shapeArgs);
  689. // return
  690. return ret;
  691. };
  692. // generelized, so now use simply
  693. SVGRenderer.prototype.cuboid = function (shapeArgs) {
  694. return this.element3d('cuboid', shapeArgs);
  695. };
  696. // Generates a cuboid path and zIndexes
  697. SVGRenderer.prototype.cuboidPath = function (shapeArgs) {
  698. var x = shapeArgs.x || 0,
  699. y = shapeArgs.y || 0,
  700. z = shapeArgs.z || 0,
  701. // For side calculation (right/left)
  702. // there is a need for height (and other shapeArgs arguments)
  703. // to be at least 1px
  704. h = shapeArgs.height || 0,
  705. w = shapeArgs.width || 0,
  706. d = shapeArgs.depth || 0,
  707. chart = charts[this.chartIndex],
  708. front,
  709. back,
  710. top,
  711. bottom,
  712. left,
  713. right,
  714. shape,
  715. path1,
  716. path2,
  717. path3,
  718. isFront,
  719. isTop,
  720. isRight,
  721. options3d = chart.options.chart.options3d,
  722. alpha = options3d.alpha,
  723. // Priority for x axis is the biggest,
  724. // because of x direction has biggest influence on zIndex
  725. incrementX = 1000000,
  726. // y axis has the smallest priority in case of our charts
  727. // (needs to be set because of stacking)
  728. incrementY = 10,
  729. incrementZ = 100,
  730. zIndex = 0,
  731. // The 8 corners of the cube
  732. pArr = [{
  733. x: x,
  734. y: y,
  735. z: z
  736. }, {
  737. x: x + w,
  738. y: y,
  739. z: z
  740. }, {
  741. x: x + w,
  742. y: y + h,
  743. z: z
  744. }, {
  745. x: x,
  746. y: y + h,
  747. z: z
  748. }, {
  749. x: x,
  750. y: y + h,
  751. z: z + d
  752. }, {
  753. x: x + w,
  754. y: y + h,
  755. z: z + d
  756. }, {
  757. x: x + w,
  758. y: y,
  759. z: z + d
  760. }, {
  761. x: x,
  762. y: y,
  763. z: z + d
  764. }],
  765. forcedSides = [],
  766. pickShape;
  767. // apply perspective
  768. pArr = perspective(pArr, chart, shapeArgs.insidePlotArea);
  769. /**
  770. * helper method to decide which side is visible
  771. * @private
  772. */
  773. function mapSidePath(i) {
  774. // Added support for 0 value in columns, where height is 0
  775. // but the shape is rendered.
  776. // Height is used from 1st to 6th element of pArr
  777. if (h === 0 && i > 1 && i < 6) { // [2, 3, 4, 5]
  778. return {
  779. x: pArr[i].x,
  780. // when height is 0 instead of cuboid we render plane
  781. // so it is needed to add fake 10 height to imitate cuboid
  782. // for side calculation
  783. y: pArr[i].y + 10,
  784. z: pArr[i].z
  785. };
  786. }
  787. // It is needed to calculate dummy sides (front/back) for breaking
  788. // points in case of x and depth values. If column has side,
  789. // it means that x values of front and back side are different.
  790. if (pArr[0].x === pArr[7].x && i >= 4) { // [4, 5, 6, 7]
  791. return {
  792. x: pArr[i].x + 10,
  793. // when height is 0 instead of cuboid we render plane
  794. // so it is needed to add fake 10 height to imitate cuboid
  795. // for side calculation
  796. y: pArr[i].y,
  797. z: pArr[i].z
  798. };
  799. }
  800. // Added dummy depth
  801. if (d === 0 && i < 2 || i > 5) { // [0, 1, 6, 7]
  802. return {
  803. x: pArr[i].x,
  804. // when height is 0 instead of cuboid we render plane
  805. // so it is needed to add fake 10 height to imitate cuboid
  806. // for side calculation
  807. y: pArr[i].y,
  808. z: pArr[i].z + 10
  809. };
  810. }
  811. return pArr[i];
  812. }
  813. /**
  814. * method creating the final side
  815. * @private
  816. */
  817. function mapPath(i) {
  818. return pArr[i];
  819. }
  820. /**
  821. * First value - path with specific face
  822. * Second value - added information about side for later calculations.
  823. * Possible second values are 0 for path1, 1 for path2 and -1 for no path
  824. * chosen.
  825. * Third value - string containing information about current side
  826. * of cuboid for forcing side rendering.
  827. * @private
  828. */
  829. pickShape = function (verticesIndex1, verticesIndex2, side) {
  830. var ret = [[], -1],
  831. // An array of vertices for cuboid face
  832. face1 = verticesIndex1.map(mapPath),
  833. face2 = verticesIndex2.map(mapPath),
  834. // dummy face is calculated the same way as standard face,
  835. // but if cuboid height is 0 additional height is added so it is
  836. // possible to use this vertices array for visible face calculation
  837. dummyFace1 = verticesIndex1.map(mapSidePath),
  838. dummyFace2 = verticesIndex2.map(mapSidePath);
  839. if (shapeArea(face1) < 0) {
  840. ret = [face1, 0];
  841. }
  842. else if (shapeArea(face2) < 0) {
  843. ret = [face2, 1];
  844. }
  845. else if (side) {
  846. forcedSides.push(side);
  847. if (shapeArea(dummyFace1) < 0) {
  848. ret = [face1, 0];
  849. }
  850. else if (shapeArea(dummyFace2) < 0) {
  851. ret = [face2, 1];
  852. }
  853. else {
  854. ret = [face1, 0]; // force side calculation.
  855. }
  856. }
  857. return ret;
  858. };
  859. // front or back
  860. front = [3, 2, 1, 0];
  861. back = [7, 6, 5, 4];
  862. shape = pickShape(front, back, 'front');
  863. path1 = shape[0];
  864. isFront = shape[1];
  865. // top or bottom
  866. top = [1, 6, 7, 0];
  867. bottom = [4, 5, 2, 3];
  868. shape = pickShape(top, bottom, 'top');
  869. path2 = shape[0];
  870. isTop = shape[1];
  871. // side
  872. right = [1, 2, 5, 6];
  873. left = [0, 7, 4, 3];
  874. shape = pickShape(right, left, 'side');
  875. path3 = shape[0];
  876. isRight = shape[1];
  877. /* New block used for calculating zIndex. It is basing on X, Y and Z
  878. position of specific columns. All zIndexes (for X, Y and Z values) are
  879. added to the final zIndex, where every value has different priority. The
  880. biggest priority is in X and Z directions, the lowest index is for
  881. stacked columns (Y direction and the same X and Z positions). Big
  882. differences between priorities is made because we need to ensure that
  883. even for big changes in Y and Z parameters all columns will be drawn
  884. correctly. */
  885. if (isRight === 1) {
  886. // It is needed to connect value with current chart width
  887. // for big chart size.
  888. zIndex += incrementX * (chart.plotWidth - x);
  889. }
  890. else if (!isRight) {
  891. zIndex += incrementX * x;
  892. }
  893. zIndex += incrementY * (!isTop ||
  894. // Numbers checked empirically
  895. (alpha >= 0 && alpha <= 180 || alpha < 360 && alpha > 357.5) ?
  896. chart.plotHeight - y : 10 + y);
  897. if (isFront === 1) {
  898. zIndex += incrementZ * (z);
  899. }
  900. else if (!isFront) {
  901. zIndex += incrementZ * (1000 - z);
  902. }
  903. return {
  904. front: this.toLinePath(path1, true),
  905. top: this.toLinePath(path2, true),
  906. side: this.toLinePath(path3, true),
  907. zIndexes: {
  908. group: Math.round(zIndex)
  909. },
  910. forcedSides: forcedSides,
  911. // additional info about zIndexes
  912. isFront: isFront,
  913. isTop: isTop
  914. }; // #4774
  915. };
  916. // SECTORS //
  917. SVGRenderer.prototype.arc3d = function (attribs) {
  918. var wrapper = this.g(), renderer = wrapper.renderer, customAttribs = ['x', 'y', 'r', 'innerR', 'start', 'end', 'depth'];
  919. /**
  920. * Get custom attributes. Don't mutate the original object and return an
  921. * object with only custom attr.
  922. * @private
  923. */
  924. function suckOutCustom(params) {
  925. var hasCA = false,
  926. ca = {},
  927. key;
  928. params = merge(params); // Don't mutate the original object
  929. for (key in params) {
  930. if (customAttribs.indexOf(key) !== -1) {
  931. ca[key] = params[key];
  932. delete params[key];
  933. hasCA = true;
  934. }
  935. }
  936. return hasCA ? [ca, params] : false;
  937. }
  938. attribs = merge(attribs);
  939. attribs.alpha = (attribs.alpha || 0) * deg2rad;
  940. attribs.beta = (attribs.beta || 0) * deg2rad;
  941. // Create the different sub sections of the shape
  942. wrapper.top = renderer.path();
  943. wrapper.side1 = renderer.path();
  944. wrapper.side2 = renderer.path();
  945. wrapper.inn = renderer.path();
  946. wrapper.out = renderer.path();
  947. /* eslint-disable no-invalid-this */
  948. // Add all faces
  949. wrapper.onAdd = function () {
  950. var parent = wrapper.parentGroup,
  951. className = wrapper.attr('class');
  952. wrapper.top.add(wrapper);
  953. // These faces are added outside the wrapper group because the z index
  954. // relates to neighbour elements as well
  955. ['out', 'inn', 'side1', 'side2'].forEach(function (face) {
  956. wrapper[face]
  957. .attr({
  958. 'class': className + ' highcharts-3d-side'
  959. })
  960. .add(parent);
  961. });
  962. };
  963. // Cascade to faces
  964. ['addClass', 'removeClass'].forEach(function (fn) {
  965. wrapper[fn] = function () {
  966. var args = arguments;
  967. ['top', 'out', 'inn', 'side1', 'side2'].forEach(function (face) {
  968. wrapper[face][fn].apply(wrapper[face], args);
  969. });
  970. };
  971. });
  972. /**
  973. * Compute the transformed paths and set them to the composite shapes
  974. * @private
  975. */
  976. wrapper.setPaths = function (attribs) {
  977. var paths = wrapper.renderer.arc3dPath(attribs),
  978. zIndex = paths.zTop * 100;
  979. wrapper.attribs = attribs;
  980. wrapper.top.attr({ d: paths.top, zIndex: paths.zTop });
  981. wrapper.inn.attr({ d: paths.inn, zIndex: paths.zInn });
  982. wrapper.out.attr({ d: paths.out, zIndex: paths.zOut });
  983. wrapper.side1.attr({ d: paths.side1, zIndex: paths.zSide1 });
  984. wrapper.side2.attr({ d: paths.side2, zIndex: paths.zSide2 });
  985. // show all children
  986. wrapper.zIndex = zIndex;
  987. wrapper.attr({ zIndex: zIndex });
  988. // Set the radial gradient center the first time
  989. if (attribs.center) {
  990. wrapper.top.setRadialReference(attribs.center);
  991. delete attribs.center;
  992. }
  993. };
  994. wrapper.setPaths(attribs);
  995. /**
  996. * Apply the fill to the top and a darker shade to the sides
  997. * @private
  998. */
  999. wrapper.fillSetter = function (value) {
  1000. var darker = color(value).brighten(-0.1).get();
  1001. this.fill = value;
  1002. this.side1.attr({ fill: darker });
  1003. this.side2.attr({ fill: darker });
  1004. this.inn.attr({ fill: darker });
  1005. this.out.attr({ fill: darker });
  1006. this.top.attr({ fill: value });
  1007. return this;
  1008. };
  1009. // Apply the same value to all. These properties cascade down to the
  1010. // children when set to the composite arc3d.
  1011. ['opacity', 'translateX', 'translateY', 'visibility'].forEach(function (setter) {
  1012. wrapper[setter + 'Setter'] = function (value, key) {
  1013. wrapper[key] = value;
  1014. ['out', 'inn', 'side1', 'side2', 'top'].forEach(function (el) {
  1015. wrapper[el].attr(key, value);
  1016. });
  1017. };
  1018. });
  1019. // Override attr to remove shape attributes and use those to set child paths
  1020. wrapper.attr = function (params) {
  1021. var ca,
  1022. paramArr;
  1023. if (typeof params === 'object') {
  1024. paramArr = suckOutCustom(params);
  1025. if (paramArr) {
  1026. ca = paramArr[0];
  1027. arguments[0] = paramArr[1];
  1028. extend(wrapper.attribs, ca);
  1029. wrapper.setPaths(wrapper.attribs);
  1030. }
  1031. }
  1032. return SVGElement.prototype.attr.apply(wrapper, arguments);
  1033. };
  1034. // Override the animate function by sucking out custom parameters related to
  1035. // the shapes directly, and update the shapes from the animation step.
  1036. wrapper.animate = function (params, animation, complete) {
  1037. var paramArr,
  1038. from = this.attribs,
  1039. to,
  1040. anim,
  1041. randomProp = 'data-' + Math.random().toString(26).substring(2, 9);
  1042. // Attribute-line properties connected to 3D. These shouldn't have been
  1043. // in the attribs collection in the first place.
  1044. delete params.center;
  1045. delete params.z;
  1046. delete params.alpha;
  1047. delete params.beta;
  1048. anim = animObject(pick(animation, this.renderer.globalAnimation));
  1049. if (anim.duration) {
  1050. paramArr = suckOutCustom(params);
  1051. // Params need to have a property in order for the step to run
  1052. // (#5765, #7097, #7437)
  1053. wrapper[randomProp] = 0;
  1054. params[randomProp] = 1;
  1055. wrapper[randomProp + 'Setter'] = H.noop;
  1056. if (paramArr) {
  1057. to = paramArr[0]; // custom attr
  1058. anim.step = function (a, fx) {
  1059. /**
  1060. * @private
  1061. */
  1062. function interpolate(key) {
  1063. return from[key] + (pick(to[key], from[key]) -
  1064. from[key]) * fx.pos;
  1065. }
  1066. if (fx.prop === randomProp) {
  1067. fx.elem.setPaths(merge(from, {
  1068. x: interpolate('x'),
  1069. y: interpolate('y'),
  1070. r: interpolate('r'),
  1071. innerR: interpolate('innerR'),
  1072. start: interpolate('start'),
  1073. end: interpolate('end'),
  1074. depth: interpolate('depth')
  1075. }));
  1076. }
  1077. };
  1078. }
  1079. animation = anim; // Only when duration (#5572)
  1080. }
  1081. return SVGElement.prototype.animate.call(this, params, animation, complete);
  1082. };
  1083. // destroy all children
  1084. wrapper.destroy = function () {
  1085. this.top.destroy();
  1086. this.out.destroy();
  1087. this.inn.destroy();
  1088. this.side1.destroy();
  1089. this.side2.destroy();
  1090. return SVGElement.prototype.destroy.call(this);
  1091. };
  1092. // hide all children
  1093. wrapper.hide = function () {
  1094. this.top.hide();
  1095. this.out.hide();
  1096. this.inn.hide();
  1097. this.side1.hide();
  1098. this.side2.hide();
  1099. };
  1100. wrapper.show = function (inherit) {
  1101. this.top.show(inherit);
  1102. this.out.show(inherit);
  1103. this.inn.show(inherit);
  1104. this.side1.show(inherit);
  1105. this.side2.show(inherit);
  1106. };
  1107. /* eslint-enable no-invalid-this */
  1108. return wrapper;
  1109. };
  1110. // Generate the paths required to draw a 3D arc
  1111. SVGRenderer.prototype.arc3dPath = function (shapeArgs) {
  1112. var cx = shapeArgs.x || 0, // x coordinate of the center
  1113. cy = shapeArgs.y || 0, // y coordinate of the center
  1114. start = shapeArgs.start || 0, // start angle
  1115. end = (shapeArgs.end || 0) - 0.00001, // end angle
  1116. r = shapeArgs.r || 0, // radius
  1117. ir = shapeArgs.innerR || 0, // inner radius
  1118. d = shapeArgs.depth || 0, // depth
  1119. alpha = shapeArgs.alpha || 0, // alpha rotation of the chart
  1120. beta = shapeArgs.beta || 0; // beta rotation of the chart
  1121. // Derived Variables
  1122. var cs = Math.cos(start), // cosinus of the start angle
  1123. ss = Math.sin(start), // sinus of the start angle
  1124. ce = Math.cos(end), // cosinus of the end angle
  1125. se = Math.sin(end), // sinus of the end angle
  1126. rx = r * Math.cos(beta), // x-radius
  1127. ry = r * Math.cos(alpha), // y-radius
  1128. irx = ir * Math.cos(beta), // x-radius (inner)
  1129. iry = ir * Math.cos(alpha), // y-radius (inner)
  1130. dx = d * Math.sin(beta), // distance between top and bottom in x
  1131. dy = d * Math.sin(alpha); // distance between top and bottom in y
  1132. // TOP
  1133. var top = [
  1134. ['M',
  1135. cx + (rx * cs),
  1136. cy + (ry * ss)]
  1137. ];
  1138. top = top.concat(curveTo(cx, cy, rx, ry, start, end, 0, 0));
  1139. top.push([
  1140. 'L', cx + (irx * ce), cy + (iry * se)
  1141. ]);
  1142. top = top.concat(curveTo(cx, cy, irx, iry, end, start, 0, 0));
  1143. top.push(['Z']);
  1144. // OUTSIDE
  1145. var b = (beta > 0 ? Math.PI / 2 : 0),
  1146. a = (alpha > 0 ? 0 : Math.PI / 2);
  1147. var start2 = start > -b ? start : (end > -b ? -b : start),
  1148. end2 = end < PI - a ? end : (start < PI - a ? PI - a : end),
  1149. midEnd = 2 * PI - a;
  1150. // When slice goes over bottom middle, need to add both, left and right
  1151. // outer side. Additionally, when we cross right hand edge, create sharp
  1152. // edge. Outer shape/wall:
  1153. //
  1154. // -------
  1155. // / ^ \
  1156. // 4) / / \ \ 1)
  1157. // / / \ \
  1158. // / / \ \
  1159. // (c)=> ==== ==== <=(d)
  1160. // \ \ / /
  1161. // \ \<=(a)/ /
  1162. // \ \ / / <=(b)
  1163. // 3) \ v / 2)
  1164. // -------
  1165. //
  1166. // (a) - inner side
  1167. // (b) - outer side
  1168. // (c) - left edge (sharp)
  1169. // (d) - right edge (sharp)
  1170. // 1..n - rendering order for startAngle = 0, when set to e.g 90, order
  1171. // changes clockwise (1->2, 2->3, n->1) and counterclockwise for negative
  1172. // startAngle
  1173. var out = [
  1174. ['M',
  1175. cx + (rx * cos(start2)),
  1176. cy + (ry * sin(start2))]
  1177. ];
  1178. out = out.concat(curveTo(cx, cy, rx, ry, start2, end2, 0, 0));
  1179. // When shape is wide, it can cross both, (c) and (d) edges, when using
  1180. // startAngle
  1181. if (end > midEnd && start < midEnd) {
  1182. // Go to outer side
  1183. out.push([
  1184. 'L', cx + (rx * cos(end2)) + dx, cy + (ry * sin(end2)) + dy
  1185. ]);
  1186. // Curve to the right edge of the slice (d)
  1187. out = out.concat(curveTo(cx, cy, rx, ry, end2, midEnd, dx, dy));
  1188. // Go to the inner side
  1189. out.push([
  1190. 'L', cx + (rx * cos(midEnd)), cy + (ry * sin(midEnd))
  1191. ]);
  1192. // Curve to the true end of the slice
  1193. out = out.concat(curveTo(cx, cy, rx, ry, midEnd, end, 0, 0));
  1194. // Go to the outer side
  1195. out.push([
  1196. 'L', cx + (rx * cos(end)) + dx, cy + (ry * sin(end)) + dy
  1197. ]);
  1198. // Go back to middle (d)
  1199. out = out.concat(curveTo(cx, cy, rx, ry, end, midEnd, dx, dy));
  1200. out.push([
  1201. 'L', cx + (rx * cos(midEnd)), cy + (ry * sin(midEnd))
  1202. ]);
  1203. // Go back to the left edge
  1204. out = out.concat(curveTo(cx, cy, rx, ry, midEnd, end2, 0, 0));
  1205. // But shape can cross also only (c) edge:
  1206. }
  1207. else if (end > PI - a && start < PI - a) {
  1208. // Go to outer side
  1209. out.push([
  1210. 'L',
  1211. cx + (rx * Math.cos(end2)) + dx,
  1212. cy + (ry * Math.sin(end2)) + dy
  1213. ]);
  1214. // Curve to the true end of the slice
  1215. out = out.concat(curveTo(cx, cy, rx, ry, end2, end, dx, dy));
  1216. // Go to the inner side
  1217. out.push([
  1218. 'L', cx + (rx * Math.cos(end)), cy + (ry * Math.sin(end))
  1219. ]);
  1220. // Go back to the artifical end2
  1221. out = out.concat(curveTo(cx, cy, rx, ry, end, end2, 0, 0));
  1222. }
  1223. out.push([
  1224. 'L', cx + (rx * Math.cos(end2)) + dx, cy + (ry * Math.sin(end2)) + dy
  1225. ]);
  1226. out = out.concat(curveTo(cx, cy, rx, ry, end2, start2, dx, dy));
  1227. out.push(['Z']);
  1228. // INSIDE
  1229. var inn = [
  1230. ['M',
  1231. cx + (irx * cs),
  1232. cy + (iry * ss)]
  1233. ];
  1234. inn = inn.concat(curveTo(cx, cy, irx, iry, start, end, 0, 0));
  1235. inn.push([
  1236. 'L', cx + (irx * Math.cos(end)) + dx, cy + (iry * Math.sin(end)) + dy
  1237. ]);
  1238. inn = inn.concat(curveTo(cx, cy, irx, iry, end, start, dx, dy));
  1239. inn.push(['Z']);
  1240. // SIDES
  1241. var side1 = [
  1242. ['M',
  1243. cx + (rx * cs),
  1244. cy + (ry * ss)],
  1245. ['L',
  1246. cx + (rx * cs) + dx,
  1247. cy + (ry * ss) + dy],
  1248. ['L',
  1249. cx + (irx * cs) + dx,
  1250. cy + (iry * ss) + dy],
  1251. ['L',
  1252. cx + (irx * cs),
  1253. cy + (iry * ss)],
  1254. ['Z']
  1255. ];
  1256. var side2 = [
  1257. ['M',
  1258. cx + (rx * ce),
  1259. cy + (ry * se)],
  1260. ['L',
  1261. cx + (rx * ce) + dx,
  1262. cy + (ry * se) + dy],
  1263. ['L',
  1264. cx + (irx * ce) + dx,
  1265. cy + (iry * se) + dy],
  1266. ['L',
  1267. cx + (irx * ce),
  1268. cy + (iry * se)],
  1269. ['Z']
  1270. ];
  1271. // correction for changed position of vanishing point caused by alpha and
  1272. // beta rotations
  1273. var angleCorr = Math.atan2(dy, -dx),
  1274. angleEnd = Math.abs(end + angleCorr),
  1275. angleStart = Math.abs(start + angleCorr),
  1276. angleMid = Math.abs((start + end) / 2 + angleCorr);
  1277. /**
  1278. * set to 0-PI range
  1279. * @private
  1280. */
  1281. function toZeroPIRange(angle) {
  1282. angle = angle % (2 * Math.PI);
  1283. if (angle > Math.PI) {
  1284. angle = 2 * Math.PI - angle;
  1285. }
  1286. return angle;
  1287. }
  1288. angleEnd = toZeroPIRange(angleEnd);
  1289. angleStart = toZeroPIRange(angleStart);
  1290. angleMid = toZeroPIRange(angleMid);
  1291. // *1e5 is to compensate pInt in zIndexSetter
  1292. var incPrecision = 1e5,
  1293. a1 = angleMid * incPrecision,
  1294. a2 = angleStart * incPrecision,
  1295. a3 = angleEnd * incPrecision;
  1296. return {
  1297. top: top,
  1298. // max angle is PI, so this is always higher
  1299. zTop: Math.PI * incPrecision + 1,
  1300. out: out,
  1301. zOut: Math.max(a1, a2, a3),
  1302. inn: inn,
  1303. zInn: Math.max(a1, a2, a3),
  1304. side1: side1,
  1305. zSide1: a3 * 0.99,
  1306. side2: side2,
  1307. zSide2: a2 * 0.99
  1308. };
  1309. };
  1310. /* *
  1311. *
  1312. * Default Export
  1313. *
  1314. * */
  1315. return SVGRenderer;
  1316. });
  1317. _registerModule(_modules, 'Core/Axis/Tick3D.js', [_modules['Core/Utilities.js']], function (U) {
  1318. /* *
  1319. *
  1320. * (c) 2010-2021 Torstein Honsi
  1321. *
  1322. * Extenstion for 3d axes
  1323. *
  1324. * License: www.highcharts.com/license
  1325. *
  1326. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1327. *
  1328. * */
  1329. var addEvent = U.addEvent,
  1330. extend = U.extend,
  1331. wrap = U.wrap;
  1332. /* eslint-disable valid-jsdoc */
  1333. /**
  1334. * Tick with 3D support
  1335. * @private
  1336. * @class
  1337. */
  1338. var Tick3D = /** @class */ (function () {
  1339. function Tick3D() {
  1340. }
  1341. /* *
  1342. *
  1343. * Static Functions
  1344. *
  1345. * */
  1346. /**
  1347. * @private
  1348. */
  1349. Tick3D.compose = function (TickClass) {
  1350. addEvent(TickClass, 'afterGetLabelPosition', Tick3D.onAfterGetLabelPosition);
  1351. var tickProto = TickClass.prototype;
  1352. wrap(tickProto, 'getMarkPath', Tick3D.wrapGetMarkPath);
  1353. };
  1354. /**
  1355. * @private
  1356. */
  1357. Tick3D.onAfterGetLabelPosition = function (e) {
  1358. var axis3D = this.axis.axis3D;
  1359. if (axis3D) {
  1360. extend(e.pos, axis3D.fix3dPosition(e.pos));
  1361. }
  1362. };
  1363. /**
  1364. * @private
  1365. */
  1366. Tick3D.wrapGetMarkPath = function (proceed) {
  1367. var chart = this.axis.chart;
  1368. var axis3D = this.axis.axis3D;
  1369. var path = proceed.apply(this,
  1370. [].slice.call(arguments, 1));
  1371. if (axis3D) {
  1372. var start = path[0];
  1373. var end = path[1];
  1374. if (start[0] === 'M' && end[0] === 'L') {
  1375. var pArr = [
  1376. axis3D.fix3dPosition({ x: start[1],
  1377. y: start[2],
  1378. z: 0 }),
  1379. axis3D.fix3dPosition({ x: end[1],
  1380. y: end[2],
  1381. z: 0 })
  1382. ];
  1383. return this.axis.chart.renderer.toLineSegments(pArr);
  1384. }
  1385. }
  1386. return path;
  1387. };
  1388. return Tick3D;
  1389. }());
  1390. return Tick3D;
  1391. });
  1392. _registerModule(_modules, 'Core/Axis/Axis3D.js', [_modules['Core/Globals.js'], _modules['Extensions/Math3D.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Axis/Tick3D.js'], _modules['Core/Utilities.js']], function (H, Math3D, Tick, Tick3D, U) {
  1393. /* *
  1394. *
  1395. * (c) 2010-2021 Torstein Honsi
  1396. *
  1397. * Extenstion for 3d axes
  1398. *
  1399. * License: www.highcharts.com/license
  1400. *
  1401. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1402. *
  1403. * */
  1404. var perspective = Math3D.perspective,
  1405. perspective3D = Math3D.perspective3D,
  1406. shapeArea = Math3D.shapeArea;
  1407. var addEvent = U.addEvent,
  1408. merge = U.merge,
  1409. pick = U.pick,
  1410. wrap = U.wrap;
  1411. var deg2rad = H.deg2rad;
  1412. /* eslint-disable valid-jsdoc */
  1413. /**
  1414. * Adds 3D support to axes.
  1415. * @private
  1416. * @class
  1417. */
  1418. var Axis3DAdditions = /** @class */ (function () {
  1419. /* *
  1420. *
  1421. * Constructors
  1422. *
  1423. * */
  1424. /**
  1425. * @private
  1426. */
  1427. function Axis3DAdditions(axis) {
  1428. this.axis = axis;
  1429. }
  1430. /* *
  1431. *
  1432. * Functions
  1433. *
  1434. * */
  1435. /**
  1436. * @private
  1437. * @param {Highcharts.Axis} axis
  1438. * Related axis.
  1439. * @param {Highcharts.Position3DObject} pos
  1440. * Position to fix.
  1441. * @param {boolean} [isTitle]
  1442. * Whether this is a title position.
  1443. * @return {Highcharts.Position3DObject}
  1444. * Fixed position.
  1445. */
  1446. Axis3DAdditions.prototype.fix3dPosition = function (pos, isTitle) {
  1447. var axis3D = this;
  1448. var axis = axis3D.axis;
  1449. var chart = axis.chart;
  1450. // Do not do this if the chart is not 3D
  1451. if (axis.coll === 'colorAxis' ||
  1452. !chart.chart3d ||
  1453. !chart.is3d()) {
  1454. return pos;
  1455. }
  1456. var alpha = deg2rad * chart.options.chart.options3d.alpha,
  1457. beta = deg2rad * chart.options.chart.options3d.beta,
  1458. positionMode = pick(isTitle && axis.options.title.position3d,
  1459. axis.options.labels.position3d),
  1460. skew = pick(isTitle && axis.options.title.skew3d,
  1461. axis.options.labels.skew3d),
  1462. frame = chart.chart3d.frame3d,
  1463. plotLeft = chart.plotLeft,
  1464. plotRight = chart.plotWidth + plotLeft,
  1465. plotTop = chart.plotTop,
  1466. plotBottom = chart.plotHeight + plotTop,
  1467. // Indicates that we are labelling an X or Z axis on the "back" of
  1468. // the chart
  1469. reverseFlap = false,
  1470. offsetX = 0,
  1471. offsetY = 0,
  1472. vecX,
  1473. vecY = { x: 0,
  1474. y: 1,
  1475. z: 0 };
  1476. pos = axis.axis3D.swapZ({ x: pos.x, y: pos.y, z: 0 });
  1477. if (axis.isZAxis) { // Z Axis
  1478. if (axis.opposite) {
  1479. if (frame.axes.z.top === null) {
  1480. return {};
  1481. }
  1482. offsetY = pos.y - plotTop;
  1483. pos.x = frame.axes.z.top.x;
  1484. pos.y = frame.axes.z.top.y;
  1485. vecX = frame.axes.z.top.xDir;
  1486. reverseFlap = !frame.top.frontFacing;
  1487. }
  1488. else {
  1489. if (frame.axes.z.bottom === null) {
  1490. return {};
  1491. }
  1492. offsetY = pos.y - plotBottom;
  1493. pos.x = frame.axes.z.bottom.x;
  1494. pos.y = frame.axes.z.bottom.y;
  1495. vecX = frame.axes.z.bottom.xDir;
  1496. reverseFlap = !frame.bottom.frontFacing;
  1497. }
  1498. }
  1499. else if (axis.horiz) { // X Axis
  1500. if (axis.opposite) {
  1501. if (frame.axes.x.top === null) {
  1502. return {};
  1503. }
  1504. offsetY = pos.y - plotTop;
  1505. pos.y = frame.axes.x.top.y;
  1506. pos.z = frame.axes.x.top.z;
  1507. vecX = frame.axes.x.top.xDir;
  1508. reverseFlap = !frame.top.frontFacing;
  1509. }
  1510. else {
  1511. if (frame.axes.x.bottom === null) {
  1512. return {};
  1513. }
  1514. offsetY = pos.y - plotBottom;
  1515. pos.y = frame.axes.x.bottom.y;
  1516. pos.z = frame.axes.x.bottom.z;
  1517. vecX = frame.axes.x.bottom.xDir;
  1518. reverseFlap = !frame.bottom.frontFacing;
  1519. }
  1520. }
  1521. else { // Y Axis
  1522. if (axis.opposite) {
  1523. if (frame.axes.y.right === null) {
  1524. return {};
  1525. }
  1526. offsetX = pos.x - plotRight;
  1527. pos.x = frame.axes.y.right.x;
  1528. pos.z = frame.axes.y.right.z;
  1529. vecX = frame.axes.y.right.xDir;
  1530. // Rotate 90º on opposite edge
  1531. vecX = { x: vecX.z, y: vecX.y, z: -vecX.x };
  1532. }
  1533. else {
  1534. if (frame.axes.y.left === null) {
  1535. return {};
  1536. }
  1537. offsetX = pos.x - plotLeft;
  1538. pos.x = frame.axes.y.left.x;
  1539. pos.z = frame.axes.y.left.z;
  1540. vecX = frame.axes.y.left.xDir;
  1541. }
  1542. }
  1543. if (positionMode === 'chart') {
  1544. // Labels preserve their direction relative to the chart
  1545. // nothing to do
  1546. }
  1547. else if (positionMode === 'flap') {
  1548. // Labels are rotated around the axis direction to face the screen
  1549. if (!axis.horiz) { // Y Axis
  1550. vecX = { x: Math.cos(beta), y: 0, z: Math.sin(beta) };
  1551. }
  1552. else { // X and Z Axis
  1553. var sin = Math.sin(alpha);
  1554. var cos = Math.cos(alpha);
  1555. if (axis.opposite) {
  1556. sin = -sin;
  1557. }
  1558. if (reverseFlap) {
  1559. sin = -sin;
  1560. }
  1561. vecY = { x: vecX.z * sin, y: cos, z: -vecX.x * sin };
  1562. }
  1563. }
  1564. else if (positionMode === 'ortho') {
  1565. // Labels will be rotated to be ortogonal to the axis
  1566. if (!axis.horiz) { // Y Axis
  1567. vecX = { x: Math.cos(beta), y: 0, z: Math.sin(beta) };
  1568. }
  1569. else { // X and Z Axis
  1570. var sina = Math.sin(alpha);
  1571. var cosa = Math.cos(alpha);
  1572. var sinb = Math.sin(beta);
  1573. var cosb = Math.cos(beta);
  1574. var vecZ = { x: sinb * cosa,
  1575. y: -sina,
  1576. z: -cosa * cosb };
  1577. vecY = {
  1578. x: vecX.y * vecZ.z - vecX.z * vecZ.y,
  1579. y: vecX.z * vecZ.x - vecX.x * vecZ.z,
  1580. z: vecX.x * vecZ.y - vecX.y * vecZ.x
  1581. };
  1582. var scale = 1 / Math.sqrt(vecY.x * vecY.x + vecY.y * vecY.y + vecY.z * vecY.z);
  1583. if (reverseFlap) {
  1584. scale = -scale;
  1585. }
  1586. vecY = { x: scale * vecY.x, y: scale * vecY.y, z: scale * vecY.z };
  1587. }
  1588. }
  1589. else { // positionMode == 'offset'
  1590. // Labels will be skewd to maintain vertical / horizontal offsets
  1591. // from axis
  1592. if (!axis.horiz) { // Y Axis
  1593. vecX = { x: Math.cos(beta), y: 0, z: Math.sin(beta) };
  1594. }
  1595. else { // X and Z Axis
  1596. vecY = {
  1597. x: Math.sin(beta) * Math.sin(alpha),
  1598. y: Math.cos(alpha),
  1599. z: -Math.cos(beta) * Math.sin(alpha)
  1600. };
  1601. }
  1602. }
  1603. pos.x += offsetX * vecX.x + offsetY * vecY.x;
  1604. pos.y += offsetX * vecX.y + offsetY * vecY.y;
  1605. pos.z += offsetX * vecX.z + offsetY * vecY.z;
  1606. var projected = perspective([pos],
  1607. axis.chart)[0];
  1608. if (skew) {
  1609. // Check if the label text would be mirrored
  1610. var isMirrored = shapeArea(perspective([
  1611. pos,
  1612. { x: pos.x + vecX.x,
  1613. y: pos.y + vecX.y,
  1614. z: pos.z + vecX.z },
  1615. { x: pos.x + vecY.x,
  1616. y: pos.y + vecY.y,
  1617. z: pos.z + vecY.z }
  1618. ],
  1619. axis.chart)) < 0;
  1620. if (isMirrored) {
  1621. vecX = { x: -vecX.x, y: -vecX.y, z: -vecX.z };
  1622. }
  1623. var pointsProjected = perspective([
  1624. { x: pos.x,
  1625. y: pos.y,
  1626. z: pos.z },
  1627. { x: pos.x + vecX.x,
  1628. y: pos.y + vecX.y,
  1629. z: pos.z + vecX.z },
  1630. { x: pos.x + vecY.x,
  1631. y: pos.y + vecY.y,
  1632. z: pos.z + vecY.z }
  1633. ],
  1634. axis.chart);
  1635. projected.matrix = [
  1636. pointsProjected[1].x - pointsProjected[0].x,
  1637. pointsProjected[1].y - pointsProjected[0].y,
  1638. pointsProjected[2].x - pointsProjected[0].x,
  1639. pointsProjected[2].y - pointsProjected[0].y,
  1640. projected.x,
  1641. projected.y
  1642. ];
  1643. projected.matrix[4] -= projected.x * projected.matrix[0] +
  1644. projected.y * projected.matrix[2];
  1645. projected.matrix[5] -= projected.x * projected.matrix[1] +
  1646. projected.y * projected.matrix[3];
  1647. }
  1648. return projected;
  1649. };
  1650. /**
  1651. * @private
  1652. */
  1653. Axis3DAdditions.prototype.swapZ = function (p, insidePlotArea) {
  1654. var axis = this.axis;
  1655. if (axis.isZAxis) {
  1656. var plotLeft = insidePlotArea ? 0 : axis.chart.plotLeft;
  1657. return {
  1658. x: plotLeft + p.z,
  1659. y: p.y,
  1660. z: p.x - plotLeft
  1661. };
  1662. }
  1663. return p;
  1664. };
  1665. return Axis3DAdditions;
  1666. }());
  1667. /**
  1668. * Axis with 3D support.
  1669. * @private
  1670. * @class
  1671. */
  1672. var Axis3D = /** @class */ (function () {
  1673. function Axis3D() {
  1674. }
  1675. /* *
  1676. *
  1677. * Static Functions
  1678. *
  1679. * */
  1680. /**
  1681. * Extends axis class with 3D support.
  1682. * @private
  1683. */
  1684. Axis3D.compose = function (AxisClass) {
  1685. merge(true, AxisClass.defaultOptions, Axis3D.defaultOptions);
  1686. AxisClass.keepProps.push('axis3D');
  1687. addEvent(AxisClass, 'init', Axis3D.onInit);
  1688. addEvent(AxisClass, 'afterSetOptions', Axis3D.onAfterSetOptions);
  1689. addEvent(AxisClass, 'drawCrosshair', Axis3D.onDrawCrosshair);
  1690. addEvent(AxisClass, 'destroy', Axis3D.onDestroy);
  1691. var axisProto = AxisClass.prototype;
  1692. wrap(axisProto, 'getLinePath', Axis3D.wrapGetLinePath);
  1693. wrap(axisProto, 'getPlotBandPath', Axis3D.wrapGetPlotBandPath);
  1694. wrap(axisProto, 'getPlotLinePath', Axis3D.wrapGetPlotLinePath);
  1695. wrap(axisProto, 'getSlotWidth', Axis3D.wrapGetSlotWidth);
  1696. wrap(axisProto, 'getTitlePosition', Axis3D.wrapGetTitlePosition);
  1697. Tick3D.compose(Tick);
  1698. };
  1699. /**
  1700. * @private
  1701. */
  1702. Axis3D.onAfterSetOptions = function () {
  1703. var axis = this;
  1704. var chart = axis.chart;
  1705. var options = axis.options;
  1706. if (chart.is3d && chart.is3d() && axis.coll !== 'colorAxis') {
  1707. options.tickWidth = pick(options.tickWidth, 0);
  1708. options.gridLineWidth = pick(options.gridLineWidth, 1);
  1709. }
  1710. };
  1711. /**
  1712. * @private
  1713. */
  1714. Axis3D.onDestroy = function () {
  1715. ['backFrame', 'bottomFrame', 'sideFrame'].forEach(function (prop) {
  1716. if (this[prop]) {
  1717. this[prop] = this[prop].destroy();
  1718. }
  1719. }, this);
  1720. };
  1721. /**
  1722. * @private
  1723. */
  1724. Axis3D.onDrawCrosshair = function (e) {
  1725. var axis = this;
  1726. if (axis.chart.is3d() &&
  1727. axis.coll !== 'colorAxis') {
  1728. if (e.point) {
  1729. e.point.crosshairPos = axis.isXAxis ?
  1730. e.point.axisXpos :
  1731. axis.len - e.point.axisYpos;
  1732. }
  1733. }
  1734. };
  1735. /**
  1736. * @private
  1737. */
  1738. Axis3D.onInit = function () {
  1739. var axis = this;
  1740. if (!axis.axis3D) {
  1741. axis.axis3D = new Axis3DAdditions(axis);
  1742. }
  1743. };
  1744. /**
  1745. * Do not draw axislines in 3D.
  1746. * @private
  1747. */
  1748. Axis3D.wrapGetLinePath = function (proceed) {
  1749. var axis = this;
  1750. // Do not do this if the chart is not 3D
  1751. if (!axis.chart.is3d() || axis.coll === 'colorAxis') {
  1752. return proceed.apply(axis, [].slice.call(arguments, 1));
  1753. }
  1754. return [];
  1755. };
  1756. /**
  1757. * @private
  1758. */
  1759. Axis3D.wrapGetPlotBandPath = function (proceed) {
  1760. // Do not do this if the chart is not 3D
  1761. if (!this.chart.is3d() || this.coll === 'colorAxis') {
  1762. return proceed.apply(this, [].slice.call(arguments, 1));
  1763. }
  1764. var args = arguments,
  1765. from = args[1],
  1766. to = args[2],
  1767. path = [],
  1768. fromPath = this.getPlotLinePath({ value: from }),
  1769. toPath = this.getPlotLinePath({ value: to });
  1770. if (fromPath && toPath) {
  1771. for (var i = 0; i < fromPath.length; i += 2) {
  1772. var fromStartSeg = fromPath[i],
  1773. fromEndSeg = fromPath[i + 1],
  1774. toStartSeg = toPath[i],
  1775. toEndSeg = toPath[i + 1];
  1776. if (fromStartSeg[0] === 'M' &&
  1777. fromEndSeg[0] === 'L' &&
  1778. toStartSeg[0] === 'M' &&
  1779. toEndSeg[0] === 'L') {
  1780. path.push(fromStartSeg, fromEndSeg, toEndSeg,
  1781. // lineTo instead of moveTo
  1782. ['L', toStartSeg[1], toStartSeg[2]], ['Z']);
  1783. }
  1784. }
  1785. }
  1786. return path;
  1787. };
  1788. /**
  1789. * @private
  1790. */
  1791. Axis3D.wrapGetPlotLinePath = function (proceed) {
  1792. var axis = this;
  1793. var axis3D = axis.axis3D;
  1794. var chart = axis.chart;
  1795. var path = proceed.apply(axis,
  1796. [].slice.call(arguments, 1));
  1797. // Do not do this if the chart is not 3D
  1798. if (axis.coll === 'colorAxis' ||
  1799. !chart.chart3d ||
  1800. !chart.is3d()) {
  1801. return path;
  1802. }
  1803. if (path === null) {
  1804. return path;
  1805. }
  1806. var options3d = chart.options.chart.options3d,
  1807. d = axis.isZAxis ? chart.plotWidth : options3d.depth,
  1808. frame = chart.chart3d.frame3d,
  1809. startSegment = path[0],
  1810. endSegment = path[1],
  1811. pArr,
  1812. pathSegments = [];
  1813. if (startSegment[0] === 'M' && endSegment[0] === 'L') {
  1814. pArr = [
  1815. axis3D.swapZ({ x: startSegment[1], y: startSegment[2], z: 0 }),
  1816. axis3D.swapZ({ x: startSegment[1], y: startSegment[2], z: d }),
  1817. axis3D.swapZ({ x: endSegment[1], y: endSegment[2], z: 0 }),
  1818. axis3D.swapZ({ x: endSegment[1], y: endSegment[2], z: d })
  1819. ];
  1820. if (!this.horiz) { // Y-Axis
  1821. if (frame.front.visible) {
  1822. pathSegments.push(pArr[0], pArr[2]);
  1823. }
  1824. if (frame.back.visible) {
  1825. pathSegments.push(pArr[1], pArr[3]);
  1826. }
  1827. if (frame.left.visible) {
  1828. pathSegments.push(pArr[0], pArr[1]);
  1829. }
  1830. if (frame.right.visible) {
  1831. pathSegments.push(pArr[2], pArr[3]);
  1832. }
  1833. }
  1834. else if (this.isZAxis) { // Z-Axis
  1835. if (frame.left.visible) {
  1836. pathSegments.push(pArr[0], pArr[2]);
  1837. }
  1838. if (frame.right.visible) {
  1839. pathSegments.push(pArr[1], pArr[3]);
  1840. }
  1841. if (frame.top.visible) {
  1842. pathSegments.push(pArr[0], pArr[1]);
  1843. }
  1844. if (frame.bottom.visible) {
  1845. pathSegments.push(pArr[2], pArr[3]);
  1846. }
  1847. }
  1848. else { // X-Axis
  1849. if (frame.front.visible) {
  1850. pathSegments.push(pArr[0], pArr[2]);
  1851. }
  1852. if (frame.back.visible) {
  1853. pathSegments.push(pArr[1], pArr[3]);
  1854. }
  1855. if (frame.top.visible) {
  1856. pathSegments.push(pArr[0], pArr[1]);
  1857. }
  1858. if (frame.bottom.visible) {
  1859. pathSegments.push(pArr[2], pArr[3]);
  1860. }
  1861. }
  1862. pathSegments = perspective(pathSegments, this.chart, false);
  1863. }
  1864. return chart.renderer.toLineSegments(pathSegments);
  1865. };
  1866. /**
  1867. * Wrap getSlotWidth function to calculate individual width value for each
  1868. * slot (#8042).
  1869. * @private
  1870. */
  1871. Axis3D.wrapGetSlotWidth = function (proceed, tick) {
  1872. var axis = this;
  1873. var chart = axis.chart;
  1874. var ticks = axis.ticks;
  1875. var gridGroup = axis.gridGroup;
  1876. if (axis.categories &&
  1877. chart.frameShapes &&
  1878. chart.is3d() &&
  1879. gridGroup &&
  1880. tick &&
  1881. tick.label) {
  1882. var firstGridLine = gridGroup.element.childNodes[0].getBBox(),
  1883. frame3DLeft = chart.frameShapes.left.getBBox(),
  1884. options3d = chart.options.chart.options3d,
  1885. origin_1 = {
  1886. x: chart.plotWidth / 2,
  1887. y: chart.plotHeight / 2,
  1888. z: options3d.depth / 2,
  1889. vd: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0)
  1890. },
  1891. labelPos = void 0,
  1892. prevLabelPos = void 0,
  1893. nextLabelPos = void 0,
  1894. slotWidth = void 0,
  1895. tickId = tick.pos,
  1896. prevTick = ticks[tickId - 1],
  1897. nextTick = ticks[tickId + 1];
  1898. // Check whether the tick is not the first one and previous tick
  1899. // exists, then calculate position of previous label.
  1900. if (tickId !== 0 && prevTick && prevTick.label && prevTick.label.xy) {
  1901. prevLabelPos = perspective3D({
  1902. x: prevTick.label.xy.x,
  1903. y: prevTick.label.xy.y,
  1904. z: null
  1905. }, origin_1, origin_1.vd);
  1906. }
  1907. // If next label position is defined, then recalculate its position
  1908. // basing on the perspective.
  1909. if (nextTick && nextTick.label && nextTick.label.xy) {
  1910. nextLabelPos = perspective3D({
  1911. x: nextTick.label.xy.x,
  1912. y: nextTick.label.xy.y,
  1913. z: null
  1914. }, origin_1, origin_1.vd);
  1915. }
  1916. labelPos = {
  1917. x: tick.label.xy.x,
  1918. y: tick.label.xy.y,
  1919. z: null
  1920. };
  1921. labelPos = perspective3D(labelPos, origin_1, origin_1.vd);
  1922. // If tick is first one, check whether next label position is
  1923. // already calculated, then return difference between the first and
  1924. // the second label. If there is no next label position calculated,
  1925. // return the difference between the first grid line and left 3d
  1926. // frame.
  1927. slotWidth = Math.abs(prevLabelPos ?
  1928. labelPos.x - prevLabelPos.x : nextLabelPos ?
  1929. nextLabelPos.x - labelPos.x :
  1930. firstGridLine.x - frame3DLeft.x);
  1931. return slotWidth;
  1932. }
  1933. return proceed.apply(axis, [].slice.call(arguments, 1));
  1934. };
  1935. /**
  1936. * @private
  1937. */
  1938. Axis3D.wrapGetTitlePosition = function (proceed) {
  1939. var pos = proceed.apply(this,
  1940. [].slice.call(arguments, 1));
  1941. return this.axis3D ?
  1942. this.axis3D.fix3dPosition(pos, true) :
  1943. pos;
  1944. };
  1945. /* *
  1946. *
  1947. * Static Properties
  1948. *
  1949. * */
  1950. /**
  1951. * @optionparent xAxis
  1952. */
  1953. Axis3D.defaultOptions = {
  1954. labels: {
  1955. /**
  1956. * Defines how the labels are be repositioned according to the 3D
  1957. * chart orientation.
  1958. *
  1959. * - `'offset'`: Maintain a fixed horizontal/vertical distance from
  1960. * the tick marks, despite the chart orientation. This is the
  1961. * backwards compatible behavior, and causes skewing of X and Z
  1962. * axes.
  1963. *
  1964. * - `'chart'`: Preserve 3D position relative to the chart. This
  1965. * looks nice, but hard to read if the text isn't forward-facing.
  1966. *
  1967. * - `'flap'`: Rotated text along the axis to compensate for the
  1968. * chart orientation. This tries to maintain text as legible as
  1969. * possible on all orientations.
  1970. *
  1971. * - `'ortho'`: Rotated text along the axis direction so that the
  1972. * labels are orthogonal to the axis. This is very similar to
  1973. * `'flap'`, but prevents skewing the labels (X and Y scaling are
  1974. * still present).
  1975. *
  1976. * @sample highcharts/3d/skewed-labels/
  1977. * Skewed labels
  1978. *
  1979. * @since 5.0.15
  1980. * @validvalue ['offset', 'chart', 'flap', 'ortho']
  1981. * @product highcharts
  1982. * @requires highcharts-3d
  1983. */
  1984. position3d: 'offset',
  1985. /**
  1986. * If enabled, the axis labels will skewed to follow the
  1987. * perspective.
  1988. *
  1989. * This will fix overlapping labels and titles, but texts become
  1990. * less legible due to the distortion.
  1991. *
  1992. * The final appearance depends heavily on `labels.position3d`.
  1993. *
  1994. * @sample highcharts/3d/skewed-labels/
  1995. * Skewed labels
  1996. *
  1997. * @since 5.0.15
  1998. * @product highcharts
  1999. * @requires highcharts-3d
  2000. */
  2001. skew3d: false
  2002. },
  2003. title: {
  2004. /**
  2005. * Defines how the title is repositioned according to the 3D chart
  2006. * orientation.
  2007. *
  2008. * - `'offset'`: Maintain a fixed horizontal/vertical distance from
  2009. * the tick marks, despite the chart orientation. This is the
  2010. * backwards compatible behavior, and causes skewing of X and Z
  2011. * axes.
  2012. *
  2013. * - `'chart'`: Preserve 3D position relative to the chart. This
  2014. * looks nice, but hard to read if the text isn't forward-facing.
  2015. *
  2016. * - `'flap'`: Rotated text along the axis to compensate for the
  2017. * chart orientation. This tries to maintain text as legible as
  2018. * possible on all orientations.
  2019. *
  2020. * - `'ortho'`: Rotated text along the axis direction so that the
  2021. * labels are orthogonal to the axis. This is very similar to
  2022. * `'flap'`, but prevents skewing the labels (X and Y scaling are
  2023. * still present).
  2024. *
  2025. * - `undefined`: Will use the config from `labels.position3d`
  2026. *
  2027. * @sample highcharts/3d/skewed-labels/
  2028. * Skewed labels
  2029. *
  2030. * @type {"offset"|"chart"|"flap"|"ortho"|null}
  2031. * @since 5.0.15
  2032. * @product highcharts
  2033. * @requires highcharts-3d
  2034. */
  2035. position3d: null,
  2036. /**
  2037. * If enabled, the axis title will skewed to follow the perspective.
  2038. *
  2039. * This will fix overlapping labels and titles, but texts become
  2040. * less legible due to the distortion.
  2041. *
  2042. * The final appearance depends heavily on `title.position3d`.
  2043. *
  2044. * A `null` value will use the config from `labels.skew3d`.
  2045. *
  2046. * @sample highcharts/3d/skewed-labels/
  2047. * Skewed labels
  2048. *
  2049. * @type {boolean|null}
  2050. * @since 5.0.15
  2051. * @product highcharts
  2052. * @requires highcharts-3d
  2053. */
  2054. skew3d: null
  2055. }
  2056. };
  2057. return Axis3D;
  2058. }());
  2059. return Axis3D;
  2060. });
  2061. _registerModule(_modules, 'Core/Axis/ZAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  2062. /* *
  2063. *
  2064. * (c) 2010-2021 Torstein Honsi
  2065. *
  2066. * License: www.highcharts.com/license
  2067. *
  2068. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2069. *
  2070. * */
  2071. var __extends = (this && this.__extends) || (function () {
  2072. var extendStatics = function (d,
  2073. b) {
  2074. extendStatics = Object.setPrototypeOf ||
  2075. ({ __proto__: [] } instanceof Array && function (d,
  2076. b) { d.__proto__ = b; }) ||
  2077. function (d,
  2078. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2079. return extendStatics(d, b);
  2080. };
  2081. return function (d, b) {
  2082. extendStatics(d, b);
  2083. function __() { this.constructor = d; }
  2084. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2085. };
  2086. })();
  2087. var addEvent = U.addEvent,
  2088. merge = U.merge,
  2089. pick = U.pick,
  2090. splat = U.splat;
  2091. /* eslint-disable valid-jsdoc */
  2092. /**
  2093. * 3D chart with support of z coordinates.
  2094. * @private
  2095. * @class
  2096. */
  2097. var ZChart = /** @class */ (function () {
  2098. function ZChart() {
  2099. }
  2100. /* *
  2101. *
  2102. * Static Functions
  2103. *
  2104. * */
  2105. ZChart.compose = function (ChartClass) {
  2106. addEvent(ChartClass, 'afterGetAxes', ZChart.onAfterGetAxes);
  2107. var chartProto = ChartClass.prototype;
  2108. chartProto.addZAxis = ZChart.wrapAddZAxis;
  2109. chartProto.collectionsWithInit.zAxis = [chartProto.addZAxis];
  2110. chartProto.collectionsWithUpdate.push('zAxis');
  2111. };
  2112. /**
  2113. * Get the Z axis in addition to the default X and Y.
  2114. * @private
  2115. */
  2116. ZChart.onAfterGetAxes = function () {
  2117. var chart = this;
  2118. var options = this.options;
  2119. var zAxisOptions = options.zAxis = splat(options.zAxis || {});
  2120. if (!chart.is3d()) {
  2121. return;
  2122. }
  2123. chart.zAxis = [];
  2124. zAxisOptions.forEach(function (axisOptions, i) {
  2125. axisOptions.index = i;
  2126. // Z-Axis is shown horizontally, so it's kind of a X-Axis
  2127. axisOptions.isX = true;
  2128. chart
  2129. .addZAxis(axisOptions)
  2130. .setScale();
  2131. });
  2132. };
  2133. /**
  2134. * @private
  2135. */
  2136. ZChart.wrapAddZAxis = function (options) {
  2137. return new ZAxis(this, options);
  2138. };
  2139. return ZChart;
  2140. }());
  2141. /**
  2142. * 3D axis for z coordinates.
  2143. */
  2144. var ZAxis = /** @class */ (function (_super) {
  2145. __extends(ZAxis, _super);
  2146. /* *
  2147. *
  2148. * Constructors
  2149. *
  2150. * */
  2151. function ZAxis(chart, userOptions) {
  2152. var _this = _super.call(this,
  2153. chart,
  2154. userOptions) || this;
  2155. _this.isZAxis = true;
  2156. return _this;
  2157. }
  2158. /* *
  2159. *
  2160. * Functions
  2161. *
  2162. * */
  2163. ZAxis.prototype.getSeriesExtremes = function () {
  2164. var axis = this;
  2165. var chart = axis.chart;
  2166. axis.hasVisibleSeries = false;
  2167. // Reset properties in case we're redrawing (#3353)
  2168. axis.dataMin = axis.dataMax = axis.ignoreMinPadding = axis.ignoreMaxPadding = void 0;
  2169. if (axis.stacking) {
  2170. axis.stacking.buildStacks();
  2171. }
  2172. // loop through this axis' series
  2173. axis.series.forEach(function (series) {
  2174. if (series.visible ||
  2175. !chart.options.chart.ignoreHiddenSeries) {
  2176. var seriesOptions = series.options,
  2177. zData = void 0,
  2178. threshold = seriesOptions.threshold;
  2179. axis.hasVisibleSeries = true;
  2180. // Validate threshold in logarithmic axes
  2181. if (axis.positiveValuesOnly && threshold <= 0) {
  2182. threshold = void 0;
  2183. }
  2184. zData = series.zData;
  2185. if (zData.length) {
  2186. axis.dataMin = Math.min(pick(axis.dataMin, zData[0]), Math.min.apply(null, zData));
  2187. axis.dataMax = Math.max(pick(axis.dataMax, zData[0]), Math.max.apply(null, zData));
  2188. }
  2189. }
  2190. });
  2191. };
  2192. /**
  2193. * @private
  2194. */
  2195. ZAxis.prototype.setAxisSize = function () {
  2196. var axis = this;
  2197. var chart = axis.chart;
  2198. _super.prototype.setAxisSize.call(this);
  2199. axis.width = axis.len = (chart.options.chart.options3d &&
  2200. chart.options.chart.options3d.depth) || 0;
  2201. axis.right = chart.chartWidth - axis.width - axis.left;
  2202. };
  2203. /**
  2204. * @private
  2205. */
  2206. ZAxis.prototype.setOptions = function (userOptions) {
  2207. userOptions = merge({
  2208. offset: 0,
  2209. lineWidth: 0
  2210. }, userOptions);
  2211. // #14793, this used to be set on the prototype
  2212. this.isZAxis = true;
  2213. _super.prototype.setOptions.call(this, userOptions);
  2214. this.coll = 'zAxis';
  2215. };
  2216. /* *
  2217. *
  2218. * Static Properties
  2219. *
  2220. * */
  2221. ZAxis.ZChartComposition = ZChart;
  2222. return ZAxis;
  2223. }(Axis));
  2224. return ZAxis;
  2225. });
  2226. _registerModule(_modules, 'Core/Chart/Chart3D.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Axis/Axis3D.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Globals.js'], _modules['Extensions/Math3D.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js'], _modules['Core/Axis/ZAxis.js']], function (Axis, Axis3D, Chart, Fx, H, Math3D, O, U, ZAxis) {
  2227. /* *
  2228. *
  2229. * (c) 2010-2021 Torstein Honsi
  2230. *
  2231. * Extension for 3D charts
  2232. *
  2233. * License: www.highcharts.com/license
  2234. *
  2235. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2236. *
  2237. * */
  2238. var perspective = Math3D.perspective,
  2239. shapeArea3D = Math3D.shapeArea3D;
  2240. var genericDefaultOptions = O.defaultOptions;
  2241. var addEvent = U.addEvent,
  2242. isArray = U.isArray,
  2243. merge = U.merge,
  2244. pick = U.pick,
  2245. wrap = U.wrap;
  2246. var Chart3D;
  2247. (function (Chart3D) {
  2248. /* *
  2249. *
  2250. * Interfaces
  2251. *
  2252. * */
  2253. /* *
  2254. *
  2255. * Classes
  2256. *
  2257. * */
  2258. var Composition = /** @class */ (function () {
  2259. /* *
  2260. *
  2261. * Constructors
  2262. *
  2263. * */
  2264. /**
  2265. * @private
  2266. */
  2267. function Composition(chart) {
  2268. this.frame3d = void 0;
  2269. this.chart = chart;
  2270. }
  2271. /* *
  2272. *
  2273. * Functions
  2274. *
  2275. * */
  2276. Composition.prototype.get3dFrame = function () {
  2277. var chart = this.chart,
  2278. options3d = chart.options.chart.options3d,
  2279. frameOptions = options3d.frame,
  2280. xm = chart.plotLeft,
  2281. xp = chart.plotLeft + chart.plotWidth,
  2282. ym = chart.plotTop,
  2283. yp = chart.plotTop + chart.plotHeight,
  2284. zm = 0,
  2285. zp = options3d.depth,
  2286. faceOrientation = function (vertexes) {
  2287. var area = shapeArea3D(vertexes,
  2288. chart);
  2289. // Give it 0.5 squared-pixel as a margin for rounding errors
  2290. if (area > 0.5) {
  2291. return 1;
  2292. }
  2293. if (area < -0.5) {
  2294. return -1;
  2295. }
  2296. return 0;
  2297. }, bottomOrientation = faceOrientation([
  2298. { x: xm, y: yp, z: zp },
  2299. { x: xp, y: yp, z: zp },
  2300. { x: xp, y: yp, z: zm },
  2301. { x: xm, y: yp, z: zm }
  2302. ]), topOrientation = faceOrientation([
  2303. { x: xm, y: ym, z: zm },
  2304. { x: xp, y: ym, z: zm },
  2305. { x: xp, y: ym, z: zp },
  2306. { x: xm, y: ym, z: zp }
  2307. ]), leftOrientation = faceOrientation([
  2308. { x: xm, y: ym, z: zm },
  2309. { x: xm, y: ym, z: zp },
  2310. { x: xm, y: yp, z: zp },
  2311. { x: xm, y: yp, z: zm }
  2312. ]), rightOrientation = faceOrientation([
  2313. { x: xp, y: ym, z: zp },
  2314. { x: xp, y: ym, z: zm },
  2315. { x: xp, y: yp, z: zm },
  2316. { x: xp, y: yp, z: zp }
  2317. ]), frontOrientation = faceOrientation([
  2318. { x: xm, y: yp, z: zm },
  2319. { x: xp, y: yp, z: zm },
  2320. { x: xp, y: ym, z: zm },
  2321. { x: xm, y: ym, z: zm }
  2322. ]), backOrientation = faceOrientation([
  2323. { x: xm, y: ym, z: zp },
  2324. { x: xp, y: ym, z: zp },
  2325. { x: xp, y: yp, z: zp },
  2326. { x: xm, y: yp, z: zp }
  2327. ]), defaultShowBottom = false, defaultShowTop = false, defaultShowLeft = false, defaultShowRight = false, defaultShowFront = false, defaultShowBack = true;
  2328. // The 'default' criteria to visible faces of the frame is looking
  2329. // up every axis to decide whenever the left/right//top/bottom sides
  2330. // of the frame will be shown
  2331. []
  2332. .concat(chart.xAxis, chart.yAxis, chart.zAxis)
  2333. .forEach(function (axis) {
  2334. if (axis) {
  2335. if (axis.horiz) {
  2336. if (axis.opposite) {
  2337. defaultShowTop = true;
  2338. }
  2339. else {
  2340. defaultShowBottom = true;
  2341. }
  2342. }
  2343. else {
  2344. if (axis.opposite) {
  2345. defaultShowRight = true;
  2346. }
  2347. else {
  2348. defaultShowLeft = true;
  2349. }
  2350. }
  2351. }
  2352. });
  2353. var getFaceOptions = function (sources, faceOrientation, defaultVisible) {
  2354. var faceAttrs = ['size', 'color', 'visible'];
  2355. var options = {};
  2356. for (var i = 0; i < faceAttrs.length; i++) {
  2357. var attr = faceAttrs[i];
  2358. for (var j = 0; j < sources.length; j++) {
  2359. if (typeof sources[j] === 'object') {
  2360. var val = sources[j][attr];
  2361. if (typeof val !== 'undefined' && val !== null) {
  2362. options[attr] = val;
  2363. break;
  2364. }
  2365. }
  2366. }
  2367. }
  2368. var isVisible = defaultVisible;
  2369. if (options.visible === true || options.visible === false) {
  2370. isVisible = options.visible;
  2371. }
  2372. else if (options.visible === 'auto') {
  2373. isVisible = faceOrientation > 0;
  2374. }
  2375. return {
  2376. size: pick(options.size, 1),
  2377. color: pick(options.color, 'none'),
  2378. frontFacing: faceOrientation > 0,
  2379. visible: isVisible
  2380. };
  2381. };
  2382. // docs @TODO: Add all frame options (left, right, top, bottom,
  2383. // front, back) to apioptions JSDoc once the new system is up.
  2384. var ret = {
  2385. axes: {},
  2386. // FIXME: Previously, left/right, top/bottom and front/back
  2387. // pairs shared size and color.
  2388. // For compatibility and consistency sake, when one face have
  2389. // size/color/visibility set, the opposite face will default to
  2390. // the same values. Also, left/right used to be called 'side',
  2391. // so that's also added as a fallback.
  2392. bottom: getFaceOptions([frameOptions.bottom,
  2393. frameOptions.top,
  2394. frameOptions],
  2395. bottomOrientation,
  2396. defaultShowBottom),
  2397. top: getFaceOptions([frameOptions.top,
  2398. frameOptions.bottom,
  2399. frameOptions],
  2400. topOrientation,
  2401. defaultShowTop),
  2402. left: getFaceOptions([
  2403. frameOptions.left,
  2404. frameOptions.right,
  2405. frameOptions.side,
  2406. frameOptions
  2407. ],
  2408. leftOrientation,
  2409. defaultShowLeft),
  2410. right: getFaceOptions([
  2411. frameOptions.right,
  2412. frameOptions.left,
  2413. frameOptions.side,
  2414. frameOptions
  2415. ],
  2416. rightOrientation,
  2417. defaultShowRight),
  2418. back: getFaceOptions([frameOptions.back,
  2419. frameOptions.front,
  2420. frameOptions],
  2421. backOrientation,
  2422. defaultShowBack),
  2423. front: getFaceOptions([frameOptions.front,
  2424. frameOptions.back,
  2425. frameOptions],
  2426. frontOrientation,
  2427. defaultShowFront)
  2428. };
  2429. // Decide the bast place to put axis title/labels based on the
  2430. // visible faces. Ideally, The labels can only be on the edge
  2431. // between a visible face and an invisble one. Also, the Y label
  2432. // should be one the left-most edge (right-most if opposite).
  2433. if (options3d.axisLabelPosition === 'auto') {
  2434. var isValidEdge = function (face1,
  2435. face2) {
  2436. return ((face1.visible !== face2.visible) ||
  2437. (face1.visible &&
  2438. face2.visible &&
  2439. (face1.frontFacing !== face2.frontFacing)));
  2440. };
  2441. var yEdges = [];
  2442. if (isValidEdge(ret.left, ret.front)) {
  2443. yEdges.push({
  2444. y: (ym + yp) / 2,
  2445. x: xm,
  2446. z: zm,
  2447. xDir: { x: 1, y: 0, z: 0 }
  2448. });
  2449. }
  2450. if (isValidEdge(ret.left, ret.back)) {
  2451. yEdges.push({
  2452. y: (ym + yp) / 2,
  2453. x: xm,
  2454. z: zp,
  2455. xDir: { x: 0, y: 0, z: -1 }
  2456. });
  2457. }
  2458. if (isValidEdge(ret.right, ret.front)) {
  2459. yEdges.push({
  2460. y: (ym + yp) / 2,
  2461. x: xp,
  2462. z: zm,
  2463. xDir: { x: 0, y: 0, z: 1 }
  2464. });
  2465. }
  2466. if (isValidEdge(ret.right, ret.back)) {
  2467. yEdges.push({
  2468. y: (ym + yp) / 2,
  2469. x: xp,
  2470. z: zp,
  2471. xDir: { x: -1, y: 0, z: 0 }
  2472. });
  2473. }
  2474. var xBottomEdges = [];
  2475. if (isValidEdge(ret.bottom, ret.front)) {
  2476. xBottomEdges.push({
  2477. x: (xm + xp) / 2,
  2478. y: yp,
  2479. z: zm,
  2480. xDir: { x: 1, y: 0, z: 0 }
  2481. });
  2482. }
  2483. if (isValidEdge(ret.bottom, ret.back)) {
  2484. xBottomEdges.push({
  2485. x: (xm + xp) / 2,
  2486. y: yp,
  2487. z: zp,
  2488. xDir: { x: -1, y: 0, z: 0 }
  2489. });
  2490. }
  2491. var xTopEdges = [];
  2492. if (isValidEdge(ret.top, ret.front)) {
  2493. xTopEdges.push({
  2494. x: (xm + xp) / 2,
  2495. y: ym,
  2496. z: zm,
  2497. xDir: { x: 1, y: 0, z: 0 }
  2498. });
  2499. }
  2500. if (isValidEdge(ret.top, ret.back)) {
  2501. xTopEdges.push({
  2502. x: (xm + xp) / 2,
  2503. y: ym,
  2504. z: zp,
  2505. xDir: { x: -1, y: 0, z: 0 }
  2506. });
  2507. }
  2508. var zBottomEdges = [];
  2509. if (isValidEdge(ret.bottom, ret.left)) {
  2510. zBottomEdges.push({
  2511. z: (zm + zp) / 2,
  2512. y: yp,
  2513. x: xm,
  2514. xDir: { x: 0, y: 0, z: -1 }
  2515. });
  2516. }
  2517. if (isValidEdge(ret.bottom, ret.right)) {
  2518. zBottomEdges.push({
  2519. z: (zm + zp) / 2,
  2520. y: yp,
  2521. x: xp,
  2522. xDir: { x: 0, y: 0, z: 1 }
  2523. });
  2524. }
  2525. var zTopEdges = [];
  2526. if (isValidEdge(ret.top, ret.left)) {
  2527. zTopEdges.push({
  2528. z: (zm + zp) / 2,
  2529. y: ym,
  2530. x: xm,
  2531. xDir: { x: 0, y: 0, z: -1 }
  2532. });
  2533. }
  2534. if (isValidEdge(ret.top, ret.right)) {
  2535. zTopEdges.push({
  2536. z: (zm + zp) / 2,
  2537. y: ym,
  2538. x: xp,
  2539. xDir: { x: 0, y: 0, z: 1 }
  2540. });
  2541. }
  2542. var pickEdge = function (edges,
  2543. axis,
  2544. mult) {
  2545. if (edges.length === 0) {
  2546. return null;
  2547. }
  2548. if (edges.length === 1) {
  2549. return edges[0];
  2550. }
  2551. var best = 0,
  2552. projections = perspective(edges,
  2553. chart,
  2554. false);
  2555. for (var i = 1; i < projections.length; i++) {
  2556. if (mult * projections[i][axis] >
  2557. mult * projections[best][axis]) {
  2558. best = i;
  2559. }
  2560. else if ((mult * projections[i][axis] ===
  2561. mult * projections[best][axis]) &&
  2562. (projections[i].z < projections[best].z)) {
  2563. best = i;
  2564. }
  2565. }
  2566. return edges[best];
  2567. };
  2568. ret.axes = {
  2569. y: {
  2570. 'left': pickEdge(yEdges, 'x', -1),
  2571. 'right': pickEdge(yEdges, 'x', +1)
  2572. },
  2573. x: {
  2574. 'top': pickEdge(xTopEdges, 'y', -1),
  2575. 'bottom': pickEdge(xBottomEdges, 'y', +1)
  2576. },
  2577. z: {
  2578. 'top': pickEdge(zTopEdges, 'y', -1),
  2579. 'bottom': pickEdge(zBottomEdges, 'y', +1)
  2580. }
  2581. };
  2582. }
  2583. else {
  2584. ret.axes = {
  2585. y: {
  2586. 'left': { x: xm, z: zm, xDir: { x: 1, y: 0, z: 0 } },
  2587. 'right': { x: xp, z: zm, xDir: { x: 0, y: 0, z: 1 } }
  2588. },
  2589. x: {
  2590. 'top': { y: ym, z: zm, xDir: { x: 1, y: 0, z: 0 } },
  2591. 'bottom': { y: yp, z: zm, xDir: { x: 1, y: 0, z: 0 } }
  2592. },
  2593. z: {
  2594. 'top': {
  2595. x: defaultShowLeft ? xp : xm,
  2596. y: ym,
  2597. xDir: defaultShowLeft ?
  2598. { x: 0, y: 0, z: 1 } :
  2599. { x: 0, y: 0, z: -1 }
  2600. },
  2601. 'bottom': {
  2602. x: defaultShowLeft ? xp : xm,
  2603. y: yp,
  2604. xDir: defaultShowLeft ?
  2605. { x: 0, y: 0, z: 1 } :
  2606. { x: 0, y: 0, z: -1 }
  2607. }
  2608. }
  2609. };
  2610. }
  2611. return ret;
  2612. };
  2613. /**
  2614. * Calculate scale of the 3D view. That is required to fit chart's 3D
  2615. * projection into the actual plotting area. Reported as #4933.
  2616. *
  2617. * @notice
  2618. * This function should ideally take the plot values instead of a chart
  2619. * object, but since the chart object is needed for perspective it is
  2620. * not practical. Possible to make both getScale and perspective more
  2621. * logical and also immutable.
  2622. *
  2623. * @private
  2624. * @function getScale
  2625. *
  2626. * @param {number} depth
  2627. * The depth of the chart
  2628. *
  2629. * @return {number}
  2630. * The scale to fit the 3D chart into the plotting area.
  2631. *
  2632. * @requires highcharts-3d
  2633. */
  2634. Composition.prototype.getScale = function (depth) {
  2635. var chart = this.chart,
  2636. plotLeft = chart.plotLeft,
  2637. plotRight = chart.plotWidth + plotLeft,
  2638. plotTop = chart.plotTop,
  2639. plotBottom = chart.plotHeight + plotTop,
  2640. originX = plotLeft + chart.plotWidth / 2,
  2641. originY = plotTop + chart.plotHeight / 2,
  2642. bbox3d = {
  2643. minX: Number.MAX_VALUE,
  2644. maxX: -Number.MAX_VALUE,
  2645. minY: Number.MAX_VALUE,
  2646. maxY: -Number.MAX_VALUE
  2647. },
  2648. corners,
  2649. scale = 1;
  2650. // Top left corners:
  2651. corners = [{
  2652. x: plotLeft,
  2653. y: plotTop,
  2654. z: 0
  2655. }, {
  2656. x: plotLeft,
  2657. y: plotTop,
  2658. z: depth
  2659. }];
  2660. // Top right corners:
  2661. [0, 1].forEach(function (i) {
  2662. corners.push({
  2663. x: plotRight,
  2664. y: corners[i].y,
  2665. z: corners[i].z
  2666. });
  2667. });
  2668. // All bottom corners:
  2669. [0, 1, 2, 3].forEach(function (i) {
  2670. corners.push({
  2671. x: corners[i].x,
  2672. y: plotBottom,
  2673. z: corners[i].z
  2674. });
  2675. });
  2676. // Calculate 3D corners:
  2677. corners = perspective(corners, chart, false);
  2678. // Get bounding box of 3D element:
  2679. corners.forEach(function (corner) {
  2680. bbox3d.minX = Math.min(bbox3d.minX, corner.x);
  2681. bbox3d.maxX = Math.max(bbox3d.maxX, corner.x);
  2682. bbox3d.minY = Math.min(bbox3d.minY, corner.y);
  2683. bbox3d.maxY = Math.max(bbox3d.maxY, corner.y);
  2684. });
  2685. // Left edge:
  2686. if (plotLeft > bbox3d.minX) {
  2687. scale = Math.min(scale, 1 - Math.abs((plotLeft + originX) / (bbox3d.minX + originX)) % 1);
  2688. }
  2689. // Right edge:
  2690. if (plotRight < bbox3d.maxX) {
  2691. scale = Math.min(scale, (plotRight - originX) / (bbox3d.maxX - originX));
  2692. }
  2693. // Top edge:
  2694. if (plotTop > bbox3d.minY) {
  2695. if (bbox3d.minY < 0) {
  2696. scale = Math.min(scale, (plotTop + originY) / (-bbox3d.minY + plotTop + originY));
  2697. }
  2698. else {
  2699. scale = Math.min(scale, 1 - (plotTop + originY) / (bbox3d.minY + originY) % 1);
  2700. }
  2701. }
  2702. // Bottom edge:
  2703. if (plotBottom < bbox3d.maxY) {
  2704. scale = Math.min(scale, Math.abs((plotBottom - originY) / (bbox3d.maxY - originY)));
  2705. }
  2706. return scale;
  2707. };
  2708. return Composition;
  2709. }());
  2710. Chart3D.Composition = Composition;
  2711. /* *
  2712. *
  2713. * Constants
  2714. *
  2715. * */
  2716. /**
  2717. * @optionparent
  2718. * @private
  2719. */
  2720. Chart3D.defaultOptions = {
  2721. chart: {
  2722. /**
  2723. * Options to render charts in 3 dimensions. This feature requires
  2724. * `highcharts-3d.js`, found in the download package or online at
  2725. * [code.highcharts.com/highcharts-3d.js](https://code.highcharts.com/highcharts-3d.js).
  2726. *
  2727. * @since 4.0
  2728. * @product highcharts
  2729. * @requires highcharts-3d
  2730. */
  2731. options3d: {
  2732. /**
  2733. * Wether to render the chart using the 3D functionality.
  2734. *
  2735. * @since 4.0
  2736. * @product highcharts
  2737. */
  2738. enabled: false,
  2739. /**
  2740. * One of the two rotation angles for the chart.
  2741. *
  2742. * @since 4.0
  2743. * @product highcharts
  2744. */
  2745. alpha: 0,
  2746. /**
  2747. * One of the two rotation angles for the chart.
  2748. *
  2749. * @since 4.0
  2750. * @product highcharts
  2751. */
  2752. beta: 0,
  2753. /**
  2754. * The total depth of the chart.
  2755. *
  2756. * @since 4.0
  2757. * @product highcharts
  2758. */
  2759. depth: 100,
  2760. /**
  2761. * Whether the 3d box should automatically adjust to the chart
  2762. * plot area.
  2763. *
  2764. * @since 4.2.4
  2765. * @product highcharts
  2766. */
  2767. fitToPlot: true,
  2768. /**
  2769. * Defines the distance the viewer is standing in front of the
  2770. * chart, this setting is important to calculate the perspective
  2771. * effect in column and scatter charts. It is not used for 3D
  2772. * pie charts.
  2773. *
  2774. * @since 4.0
  2775. * @product highcharts
  2776. */
  2777. viewDistance: 25,
  2778. /**
  2779. * Set it to `"auto"` to automatically move the labels to the
  2780. * best edge.
  2781. *
  2782. * @type {"auto"|null}
  2783. * @since 5.0.12
  2784. * @product highcharts
  2785. */
  2786. axisLabelPosition: null,
  2787. /**
  2788. * Provides the option to draw a frame around the charts by
  2789. * defining a bottom, front and back panel.
  2790. *
  2791. * @since 4.0
  2792. * @product highcharts
  2793. * @requires highcharts-3d
  2794. */
  2795. frame: {
  2796. /**
  2797. * Whether the frames are visible.
  2798. */
  2799. visible: 'default',
  2800. /**
  2801. * General pixel thickness for the frame faces.
  2802. */
  2803. size: 1,
  2804. /**
  2805. * The bottom of the frame around a 3D chart.
  2806. *
  2807. * @since 4.0
  2808. * @product highcharts
  2809. * @requires highcharts-3d
  2810. */
  2811. /**
  2812. * The color of the panel.
  2813. *
  2814. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2815. * @default transparent
  2816. * @since 4.0
  2817. * @product highcharts
  2818. * @apioption chart.options3d.frame.bottom.color
  2819. */
  2820. /**
  2821. * The thickness of the panel.
  2822. *
  2823. * @type {number}
  2824. * @default 1
  2825. * @since 4.0
  2826. * @product highcharts
  2827. * @apioption chart.options3d.frame.bottom.size
  2828. */
  2829. /**
  2830. * Whether to display the frame. Possible values are `true`,
  2831. * `false`, `"auto"` to display only the frames behind the
  2832. * data, and `"default"` to display faces behind the data
  2833. * based on the axis layout, ignoring the point of view.
  2834. *
  2835. * @sample {highcharts} highcharts/3d/scatter-frame/
  2836. * Auto frames
  2837. *
  2838. * @type {boolean|"default"|"auto"}
  2839. * @default default
  2840. * @since 5.0.12
  2841. * @product highcharts
  2842. * @apioption chart.options3d.frame.bottom.visible
  2843. */
  2844. /**
  2845. * The bottom of the frame around a 3D chart.
  2846. */
  2847. bottom: {},
  2848. /**
  2849. * The top of the frame around a 3D chart.
  2850. *
  2851. * @extends chart.options3d.frame.bottom
  2852. */
  2853. top: {},
  2854. /**
  2855. * The left side of the frame around a 3D chart.
  2856. *
  2857. * @extends chart.options3d.frame.bottom
  2858. */
  2859. left: {},
  2860. /**
  2861. * The right of the frame around a 3D chart.
  2862. *
  2863. * @extends chart.options3d.frame.bottom
  2864. */
  2865. right: {},
  2866. /**
  2867. * The back side of the frame around a 3D chart.
  2868. *
  2869. * @extends chart.options3d.frame.bottom
  2870. */
  2871. back: {},
  2872. /**
  2873. * The front of the frame around a 3D chart.
  2874. *
  2875. * @extends chart.options3d.frame.bottom
  2876. */
  2877. front: {}
  2878. }
  2879. }
  2880. }
  2881. };
  2882. /* *
  2883. *
  2884. * Functions
  2885. *
  2886. * */
  2887. /**
  2888. * @private
  2889. */
  2890. function compose(ChartClass, FxClass) {
  2891. var chartProto = ChartClass.prototype;
  2892. var fxProto = FxClass.prototype;
  2893. /**
  2894. * Shorthand to check the is3d flag.
  2895. * @private
  2896. * @return {boolean}
  2897. * Whether it is a 3D chart.
  2898. */
  2899. chartProto.is3d = function () {
  2900. return Boolean(this.options.chart.options3d &&
  2901. this.options.chart.options3d.enabled); // #4280
  2902. };
  2903. chartProto.propsRequireDirtyBox.push('chart.options3d');
  2904. chartProto.propsRequireUpdateSeries.push('chart.options3d');
  2905. /**
  2906. * Animation setter for matrix property.
  2907. * @private
  2908. */
  2909. fxProto.matrixSetter = function () {
  2910. var interpolated;
  2911. if (this.pos < 1 &&
  2912. (isArray(this.start) || isArray(this.end))) {
  2913. var start = this.start || [1, 0, 0, 1, 0, 0];
  2914. var end = this.end || [1, 0, 0, 1, 0, 0];
  2915. interpolated = [];
  2916. for (var i = 0; i < 6; i++) {
  2917. interpolated.push(this.pos * end[i] + (1 - this.pos) * start[i]);
  2918. }
  2919. }
  2920. else {
  2921. interpolated = this.end;
  2922. }
  2923. this.elem.attr(this.prop, interpolated, null, true);
  2924. };
  2925. merge(true, genericDefaultOptions, Chart3D.defaultOptions);
  2926. addEvent(ChartClass, 'init', onInit);
  2927. addEvent(ChartClass, 'addSeries', onAddSeries);
  2928. addEvent(ChartClass, 'afterDrawChartBox', onAfterDrawChartBox);
  2929. addEvent(ChartClass, 'afterGetContainer', onAfterGetContainer);
  2930. addEvent(ChartClass, 'afterInit', onAfterInit);
  2931. addEvent(ChartClass, 'afterSetChartSize', onAfterSetChartSize);
  2932. addEvent(ChartClass, 'beforeRedraw', onBeforeRedraw);
  2933. addEvent(ChartClass, 'beforeRender', onBeforeRender);
  2934. wrap(H.Chart.prototype, 'isInsidePlot', wrapIsInsidePlot);
  2935. wrap(ChartClass, 'renderSeries', wrapRenderSeries);
  2936. wrap(ChartClass, 'setClassName', wrapSetClassName);
  2937. }
  2938. Chart3D.compose = compose;
  2939. /**
  2940. * Legacy support for HC < 6 to make 'scatter' series in a 3D chart route to
  2941. * the real 'scatter3d' series type. (#8407)
  2942. * @private
  2943. */
  2944. function onAddSeries(e) {
  2945. if (this.is3d()) {
  2946. if (e.options.type === 'scatter') {
  2947. e.options.type = 'scatter3d';
  2948. }
  2949. }
  2950. }
  2951. /**
  2952. * @private
  2953. */
  2954. function onAfterDrawChartBox() {
  2955. if (this.chart3d &&
  2956. this.is3d()) {
  2957. var chart = this,
  2958. renderer = chart.renderer,
  2959. options3d = this.options.chart.options3d,
  2960. frame = this.chart3d.get3dFrame(),
  2961. xm = this.plotLeft,
  2962. xp = this.plotLeft + this.plotWidth,
  2963. ym = this.plotTop,
  2964. yp = this.plotTop + this.plotHeight,
  2965. zm = 0,
  2966. zp = options3d.depth,
  2967. xmm = xm - (frame.left.visible ? frame.left.size : 0),
  2968. xpp = xp + (frame.right.visible ? frame.right.size : 0),
  2969. ymm = ym - (frame.top.visible ? frame.top.size : 0),
  2970. ypp = yp + (frame.bottom.visible ? frame.bottom.size : 0),
  2971. zmm = zm - (frame.front.visible ? frame.front.size : 0),
  2972. zpp = zp + (frame.back.visible ? frame.back.size : 0),
  2973. verb = chart.hasRendered ? 'animate' : 'attr';
  2974. this.chart3d.frame3d = frame;
  2975. if (!this.frameShapes) {
  2976. this.frameShapes = {
  2977. bottom: renderer.polyhedron().add(),
  2978. top: renderer.polyhedron().add(),
  2979. left: renderer.polyhedron().add(),
  2980. right: renderer.polyhedron().add(),
  2981. back: renderer.polyhedron().add(),
  2982. front: renderer.polyhedron().add()
  2983. };
  2984. }
  2985. this.frameShapes.bottom[verb]({
  2986. 'class': 'highcharts-3d-frame highcharts-3d-frame-bottom',
  2987. zIndex: frame.bottom.frontFacing ? -1000 : 1000,
  2988. faces: [{
  2989. fill: H.color(frame.bottom.color).brighten(0.1).get(),
  2990. vertexes: [{
  2991. x: xmm,
  2992. y: ypp,
  2993. z: zmm
  2994. }, {
  2995. x: xpp,
  2996. y: ypp,
  2997. z: zmm
  2998. }, {
  2999. x: xpp,
  3000. y: ypp,
  3001. z: zpp
  3002. }, {
  3003. x: xmm,
  3004. y: ypp,
  3005. z: zpp
  3006. }],
  3007. enabled: frame.bottom.visible
  3008. },
  3009. {
  3010. fill: H.color(frame.bottom.color).brighten(0.1).get(),
  3011. vertexes: [{
  3012. x: xm,
  3013. y: yp,
  3014. z: zp
  3015. }, {
  3016. x: xp,
  3017. y: yp,
  3018. z: zp
  3019. }, {
  3020. x: xp,
  3021. y: yp,
  3022. z: zm
  3023. }, {
  3024. x: xm,
  3025. y: yp,
  3026. z: zm
  3027. }],
  3028. enabled: frame.bottom.visible
  3029. },
  3030. {
  3031. fill: H.color(frame.bottom.color).brighten(-0.1).get(),
  3032. vertexes: [{
  3033. x: xmm,
  3034. y: ypp,
  3035. z: zmm
  3036. }, {
  3037. x: xmm,
  3038. y: ypp,
  3039. z: zpp
  3040. }, {
  3041. x: xm,
  3042. y: yp,
  3043. z: zp
  3044. }, {
  3045. x: xm,
  3046. y: yp,
  3047. z: zm
  3048. }],
  3049. enabled: frame.bottom.visible && !frame.left.visible
  3050. },
  3051. {
  3052. fill: H.color(frame.bottom.color).brighten(-0.1).get(),
  3053. vertexes: [{
  3054. x: xpp,
  3055. y: ypp,
  3056. z: zpp
  3057. }, {
  3058. x: xpp,
  3059. y: ypp,
  3060. z: zmm
  3061. }, {
  3062. x: xp,
  3063. y: yp,
  3064. z: zm
  3065. }, {
  3066. x: xp,
  3067. y: yp,
  3068. z: zp
  3069. }],
  3070. enabled: frame.bottom.visible && !frame.right.visible
  3071. },
  3072. {
  3073. fill: H.color(frame.bottom.color).get(),
  3074. vertexes: [{
  3075. x: xpp,
  3076. y: ypp,
  3077. z: zmm
  3078. }, {
  3079. x: xmm,
  3080. y: ypp,
  3081. z: zmm
  3082. }, {
  3083. x: xm,
  3084. y: yp,
  3085. z: zm
  3086. }, {
  3087. x: xp,
  3088. y: yp,
  3089. z: zm
  3090. }],
  3091. enabled: frame.bottom.visible && !frame.front.visible
  3092. },
  3093. {
  3094. fill: H.color(frame.bottom.color).get(),
  3095. vertexes: [{
  3096. x: xmm,
  3097. y: ypp,
  3098. z: zpp
  3099. }, {
  3100. x: xpp,
  3101. y: ypp,
  3102. z: zpp
  3103. }, {
  3104. x: xp,
  3105. y: yp,
  3106. z: zp
  3107. }, {
  3108. x: xm,
  3109. y: yp,
  3110. z: zp
  3111. }],
  3112. enabled: frame.bottom.visible && !frame.back.visible
  3113. }]
  3114. });
  3115. this.frameShapes.top[verb]({
  3116. 'class': 'highcharts-3d-frame highcharts-3d-frame-top',
  3117. zIndex: frame.top.frontFacing ? -1000 : 1000,
  3118. faces: [{
  3119. fill: H.color(frame.top.color).brighten(0.1).get(),
  3120. vertexes: [{
  3121. x: xmm,
  3122. y: ymm,
  3123. z: zpp
  3124. }, {
  3125. x: xpp,
  3126. y: ymm,
  3127. z: zpp
  3128. }, {
  3129. x: xpp,
  3130. y: ymm,
  3131. z: zmm
  3132. }, {
  3133. x: xmm,
  3134. y: ymm,
  3135. z: zmm
  3136. }],
  3137. enabled: frame.top.visible
  3138. },
  3139. {
  3140. fill: H.color(frame.top.color).brighten(0.1).get(),
  3141. vertexes: [{
  3142. x: xm,
  3143. y: ym,
  3144. z: zm
  3145. }, {
  3146. x: xp,
  3147. y: ym,
  3148. z: zm
  3149. }, {
  3150. x: xp,
  3151. y: ym,
  3152. z: zp
  3153. }, {
  3154. x: xm,
  3155. y: ym,
  3156. z: zp
  3157. }],
  3158. enabled: frame.top.visible
  3159. },
  3160. {
  3161. fill: H.color(frame.top.color).brighten(-0.1).get(),
  3162. vertexes: [{
  3163. x: xmm,
  3164. y: ymm,
  3165. z: zpp
  3166. }, {
  3167. x: xmm,
  3168. y: ymm,
  3169. z: zmm
  3170. }, {
  3171. x: xm,
  3172. y: ym,
  3173. z: zm
  3174. }, {
  3175. x: xm,
  3176. y: ym,
  3177. z: zp
  3178. }],
  3179. enabled: frame.top.visible && !frame.left.visible
  3180. },
  3181. {
  3182. fill: H.color(frame.top.color).brighten(-0.1).get(),
  3183. vertexes: [{
  3184. x: xpp,
  3185. y: ymm,
  3186. z: zmm
  3187. }, {
  3188. x: xpp,
  3189. y: ymm,
  3190. z: zpp
  3191. }, {
  3192. x: xp,
  3193. y: ym,
  3194. z: zp
  3195. }, {
  3196. x: xp,
  3197. y: ym,
  3198. z: zm
  3199. }],
  3200. enabled: frame.top.visible && !frame.right.visible
  3201. },
  3202. {
  3203. fill: H.color(frame.top.color).get(),
  3204. vertexes: [{
  3205. x: xmm,
  3206. y: ymm,
  3207. z: zmm
  3208. }, {
  3209. x: xpp,
  3210. y: ymm,
  3211. z: zmm
  3212. }, {
  3213. x: xp,
  3214. y: ym,
  3215. z: zm
  3216. }, {
  3217. x: xm,
  3218. y: ym,
  3219. z: zm
  3220. }],
  3221. enabled: frame.top.visible && !frame.front.visible
  3222. },
  3223. {
  3224. fill: H.color(frame.top.color).get(),
  3225. vertexes: [{
  3226. x: xpp,
  3227. y: ymm,
  3228. z: zpp
  3229. }, {
  3230. x: xmm,
  3231. y: ymm,
  3232. z: zpp
  3233. }, {
  3234. x: xm,
  3235. y: ym,
  3236. z: zp
  3237. }, {
  3238. x: xp,
  3239. y: ym,
  3240. z: zp
  3241. }],
  3242. enabled: frame.top.visible && !frame.back.visible
  3243. }]
  3244. });
  3245. this.frameShapes.left[verb]({
  3246. 'class': 'highcharts-3d-frame highcharts-3d-frame-left',
  3247. zIndex: frame.left.frontFacing ? -1000 : 1000,
  3248. faces: [{
  3249. fill: H.color(frame.left.color).brighten(0.1).get(),
  3250. vertexes: [{
  3251. x: xmm,
  3252. y: ypp,
  3253. z: zmm
  3254. }, {
  3255. x: xm,
  3256. y: yp,
  3257. z: zm
  3258. }, {
  3259. x: xm,
  3260. y: yp,
  3261. z: zp
  3262. }, {
  3263. x: xmm,
  3264. y: ypp,
  3265. z: zpp
  3266. }],
  3267. enabled: frame.left.visible && !frame.bottom.visible
  3268. },
  3269. {
  3270. fill: H.color(frame.left.color).brighten(0.1).get(),
  3271. vertexes: [{
  3272. x: xmm,
  3273. y: ymm,
  3274. z: zpp
  3275. }, {
  3276. x: xm,
  3277. y: ym,
  3278. z: zp
  3279. }, {
  3280. x: xm,
  3281. y: ym,
  3282. z: zm
  3283. }, {
  3284. x: xmm,
  3285. y: ymm,
  3286. z: zmm
  3287. }],
  3288. enabled: frame.left.visible && !frame.top.visible
  3289. },
  3290. {
  3291. fill: H.color(frame.left.color).brighten(-0.1).get(),
  3292. vertexes: [{
  3293. x: xmm,
  3294. y: ypp,
  3295. z: zpp
  3296. }, {
  3297. x: xmm,
  3298. y: ymm,
  3299. z: zpp
  3300. }, {
  3301. x: xmm,
  3302. y: ymm,
  3303. z: zmm
  3304. }, {
  3305. x: xmm,
  3306. y: ypp,
  3307. z: zmm
  3308. }],
  3309. enabled: frame.left.visible
  3310. },
  3311. {
  3312. fill: H.color(frame.left.color).brighten(-0.1).get(),
  3313. vertexes: [{
  3314. x: xm,
  3315. y: ym,
  3316. z: zp
  3317. }, {
  3318. x: xm,
  3319. y: yp,
  3320. z: zp
  3321. }, {
  3322. x: xm,
  3323. y: yp,
  3324. z: zm
  3325. }, {
  3326. x: xm,
  3327. y: ym,
  3328. z: zm
  3329. }],
  3330. enabled: frame.left.visible
  3331. },
  3332. {
  3333. fill: H.color(frame.left.color).get(),
  3334. vertexes: [{
  3335. x: xmm,
  3336. y: ypp,
  3337. z: zmm
  3338. }, {
  3339. x: xmm,
  3340. y: ymm,
  3341. z: zmm
  3342. }, {
  3343. x: xm,
  3344. y: ym,
  3345. z: zm
  3346. }, {
  3347. x: xm,
  3348. y: yp,
  3349. z: zm
  3350. }],
  3351. enabled: frame.left.visible && !frame.front.visible
  3352. },
  3353. {
  3354. fill: H.color(frame.left.color).get(),
  3355. vertexes: [{
  3356. x: xmm,
  3357. y: ymm,
  3358. z: zpp
  3359. }, {
  3360. x: xmm,
  3361. y: ypp,
  3362. z: zpp
  3363. }, {
  3364. x: xm,
  3365. y: yp,
  3366. z: zp
  3367. }, {
  3368. x: xm,
  3369. y: ym,
  3370. z: zp
  3371. }],
  3372. enabled: frame.left.visible && !frame.back.visible
  3373. }]
  3374. });
  3375. this.frameShapes.right[verb]({
  3376. 'class': 'highcharts-3d-frame highcharts-3d-frame-right',
  3377. zIndex: frame.right.frontFacing ? -1000 : 1000,
  3378. faces: [{
  3379. fill: H.color(frame.right.color).brighten(0.1).get(),
  3380. vertexes: [{
  3381. x: xpp,
  3382. y: ypp,
  3383. z: zpp
  3384. }, {
  3385. x: xp,
  3386. y: yp,
  3387. z: zp
  3388. }, {
  3389. x: xp,
  3390. y: yp,
  3391. z: zm
  3392. }, {
  3393. x: xpp,
  3394. y: ypp,
  3395. z: zmm
  3396. }],
  3397. enabled: frame.right.visible && !frame.bottom.visible
  3398. },
  3399. {
  3400. fill: H.color(frame.right.color).brighten(0.1).get(),
  3401. vertexes: [{
  3402. x: xpp,
  3403. y: ymm,
  3404. z: zmm
  3405. }, {
  3406. x: xp,
  3407. y: ym,
  3408. z: zm
  3409. }, {
  3410. x: xp,
  3411. y: ym,
  3412. z: zp
  3413. }, {
  3414. x: xpp,
  3415. y: ymm,
  3416. z: zpp
  3417. }],
  3418. enabled: frame.right.visible && !frame.top.visible
  3419. },
  3420. {
  3421. fill: H.color(frame.right.color).brighten(-0.1).get(),
  3422. vertexes: [{
  3423. x: xp,
  3424. y: ym,
  3425. z: zm
  3426. }, {
  3427. x: xp,
  3428. y: yp,
  3429. z: zm
  3430. }, {
  3431. x: xp,
  3432. y: yp,
  3433. z: zp
  3434. }, {
  3435. x: xp,
  3436. y: ym,
  3437. z: zp
  3438. }],
  3439. enabled: frame.right.visible
  3440. },
  3441. {
  3442. fill: H.color(frame.right.color).brighten(-0.1).get(),
  3443. vertexes: [{
  3444. x: xpp,
  3445. y: ypp,
  3446. z: zmm
  3447. }, {
  3448. x: xpp,
  3449. y: ymm,
  3450. z: zmm
  3451. }, {
  3452. x: xpp,
  3453. y: ymm,
  3454. z: zpp
  3455. }, {
  3456. x: xpp,
  3457. y: ypp,
  3458. z: zpp
  3459. }],
  3460. enabled: frame.right.visible
  3461. },
  3462. {
  3463. fill: H.color(frame.right.color).get(),
  3464. vertexes: [{
  3465. x: xpp,
  3466. y: ymm,
  3467. z: zmm
  3468. }, {
  3469. x: xpp,
  3470. y: ypp,
  3471. z: zmm
  3472. }, {
  3473. x: xp,
  3474. y: yp,
  3475. z: zm
  3476. }, {
  3477. x: xp,
  3478. y: ym,
  3479. z: zm
  3480. }],
  3481. enabled: frame.right.visible && !frame.front.visible
  3482. },
  3483. {
  3484. fill: H.color(frame.right.color).get(),
  3485. vertexes: [{
  3486. x: xpp,
  3487. y: ypp,
  3488. z: zpp
  3489. }, {
  3490. x: xpp,
  3491. y: ymm,
  3492. z: zpp
  3493. }, {
  3494. x: xp,
  3495. y: ym,
  3496. z: zp
  3497. }, {
  3498. x: xp,
  3499. y: yp,
  3500. z: zp
  3501. }],
  3502. enabled: frame.right.visible && !frame.back.visible
  3503. }]
  3504. });
  3505. this.frameShapes.back[verb]({
  3506. 'class': 'highcharts-3d-frame highcharts-3d-frame-back',
  3507. zIndex: frame.back.frontFacing ? -1000 : 1000,
  3508. faces: [{
  3509. fill: H.color(frame.back.color).brighten(0.1).get(),
  3510. vertexes: [{
  3511. x: xpp,
  3512. y: ypp,
  3513. z: zpp
  3514. }, {
  3515. x: xmm,
  3516. y: ypp,
  3517. z: zpp
  3518. }, {
  3519. x: xm,
  3520. y: yp,
  3521. z: zp
  3522. }, {
  3523. x: xp,
  3524. y: yp,
  3525. z: zp
  3526. }],
  3527. enabled: frame.back.visible && !frame.bottom.visible
  3528. },
  3529. {
  3530. fill: H.color(frame.back.color).brighten(0.1).get(),
  3531. vertexes: [{
  3532. x: xmm,
  3533. y: ymm,
  3534. z: zpp
  3535. }, {
  3536. x: xpp,
  3537. y: ymm,
  3538. z: zpp
  3539. }, {
  3540. x: xp,
  3541. y: ym,
  3542. z: zp
  3543. }, {
  3544. x: xm,
  3545. y: ym,
  3546. z: zp
  3547. }],
  3548. enabled: frame.back.visible && !frame.top.visible
  3549. },
  3550. {
  3551. fill: H.color(frame.back.color).brighten(-0.1).get(),
  3552. vertexes: [{
  3553. x: xmm,
  3554. y: ypp,
  3555. z: zpp
  3556. }, {
  3557. x: xmm,
  3558. y: ymm,
  3559. z: zpp
  3560. }, {
  3561. x: xm,
  3562. y: ym,
  3563. z: zp
  3564. }, {
  3565. x: xm,
  3566. y: yp,
  3567. z: zp
  3568. }],
  3569. enabled: frame.back.visible && !frame.left.visible
  3570. },
  3571. {
  3572. fill: H.color(frame.back.color).brighten(-0.1).get(),
  3573. vertexes: [{
  3574. x: xpp,
  3575. y: ymm,
  3576. z: zpp
  3577. }, {
  3578. x: xpp,
  3579. y: ypp,
  3580. z: zpp
  3581. }, {
  3582. x: xp,
  3583. y: yp,
  3584. z: zp
  3585. }, {
  3586. x: xp,
  3587. y: ym,
  3588. z: zp
  3589. }],
  3590. enabled: frame.back.visible && !frame.right.visible
  3591. },
  3592. {
  3593. fill: H.color(frame.back.color).get(),
  3594. vertexes: [{
  3595. x: xm,
  3596. y: ym,
  3597. z: zp
  3598. }, {
  3599. x: xp,
  3600. y: ym,
  3601. z: zp
  3602. }, {
  3603. x: xp,
  3604. y: yp,
  3605. z: zp
  3606. }, {
  3607. x: xm,
  3608. y: yp,
  3609. z: zp
  3610. }],
  3611. enabled: frame.back.visible
  3612. },
  3613. {
  3614. fill: H.color(frame.back.color).get(),
  3615. vertexes: [{
  3616. x: xmm,
  3617. y: ypp,
  3618. z: zpp
  3619. }, {
  3620. x: xpp,
  3621. y: ypp,
  3622. z: zpp
  3623. }, {
  3624. x: xpp,
  3625. y: ymm,
  3626. z: zpp
  3627. }, {
  3628. x: xmm,
  3629. y: ymm,
  3630. z: zpp
  3631. }],
  3632. enabled: frame.back.visible
  3633. }]
  3634. });
  3635. this.frameShapes.front[verb]({
  3636. 'class': 'highcharts-3d-frame highcharts-3d-frame-front',
  3637. zIndex: frame.front.frontFacing ? -1000 : 1000,
  3638. faces: [{
  3639. fill: H.color(frame.front.color).brighten(0.1).get(),
  3640. vertexes: [{
  3641. x: xmm,
  3642. y: ypp,
  3643. z: zmm
  3644. }, {
  3645. x: xpp,
  3646. y: ypp,
  3647. z: zmm
  3648. }, {
  3649. x: xp,
  3650. y: yp,
  3651. z: zm
  3652. }, {
  3653. x: xm,
  3654. y: yp,
  3655. z: zm
  3656. }],
  3657. enabled: frame.front.visible && !frame.bottom.visible
  3658. },
  3659. {
  3660. fill: H.color(frame.front.color).brighten(0.1).get(),
  3661. vertexes: [{
  3662. x: xpp,
  3663. y: ymm,
  3664. z: zmm
  3665. }, {
  3666. x: xmm,
  3667. y: ymm,
  3668. z: zmm
  3669. }, {
  3670. x: xm,
  3671. y: ym,
  3672. z: zm
  3673. }, {
  3674. x: xp,
  3675. y: ym,
  3676. z: zm
  3677. }],
  3678. enabled: frame.front.visible && !frame.top.visible
  3679. },
  3680. {
  3681. fill: H.color(frame.front.color).brighten(-0.1).get(),
  3682. vertexes: [{
  3683. x: xmm,
  3684. y: ymm,
  3685. z: zmm
  3686. }, {
  3687. x: xmm,
  3688. y: ypp,
  3689. z: zmm
  3690. }, {
  3691. x: xm,
  3692. y: yp,
  3693. z: zm
  3694. }, {
  3695. x: xm,
  3696. y: ym,
  3697. z: zm
  3698. }],
  3699. enabled: frame.front.visible && !frame.left.visible
  3700. },
  3701. {
  3702. fill: H.color(frame.front.color).brighten(-0.1).get(),
  3703. vertexes: [{
  3704. x: xpp,
  3705. y: ypp,
  3706. z: zmm
  3707. }, {
  3708. x: xpp,
  3709. y: ymm,
  3710. z: zmm
  3711. }, {
  3712. x: xp,
  3713. y: ym,
  3714. z: zm
  3715. }, {
  3716. x: xp,
  3717. y: yp,
  3718. z: zm
  3719. }],
  3720. enabled: frame.front.visible && !frame.right.visible
  3721. },
  3722. {
  3723. fill: H.color(frame.front.color).get(),
  3724. vertexes: [{
  3725. x: xp,
  3726. y: ym,
  3727. z: zm
  3728. }, {
  3729. x: xm,
  3730. y: ym,
  3731. z: zm
  3732. }, {
  3733. x: xm,
  3734. y: yp,
  3735. z: zm
  3736. }, {
  3737. x: xp,
  3738. y: yp,
  3739. z: zm
  3740. }],
  3741. enabled: frame.front.visible
  3742. },
  3743. {
  3744. fill: H.color(frame.front.color).get(),
  3745. vertexes: [{
  3746. x: xpp,
  3747. y: ypp,
  3748. z: zmm
  3749. }, {
  3750. x: xmm,
  3751. y: ypp,
  3752. z: zmm
  3753. }, {
  3754. x: xmm,
  3755. y: ymm,
  3756. z: zmm
  3757. }, {
  3758. x: xpp,
  3759. y: ymm,
  3760. z: zmm
  3761. }],
  3762. enabled: frame.front.visible
  3763. }]
  3764. });
  3765. }
  3766. }
  3767. /**
  3768. * Add the required CSS classes for column sides (#6018)
  3769. * @private
  3770. */
  3771. function onAfterGetContainer() {
  3772. if (this.styledMode) {
  3773. this.renderer.definition({
  3774. tagName: 'style',
  3775. textContent: '.highcharts-3d-top{' +
  3776. 'filter: url(#highcharts-brighter)' +
  3777. '}\n' +
  3778. '.highcharts-3d-side{' +
  3779. 'filter: url(#highcharts-darker)' +
  3780. '}\n'
  3781. });
  3782. // Add add definitions used by brighter and darker faces of the
  3783. // cuboids.
  3784. [{
  3785. name: 'darker',
  3786. slope: 0.6
  3787. }, {
  3788. name: 'brighter',
  3789. slope: 1.4
  3790. }].forEach(function (cfg) {
  3791. this.renderer.definition({
  3792. tagName: 'filter',
  3793. attributes: {
  3794. id: 'highcharts-' + cfg.name
  3795. },
  3796. children: [{
  3797. tagName: 'feComponentTransfer',
  3798. children: [{
  3799. tagName: 'feFuncR',
  3800. attributes: {
  3801. type: 'linear',
  3802. slope: cfg.slope
  3803. }
  3804. }, {
  3805. tagName: 'feFuncG',
  3806. attributes: {
  3807. type: 'linear',
  3808. slope: cfg.slope
  3809. }
  3810. }, {
  3811. tagName: 'feFuncB',
  3812. attributes: {
  3813. type: 'linear',
  3814. slope: cfg.slope
  3815. }
  3816. }]
  3817. }]
  3818. });
  3819. }, this);
  3820. }
  3821. }
  3822. /**
  3823. * Legacy support for HC < 6 to make 'scatter' series in a 3D chart route to
  3824. * the real 'scatter3d' series type. (#8407)
  3825. * @private
  3826. */
  3827. function onAfterInit() {
  3828. var options = this.options;
  3829. if (this.is3d()) {
  3830. (options.series || []).forEach(function (s) {
  3831. var type = s.type ||
  3832. options.chart.type ||
  3833. options.chart.defaultSeriesType;
  3834. if (type === 'scatter') {
  3835. s.type = 'scatter3d';
  3836. }
  3837. });
  3838. }
  3839. }
  3840. /**
  3841. * @private
  3842. */
  3843. function onAfterSetChartSize() {
  3844. var chart = this,
  3845. options3d = chart.options.chart.options3d;
  3846. if (chart.chart3d &&
  3847. chart.is3d()) {
  3848. // Add a 0-360 normalisation for alfa and beta angles in 3d graph
  3849. if (options3d) {
  3850. options3d.alpha = options3d.alpha % 360 + (options3d.alpha >= 0 ? 0 : 360);
  3851. options3d.beta = options3d.beta % 360 + (options3d.beta >= 0 ? 0 : 360);
  3852. }
  3853. var inverted = chart.inverted, clipBox = chart.clipBox, margin = chart.margin, x = inverted ? 'y' : 'x', y = inverted ? 'x' : 'y', w = inverted ? 'height' : 'width', h = inverted ? 'width' : 'height';
  3854. clipBox[x] = -(margin[3] || 0);
  3855. clipBox[y] = -(margin[0] || 0);
  3856. clipBox[w] =
  3857. chart.chartWidth + (margin[3] || 0) + (margin[1] || 0);
  3858. clipBox[h] =
  3859. chart.chartHeight + (margin[0] || 0) + (margin[2] || 0);
  3860. // Set scale, used later in perspective method():
  3861. // getScale uses perspective, so scale3d has to be reset.
  3862. chart.scale3d = 1;
  3863. if (options3d.fitToPlot === true) {
  3864. chart.scale3d = chart.chart3d.getScale(options3d.depth);
  3865. }
  3866. // Recalculate the 3d frame with every call of setChartSize,
  3867. // instead of doing it after every redraw(). It avoids ticks
  3868. // and axis title outside of chart.
  3869. chart.chart3d.frame3d = chart.chart3d.get3dFrame(); // #7942
  3870. }
  3871. }
  3872. /**
  3873. * @private
  3874. */
  3875. function onBeforeRedraw() {
  3876. if (this.is3d()) {
  3877. // Set to force a redraw of all elements
  3878. this.isDirtyBox = true;
  3879. }
  3880. }
  3881. /**
  3882. * @private
  3883. */
  3884. function onBeforeRender() {
  3885. if (this.chart3d && this.is3d()) {
  3886. this.chart3d.frame3d = this.chart3d.get3dFrame();
  3887. }
  3888. }
  3889. /**
  3890. * @private
  3891. */
  3892. function onInit() {
  3893. if (!this.chart3d) {
  3894. this.chart3d = new Composition(this);
  3895. }
  3896. }
  3897. /**
  3898. * @private
  3899. */
  3900. function wrapIsInsidePlot(proceed) {
  3901. return this.is3d() || proceed.apply(this, [].slice.call(arguments, 1));
  3902. }
  3903. /**
  3904. * Draw the series in the reverse order (#3803, #3917)
  3905. * @private
  3906. */
  3907. function wrapRenderSeries(proceed) {
  3908. var series,
  3909. i = this.series.length;
  3910. if (this.is3d()) {
  3911. while (i--) {
  3912. series = this.series[i];
  3913. series.translate();
  3914. series.render();
  3915. }
  3916. }
  3917. else {
  3918. proceed.call(this);
  3919. }
  3920. }
  3921. /**
  3922. * @private
  3923. */
  3924. function wrapSetClassName(proceed) {
  3925. proceed.apply(this, [].slice.call(arguments, 1));
  3926. if (this.is3d()) {
  3927. this.container.className += ' highcharts-3d-chart';
  3928. }
  3929. }
  3930. })(Chart3D || (Chart3D = {}));
  3931. Chart3D.compose(Chart, Fx);
  3932. ZAxis.ZChartComposition.compose(Chart);
  3933. Axis3D.compose(Axis);
  3934. /**
  3935. * Note: As of v5.0.12, `frame.left` or `frame.right` should be used instead.
  3936. *
  3937. * The side for the frame around a 3D chart.
  3938. *
  3939. * @deprecated
  3940. * @since 4.0
  3941. * @product highcharts
  3942. * @requires highcharts-3d
  3943. * @apioption chart.options3d.frame.side
  3944. */
  3945. /**
  3946. * The color of the panel.
  3947. *
  3948. * @deprecated
  3949. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3950. * @default transparent
  3951. * @since 4.0
  3952. * @product highcharts
  3953. * @apioption chart.options3d.frame.side.color
  3954. */
  3955. /**
  3956. * The thickness of the panel.
  3957. *
  3958. * @deprecated
  3959. * @type {number}
  3960. * @default 1
  3961. * @since 4.0
  3962. * @product highcharts
  3963. * @apioption chart.options3d.frame.side.size
  3964. */
  3965. ''; // adds doclets above to transpiled file
  3966. return Chart3D;
  3967. });
  3968. _registerModule(_modules, 'Core/Series/Series3D.js', [_modules['Extensions/Math3D.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Math3D, Series, U) {
  3969. /* *
  3970. *
  3971. * (c) 2010-2021 Torstein Honsi
  3972. *
  3973. * Extension to the Series object in 3D charts.
  3974. *
  3975. * License: www.highcharts.com/license
  3976. *
  3977. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3978. *
  3979. * */
  3980. var __extends = (this && this.__extends) || (function () {
  3981. var extendStatics = function (d,
  3982. b) {
  3983. extendStatics = Object.setPrototypeOf ||
  3984. ({ __proto__: [] } instanceof Array && function (d,
  3985. b) { d.__proto__ = b; }) ||
  3986. function (d,
  3987. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3988. return extendStatics(d, b);
  3989. };
  3990. return function (d, b) {
  3991. extendStatics(d, b);
  3992. function __() { this.constructor = d; }
  3993. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3994. };
  3995. })();
  3996. var perspective = Math3D.perspective;
  3997. var addEvent = U.addEvent,
  3998. extend = U.extend,
  3999. merge = U.merge,
  4000. pick = U.pick,
  4001. isNumber = U.isNumber;
  4002. /* *
  4003. *
  4004. * Class
  4005. *
  4006. * */
  4007. var Series3D = /** @class */ (function (_super) {
  4008. __extends(Series3D, _super);
  4009. function Series3D() {
  4010. return _super !== null && _super.apply(this, arguments) || this;
  4011. }
  4012. /* *
  4013. *
  4014. * Functions
  4015. *
  4016. * */
  4017. /* eslint-disable valid-jsdoc */
  4018. Series3D.prototype.translate = function () {
  4019. _super.prototype.translate.apply(this, arguments);
  4020. if (this.chart.is3d()) {
  4021. this.translate3dPoints();
  4022. }
  4023. };
  4024. /**
  4025. * Translate the plotX, plotY properties and add plotZ.
  4026. * @private
  4027. */
  4028. Series3D.prototype.translate3dPoints = function () {
  4029. var series = this,
  4030. seriesOptions = series.options,
  4031. chart = series.chart,
  4032. zAxis = pick(series.zAxis,
  4033. chart.options.zAxis[0]),
  4034. rawPoints = [],
  4035. rawPoint,
  4036. projectedPoints,
  4037. projectedPoint,
  4038. zValue,
  4039. i,
  4040. rawPointsX = [],
  4041. stack = seriesOptions.stacking ?
  4042. (isNumber(seriesOptions.stack) ? seriesOptions.stack : 0) :
  4043. series.index || 0;
  4044. series.zPadding = stack *
  4045. (seriesOptions.depth || 0 + (seriesOptions.groupZPadding || 1));
  4046. for (i = 0; i < series.data.length; i++) {
  4047. rawPoint = series.data[i];
  4048. if (zAxis && zAxis.translate) {
  4049. zValue = zAxis.logarithmic && zAxis.val2lin ?
  4050. zAxis.val2lin(rawPoint.z) :
  4051. rawPoint.z; // #4562
  4052. rawPoint.plotZ = zAxis.translate(zValue);
  4053. rawPoint.isInside = rawPoint.isInside ?
  4054. (zValue >= zAxis.min &&
  4055. zValue <= zAxis.max) :
  4056. false;
  4057. }
  4058. else {
  4059. rawPoint.plotZ = series.zPadding;
  4060. }
  4061. rawPoint.axisXpos = rawPoint.plotX;
  4062. rawPoint.axisYpos = rawPoint.plotY;
  4063. rawPoint.axisZpos = rawPoint.plotZ;
  4064. rawPoints.push({
  4065. x: rawPoint.plotX,
  4066. y: rawPoint.plotY,
  4067. z: rawPoint.plotZ
  4068. });
  4069. rawPointsX.push(rawPoint.plotX || 0);
  4070. }
  4071. series.rawPointsX = rawPointsX;
  4072. projectedPoints = perspective(rawPoints, chart, true);
  4073. for (i = 0; i < series.data.length; i++) {
  4074. rawPoint = series.data[i];
  4075. projectedPoint = projectedPoints[i];
  4076. rawPoint.plotX = projectedPoint.x;
  4077. rawPoint.plotY = projectedPoint.y;
  4078. rawPoint.plotZ = projectedPoint.z;
  4079. }
  4080. };
  4081. /* *
  4082. *
  4083. * Static Properties
  4084. *
  4085. * */
  4086. Series3D.defaultOptions = merge(Series.defaultOptions);
  4087. return Series3D;
  4088. }(Series));
  4089. /* *
  4090. *
  4091. * Compatibility
  4092. *
  4093. * */
  4094. /* eslint-disable no-invalid-this */
  4095. addEvent(Series, 'afterTranslate', function () {
  4096. if (this.chart.is3d()) {
  4097. this.translate3dPoints();
  4098. }
  4099. });
  4100. /* eslint-enable no-invalid-this */
  4101. extend(Series.prototype, {
  4102. translate3dPoints: Series3D.prototype.translate3dPoints
  4103. });
  4104. /* *
  4105. *
  4106. * Default Export
  4107. *
  4108. * */
  4109. return Series3D;
  4110. });
  4111. _registerModule(_modules, 'Series/Column3D/Column3DComposition.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Extensions/Math3D.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Extensions/Stacking.js'], _modules['Core/Utilities.js']], function (ColumnSeries, H, Series, Math3D, SeriesRegistry, StackItem, U) {
  4112. /* *
  4113. *
  4114. * (c) 2010-2021 Torstein Honsi
  4115. *
  4116. * License: www.highcharts.com/license
  4117. *
  4118. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4119. *
  4120. * */
  4121. var columnProto = ColumnSeries.prototype;
  4122. var svg = H.svg;
  4123. var perspective = Math3D.perspective;
  4124. var addEvent = U.addEvent,
  4125. pick = U.pick,
  4126. wrap = U.wrap;
  4127. /* *
  4128. *
  4129. * Functions
  4130. *
  4131. * */
  4132. /* eslint-disable no-invalid-this */
  4133. /**
  4134. * @private
  4135. * @param {Highcharts.Chart} chart
  4136. * Chart with stacks
  4137. * @param {string} stacking
  4138. * Stacking option
  4139. * @return {Highcharts.Stack3DDictionary}
  4140. */
  4141. function retrieveStacks(chart, stacking) {
  4142. var series = chart.series,
  4143. stacks = {};
  4144. var stackNumber,
  4145. i = 1;
  4146. series.forEach(function (s) {
  4147. stackNumber = pick(s.options.stack, (stacking ? 0 : series.length - 1 - s.index)); // #3841, #4532
  4148. if (!stacks[stackNumber]) {
  4149. stacks[stackNumber] = { series: [s], position: i };
  4150. i++;
  4151. }
  4152. else {
  4153. stacks[stackNumber].series.push(s);
  4154. }
  4155. });
  4156. stacks.totalStacks = i + 1;
  4157. return stacks;
  4158. }
  4159. wrap(columnProto, 'translate', function (proceed) {
  4160. proceed.apply(this, [].slice.call(arguments, 1));
  4161. // Do not do this if the chart is not 3D
  4162. if (this.chart.is3d()) {
  4163. this.translate3dShapes();
  4164. }
  4165. });
  4166. // Don't use justifyDataLabel when point is outsidePlot
  4167. wrap(Series.prototype, 'justifyDataLabel', function (proceed) {
  4168. return !(arguments[2].outside3dPlot) ?
  4169. proceed.apply(this, [].slice.call(arguments, 1)) :
  4170. false;
  4171. });
  4172. columnProto.translate3dPoints = function () { };
  4173. columnProto.translate3dShapes = function () {
  4174. var series = this,
  4175. chart = series.chart,
  4176. seriesOptions = series.options,
  4177. depth = seriesOptions.depth,
  4178. stack = seriesOptions.stacking ?
  4179. (seriesOptions.stack || 0) :
  4180. series.index, // #4743
  4181. z = stack * (depth + (seriesOptions.groupZPadding || 1)),
  4182. borderCrisp = series.borderWidth % 2 ? 0.5 : 0,
  4183. point2dPos; // Position of point in 2D, used for 3D position calculation.
  4184. if (chart.inverted && !series.yAxis.reversed) {
  4185. borderCrisp *= -1;
  4186. }
  4187. if (seriesOptions.grouping !== false) {
  4188. z = 0;
  4189. }
  4190. z += (seriesOptions.groupZPadding || 1);
  4191. series.data.forEach(function (point) {
  4192. // #7103 Reset outside3dPlot flag
  4193. point.outside3dPlot = null;
  4194. if (point.y !== null) {
  4195. var shapeArgs_1 = point.shapeArgs, tooltipPos = point.tooltipPos,
  4196. // Array for final shapeArgs calculation.
  4197. // We are checking two dimensions (x and y).
  4198. dimensions = [['x', 'width'], ['y', 'height']], borderlessBase_1; // Crisped rects can have +/- 0.5 pixels offset.
  4199. // #3131 We need to check if column is inside plotArea.
  4200. dimensions.forEach(function (d) {
  4201. borderlessBase_1 = shapeArgs_1[d[0]] - borderCrisp;
  4202. if (borderlessBase_1 < 0) {
  4203. // If borderLessBase is smaller than 0, it is needed to set
  4204. // its value to 0 or 0.5 depending on borderWidth
  4205. // borderWidth may be even or odd.
  4206. shapeArgs_1[d[1]] +=
  4207. shapeArgs_1[d[0]] + borderCrisp;
  4208. shapeArgs_1[d[0]] = -borderCrisp;
  4209. borderlessBase_1 = 0;
  4210. }
  4211. if ((borderlessBase_1 + shapeArgs_1[d[1]] >
  4212. series[d[0] + 'Axis'].len) &&
  4213. // Do not change height/width of column if 0 (#6708)
  4214. shapeArgs_1[d[1]] !== 0) {
  4215. shapeArgs_1[d[1]] =
  4216. series[d[0] + 'Axis'].len -
  4217. shapeArgs_1[d[0]];
  4218. }
  4219. if (
  4220. // Do not remove columns with zero height/width.
  4221. (shapeArgs_1[d[1]] !== 0) &&
  4222. (shapeArgs_1[d[0]] >=
  4223. series[d[0] + 'Axis'].len ||
  4224. shapeArgs_1[d[0]] + shapeArgs_1[d[1]] <=
  4225. borderCrisp)) {
  4226. // Set args to 0 if column is outside the chart.
  4227. for (var key in shapeArgs_1) { // eslint-disable-line guard-for-in
  4228. shapeArgs_1[key] = 0;
  4229. }
  4230. // #7103 outside3dPlot flag is set on Points which are
  4231. // currently outside of plot.
  4232. point.outside3dPlot = true;
  4233. }
  4234. });
  4235. // Change from 2d to 3d
  4236. if (point.shapeType === 'rect') {
  4237. point.shapeType = 'cuboid';
  4238. }
  4239. shapeArgs_1.z = z;
  4240. shapeArgs_1.depth = depth;
  4241. shapeArgs_1.insidePlotArea = true;
  4242. // Point's position in 2D
  4243. point2dPos = {
  4244. x: shapeArgs_1.x + shapeArgs_1.width / 2,
  4245. y: shapeArgs_1.y,
  4246. z: z + depth / 2 // The center of column in Z dimension
  4247. };
  4248. // Recalculate point positions for inverted graphs
  4249. if (chart.inverted) {
  4250. point2dPos.x = shapeArgs_1.height;
  4251. point2dPos.y = point.clientX;
  4252. }
  4253. // Calculate and store point's position in 3D,
  4254. // using perspective method.
  4255. point.plot3d = perspective([point2dPos], chart, true, false)[0];
  4256. // Translate the tooltip position in 3d space
  4257. tooltipPos = perspective([{
  4258. x: tooltipPos[0],
  4259. y: tooltipPos[1],
  4260. z: z + depth / 2 // The center of column in Z dimension
  4261. }], chart, true, false)[0];
  4262. point.tooltipPos = [tooltipPos.x, tooltipPos.y];
  4263. }
  4264. });
  4265. // store for later use #4067
  4266. series.z = z;
  4267. };
  4268. wrap(columnProto, 'animate', function (proceed) {
  4269. if (!this.chart.is3d()) {
  4270. proceed.apply(this, [].slice.call(arguments, 1));
  4271. }
  4272. else {
  4273. var args = arguments,
  4274. init = args[1],
  4275. yAxis_1 = this.yAxis,
  4276. series_1 = this,
  4277. reversed_1 = this.yAxis.reversed;
  4278. if (svg) { // VML is too slow anyway
  4279. if (init) {
  4280. series_1.data.forEach(function (point) {
  4281. if (point.y !== null) {
  4282. point.height = point.shapeArgs.height;
  4283. point.shapey = point.shapeArgs.y; // #2968
  4284. point.shapeArgs.height = 1;
  4285. if (!reversed_1) {
  4286. if (point.stackY) {
  4287. point.shapeArgs.y =
  4288. point.plotY +
  4289. yAxis_1.translate(point.stackY);
  4290. }
  4291. else {
  4292. point.shapeArgs.y =
  4293. point.plotY +
  4294. (point.negative ?
  4295. -point.height :
  4296. point.height);
  4297. }
  4298. }
  4299. }
  4300. });
  4301. }
  4302. else { // run the animation
  4303. series_1.data.forEach(function (point) {
  4304. if (point.y !== null) {
  4305. point.shapeArgs.height = point.height;
  4306. point.shapeArgs.y = point.shapey; // #2968
  4307. // null value do not have a graphic
  4308. if (point.graphic) {
  4309. point.graphic.animate(point.shapeArgs, series_1.options.animation);
  4310. }
  4311. }
  4312. });
  4313. // redraw datalabels to the correct position
  4314. this.drawDataLabels();
  4315. }
  4316. }
  4317. }
  4318. });
  4319. // In case of 3d columns there is no sense to add this columns to a specific
  4320. // series group - if series is added to a group all columns will have the same
  4321. // zIndex in comparison with different series.
  4322. wrap(columnProto, 'plotGroup', function (proceed, prop, _name, _visibility, _zIndex, parent) {
  4323. if (prop !== 'dataLabelsGroup') {
  4324. if (this.chart.is3d()) {
  4325. if (this[prop]) {
  4326. delete this[prop];
  4327. }
  4328. if (parent) {
  4329. if (!this.chart.columnGroup) {
  4330. this.chart.columnGroup =
  4331. this.chart.renderer.g('columnGroup').add(parent);
  4332. }
  4333. this[prop] = this.chart.columnGroup;
  4334. this.chart.columnGroup.attr(this.getPlotBox());
  4335. this[prop].survive = true;
  4336. if (prop === 'group' || prop === 'markerGroup') {
  4337. arguments[3] = 'visible';
  4338. // For 3D column group and markerGroup should be visible
  4339. }
  4340. }
  4341. }
  4342. }
  4343. return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  4344. });
  4345. // When series is not added to group it is needed to change setVisible method to
  4346. // allow correct Legend funcionality. This wrap is basing on pie chart series.
  4347. wrap(columnProto, 'setVisible', function (proceed, vis) {
  4348. var series = this;
  4349. if (series.chart.is3d()) {
  4350. series.data.forEach(function (point) {
  4351. point.visible = point.options.visible = vis =
  4352. typeof vis === 'undefined' ?
  4353. !pick(series.visible, point.visible) : vis;
  4354. series.options.data[series.data.indexOf(point)] =
  4355. point.options;
  4356. if (point.graphic) {
  4357. point.graphic.attr({
  4358. visibility: vis ? 'visible' : 'hidden'
  4359. });
  4360. }
  4361. });
  4362. }
  4363. proceed.apply(this, Array.prototype.slice.call(arguments, 1));
  4364. });
  4365. addEvent(ColumnSeries, 'afterInit', function () {
  4366. if (this.chart.is3d()) {
  4367. var series = this,
  4368. seriesOptions = this.options,
  4369. grouping = seriesOptions.grouping,
  4370. stacking = seriesOptions.stacking,
  4371. reversedStacks = this.yAxis.options.reversedStacks,
  4372. z = 0;
  4373. // @todo grouping === true ?
  4374. if (!(typeof grouping !== 'undefined' && !grouping)) {
  4375. var stacks = retrieveStacks(this.chart,
  4376. stacking),
  4377. stack = seriesOptions.stack || 0,
  4378. i = // position within the stack
  4379. void 0; // position within the stack
  4380. for (i = 0; i < stacks[stack].series.length; i++) {
  4381. if (stacks[stack].series[i] === this) {
  4382. break;
  4383. }
  4384. }
  4385. z = (10 * (stacks.totalStacks - stacks[stack].position)) +
  4386. (reversedStacks ? i : -i); // #4369
  4387. // In case when axis is reversed, columns are also reversed inside
  4388. // the group (#3737)
  4389. if (!this.xAxis.reversed) {
  4390. z = (stacks.totalStacks * 10) - z;
  4391. }
  4392. }
  4393. seriesOptions.depth = seriesOptions.depth || 25;
  4394. series.z = series.z || 0;
  4395. seriesOptions.zIndex = z;
  4396. }
  4397. });
  4398. // eslint-disable-next-line valid-jsdoc
  4399. /**
  4400. * @private
  4401. */
  4402. function pointAttribs(proceed) {
  4403. var attr = proceed.apply(this,
  4404. [].slice.call(arguments, 1));
  4405. if (this.chart.is3d && this.chart.is3d()) {
  4406. // Set the fill color to the fill color to provide a smooth edge
  4407. attr.stroke = this.options.edgeColor || attr.fill;
  4408. attr['stroke-width'] = pick(this.options.edgeWidth, 1); // #4055
  4409. }
  4410. return attr;
  4411. }
  4412. // eslint-disable-next-line valid-jsdoc
  4413. /**
  4414. * In 3D mode, all column-series are rendered in one main group. Because of that
  4415. * we need to apply inactive state on all points.
  4416. * @private
  4417. */
  4418. function setState(proceed, state, inherit) {
  4419. var is3d = this.chart.is3d && this.chart.is3d();
  4420. if (is3d) {
  4421. this.options.inactiveOtherPoints = true;
  4422. }
  4423. proceed.call(this, state, inherit);
  4424. if (is3d) {
  4425. this.options.inactiveOtherPoints = false;
  4426. }
  4427. }
  4428. // eslint-disable-next-line valid-jsdoc
  4429. /**
  4430. * In 3D mode, simple checking for a new shape to animate is not enough.
  4431. * Additionally check if graphic is a group of elements
  4432. * @private
  4433. */
  4434. function hasNewShapeType(proceed) {
  4435. var args = [];
  4436. for (var _i = 1; _i < arguments.length; _i++) {
  4437. args[_i - 1] = arguments[_i];
  4438. }
  4439. return this.series.chart.is3d() ?
  4440. this.graphic && this.graphic.element.nodeName !== 'g' :
  4441. proceed.apply(this, args);
  4442. }
  4443. wrap(columnProto, 'pointAttribs', pointAttribs);
  4444. wrap(columnProto, 'setState', setState);
  4445. wrap(columnProto.pointClass.prototype, 'hasNewShapeType', hasNewShapeType);
  4446. if (SeriesRegistry.seriesTypes.columnRange) {
  4447. var columnRangeProto = SeriesRegistry.seriesTypes.columnrange.prototype;
  4448. wrap(columnRangeProto, 'pointAttribs', pointAttribs);
  4449. wrap(columnRangeProto, 'setState', setState);
  4450. wrap(columnRangeProto.pointClass.prototype, 'hasNewShapeType', hasNewShapeType);
  4451. columnRangeProto.plotGroup = columnProto.plotGroup;
  4452. columnRangeProto.setVisible = columnProto.setVisible;
  4453. }
  4454. wrap(Series.prototype, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo) {
  4455. var chart = this.chart;
  4456. // In 3D we need to pass point.outsidePlot option to the justifyDataLabel
  4457. // method for disabling justifying dataLabels in columns outside plot
  4458. options.outside3dPlot = point.outside3dPlot;
  4459. // Only do this for 3D columns and it's derived series
  4460. if (chart.is3d() &&
  4461. this.is('column')) {
  4462. var series = this,
  4463. seriesOptions = series.options,
  4464. inside = pick(options.inside, !!series.options.stacking),
  4465. options3d = chart.options.chart.options3d,
  4466. xOffset = point.pointWidth / 2 || 0;
  4467. var dLPosition = {
  4468. x: alignTo.x + xOffset,
  4469. y: alignTo.y,
  4470. z: series.z + seriesOptions.depth / 2
  4471. };
  4472. if (chart.inverted) {
  4473. // Inside dataLabels are positioned according to above
  4474. // logic and there is no need to position them using
  4475. // non-3D algorighm (that use alignTo.width)
  4476. if (inside) {
  4477. alignTo.width = 0;
  4478. dLPosition.x += point.shapeArgs.height / 2;
  4479. }
  4480. // When chart is upside down
  4481. // (alpha angle between 180 and 360 degrees)
  4482. // it is needed to add column width to calculated value.
  4483. if (options3d.alpha >= 90 && options3d.alpha <= 270) {
  4484. dLPosition.y += point.shapeArgs.width;
  4485. }
  4486. }
  4487. // dLPosition is recalculated for 3D graphs
  4488. dLPosition = perspective([dLPosition], chart, true, false)[0];
  4489. alignTo.x = dLPosition.x - xOffset;
  4490. // #7103 If point is outside of plotArea, hide data label.
  4491. alignTo.y = point.outside3dPlot ? -9e9 : dLPosition.y;
  4492. }
  4493. proceed.apply(this, [].slice.call(arguments, 1));
  4494. });
  4495. // Added stackLabels position calculation for 3D charts.
  4496. wrap(StackItem.prototype, 'getStackBox', function (proceed, chart, stackItem, x, y, xWidth, h, axis) {
  4497. var stackBox = proceed.apply(this,
  4498. [].slice.call(arguments, 1));
  4499. // Only do this for 3D graph
  4500. if (chart.is3d() && stackItem.base) {
  4501. // First element of stackItem.base is an index of base series.
  4502. var baseSeriesInd = +(stackItem.base).split(',')[0];
  4503. var columnSeries = chart.series[baseSeriesInd];
  4504. var options3d = chart.options.chart.options3d;
  4505. // Only do this if base series is a column or inherited type,
  4506. // use its barW, z and depth parameters
  4507. // for correct stackLabels position calculation
  4508. if (columnSeries &&
  4509. columnSeries instanceof SeriesRegistry.seriesTypes.column) {
  4510. var dLPosition = {
  4511. x: stackBox.x + (chart.inverted ? h : xWidth / 2),
  4512. y: stackBox.y,
  4513. z: columnSeries.options.depth / 2
  4514. };
  4515. if (chart.inverted) {
  4516. // Do not use default offset calculation logic
  4517. // for 3D inverted stackLabels.
  4518. stackBox.width = 0;
  4519. // When chart is upside down
  4520. // (alpha angle between 180 and 360 degrees)
  4521. // it is needed to add column width to calculated value.
  4522. if (options3d.alpha >= 90 && options3d.alpha <= 270) {
  4523. dLPosition.y += xWidth;
  4524. }
  4525. }
  4526. dLPosition = perspective([dLPosition], chart, true, false)[0];
  4527. stackBox.x = dLPosition.x - xWidth / 2;
  4528. stackBox.y = dLPosition.y;
  4529. }
  4530. }
  4531. return stackBox;
  4532. });
  4533. /*
  4534. @merge v6.2
  4535. @todo
  4536. EXTENSION FOR 3D CYLINDRICAL COLUMNS
  4537. Not supported
  4538. */
  4539. /*
  4540. let defaultOptions = H.getOptions();
  4541. defaultOptions.plotOptions.cylinder =
  4542. merge(defaultOptions.plotOptions.column);
  4543. let CylinderSeries = extendClass(seriesTypes.column, {
  4544. type: 'cylinder'
  4545. });
  4546. seriesTypes.cylinder = CylinderSeries;
  4547. wrap(seriesTypes.cylinder.prototype, 'translate', function (proceed) {
  4548. proceed.apply(this, [].slice.call(arguments, 1));
  4549. // Do not do this if the chart is not 3D
  4550. if (!this.chart.is3d()) {
  4551. return;
  4552. }
  4553. let series = this,
  4554. chart = series.chart,
  4555. options = chart.options,
  4556. cylOptions = options.plotOptions.cylinder,
  4557. options3d = options.chart.options3d,
  4558. depth = cylOptions.depth || 0,
  4559. alpha = chart.alpha3d;
  4560. let z = cylOptions.stacking ?
  4561. (this.options.stack || 0) * depth :
  4562. series._i * depth;
  4563. z += depth / 2;
  4564. if (cylOptions.grouping !== false) { z = 0; }
  4565. each(series.data, function (point) {
  4566. let shapeArgs = point.shapeArgs,
  4567. deg2rad = H.deg2rad;
  4568. point.shapeType = 'arc3d';
  4569. shapeArgs.x += depth / 2;
  4570. shapeArgs.z = z;
  4571. shapeArgs.start = 0;
  4572. shapeArgs.end = 2 * PI;
  4573. shapeArgs.r = depth * 0.95;
  4574. shapeArgs.innerR = 0;
  4575. shapeArgs.depth =
  4576. shapeArgs.height * (1 / sin((90 - alpha) * deg2rad)) - z;
  4577. shapeArgs.alpha = 90 - alpha;
  4578. shapeArgs.beta = 0;
  4579. });
  4580. });
  4581. */
  4582. /* *
  4583. *
  4584. * Default Export
  4585. *
  4586. * */
  4587. /* *
  4588. *
  4589. * API Options
  4590. *
  4591. * */
  4592. /**
  4593. * Depth of the columns in a 3D column chart.
  4594. *
  4595. * @type {number}
  4596. * @default 25
  4597. * @since 4.0
  4598. * @product highcharts
  4599. * @requires highcharts-3d
  4600. * @apioption plotOptions.column.depth
  4601. */
  4602. /**
  4603. * 3D columns only. The color of the edges. Similar to `borderColor`, except it
  4604. * defaults to the same color as the column.
  4605. *
  4606. * @type {Highcharts.ColorString}
  4607. * @product highcharts
  4608. * @requires highcharts-3d
  4609. * @apioption plotOptions.column.edgeColor
  4610. */
  4611. /**
  4612. * 3D columns only. The width of the colored edges.
  4613. *
  4614. * @type {number}
  4615. * @default 1
  4616. * @product highcharts
  4617. * @requires highcharts-3d
  4618. * @apioption plotOptions.column.edgeWidth
  4619. */
  4620. /**
  4621. * The spacing between columns on the Z Axis in a 3D chart.
  4622. *
  4623. * @type {number}
  4624. * @default 1
  4625. * @since 4.0
  4626. * @product highcharts
  4627. * @requires highcharts-3d
  4628. * @apioption plotOptions.column.groupZPadding
  4629. */
  4630. ''; // keeps doclets above in transpiled file
  4631. return ColumnSeries;
  4632. });
  4633. _registerModule(_modules, 'Series/Pie3D/Pie3DPoint.js', [_modules['Core/Series/SeriesRegistry.js']], function (SeriesRegistry) {
  4634. /* *
  4635. *
  4636. * (c) 2010-2021 Torstein Honsi
  4637. *
  4638. * 3D pie series
  4639. *
  4640. * License: www.highcharts.com/license
  4641. *
  4642. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4643. *
  4644. * */
  4645. var __extends = (this && this.__extends) || (function () {
  4646. var extendStatics = function (d,
  4647. b) {
  4648. extendStatics = Object.setPrototypeOf ||
  4649. ({ __proto__: [] } instanceof Array && function (d,
  4650. b) { d.__proto__ = b; }) ||
  4651. function (d,
  4652. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4653. return extendStatics(d, b);
  4654. };
  4655. return function (d, b) {
  4656. extendStatics(d, b);
  4657. function __() { this.constructor = d; }
  4658. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4659. };
  4660. })();
  4661. var PiePoint = SeriesRegistry.seriesTypes.pie.prototype.pointClass;
  4662. /* *
  4663. *
  4664. * Constants
  4665. *
  4666. * */
  4667. var superHaloPath = PiePoint.prototype.haloPath;
  4668. /* *
  4669. *
  4670. * Class
  4671. *
  4672. * */
  4673. var Pie3DPoint = /** @class */ (function (_super) {
  4674. __extends(Pie3DPoint, _super);
  4675. function Pie3DPoint() {
  4676. /* *
  4677. *
  4678. * Properties
  4679. *
  4680. * */
  4681. var _this = _super !== null && _super.apply(this,
  4682. arguments) || this;
  4683. _this.series = void 0;
  4684. return _this;
  4685. /* eslint-enable valid-jsdoc */
  4686. }
  4687. /* *
  4688. *
  4689. * Functions
  4690. *
  4691. * */
  4692. /* eslint-disable valid-jsdoc */
  4693. /**
  4694. * @private
  4695. */
  4696. Pie3DPoint.prototype.haloPath = function () {
  4697. return this.series.chart.is3d() ? [] : superHaloPath.apply(this, arguments);
  4698. };
  4699. return Pie3DPoint;
  4700. }(PiePoint));
  4701. /* *
  4702. *
  4703. * Default Export
  4704. *
  4705. * */
  4706. return Pie3DPoint;
  4707. });
  4708. _registerModule(_modules, 'Series/Pie3D/Pie3DSeries.js', [_modules['Core/Globals.js'], _modules['Series/Pie3D/Pie3DPoint.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (H, Pie3DPoint, SeriesRegistry, U) {
  4709. /* *
  4710. *
  4711. * (c) 2010-2021 Torstein Honsi
  4712. *
  4713. * 3D pie series
  4714. *
  4715. * License: www.highcharts.com/license
  4716. *
  4717. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4718. *
  4719. * */
  4720. var __extends = (this && this.__extends) || (function () {
  4721. var extendStatics = function (d,
  4722. b) {
  4723. extendStatics = Object.setPrototypeOf ||
  4724. ({ __proto__: [] } instanceof Array && function (d,
  4725. b) { d.__proto__ = b; }) ||
  4726. function (d,
  4727. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4728. return extendStatics(d, b);
  4729. };
  4730. return function (d, b) {
  4731. extendStatics(d, b);
  4732. function __() { this.constructor = d; }
  4733. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4734. };
  4735. })();
  4736. var deg2rad = H.deg2rad,
  4737. svg = H.svg;
  4738. var PieSeries = SeriesRegistry.seriesTypes.pie;
  4739. var extend = U.extend,
  4740. pick = U.pick;
  4741. /* *
  4742. *
  4743. * Class
  4744. *
  4745. * */
  4746. var Pie3DSeries = /** @class */ (function (_super) {
  4747. __extends(Pie3DSeries, _super);
  4748. function Pie3DSeries() {
  4749. return _super !== null && _super.apply(this, arguments) || this;
  4750. }
  4751. /* *
  4752. *
  4753. * Functions
  4754. *
  4755. * */
  4756. /* eslint-disable valid-jsdoc */
  4757. /**
  4758. * @private
  4759. */
  4760. Pie3DSeries.prototype.addPoint = function () {
  4761. _super.prototype.addPoint.apply(this, arguments);
  4762. if (this.chart.is3d()) {
  4763. // destroy (and rebuild) everything!!!
  4764. this.update(this.userOptions, true); // #3845 pass the old options
  4765. }
  4766. };
  4767. /**
  4768. * @private
  4769. */
  4770. Pie3DSeries.prototype.animate = function (init) {
  4771. if (!this.chart.is3d()) {
  4772. _super.prototype.animate.apply(this, arguments);
  4773. }
  4774. else {
  4775. var animation = this.options.animation,
  4776. attribs = void 0,
  4777. center = this.center,
  4778. group = this.group,
  4779. markerGroup = this.markerGroup;
  4780. if (svg) { // VML is too slow anyway
  4781. if (animation === true) {
  4782. animation = {};
  4783. }
  4784. // Initialize the animation
  4785. if (init) {
  4786. // Scale down the group and place it in the center
  4787. group.oldtranslateX = pick(group.oldtranslateX, group.translateX);
  4788. group.oldtranslateY = pick(group.oldtranslateY, group.translateY);
  4789. attribs = {
  4790. translateX: center[0],
  4791. translateY: center[1],
  4792. scaleX: 0.001,
  4793. scaleY: 0.001
  4794. };
  4795. group.attr(attribs);
  4796. if (markerGroup) {
  4797. markerGroup.attrSetters = group.attrSetters;
  4798. markerGroup.attr(attribs);
  4799. }
  4800. // Run the animation
  4801. }
  4802. else {
  4803. attribs = {
  4804. translateX: group.oldtranslateX,
  4805. translateY: group.oldtranslateY,
  4806. scaleX: 1,
  4807. scaleY: 1
  4808. };
  4809. group.animate(attribs, animation);
  4810. if (markerGroup) {
  4811. markerGroup.animate(attribs, animation);
  4812. }
  4813. }
  4814. }
  4815. }
  4816. };
  4817. /**
  4818. * @private
  4819. */
  4820. Pie3DSeries.prototype.drawDataLabels = function () {
  4821. if (this.chart.is3d()) {
  4822. var series = this,
  4823. chart = series.chart,
  4824. options3d_1 = chart.options.chart.options3d;
  4825. series.data.forEach(function (point) {
  4826. var shapeArgs = point.shapeArgs,
  4827. r = shapeArgs.r,
  4828. // #3240 issue with datalabels for 0 and null values
  4829. a1 = (shapeArgs.alpha || options3d_1.alpha) * deg2rad,
  4830. b1 = (shapeArgs.beta || options3d_1.beta) * deg2rad,
  4831. a2 = (shapeArgs.start + shapeArgs.end) / 2,
  4832. labelPosition = point.labelPosition,
  4833. connectorPosition = labelPosition.connectorPosition,
  4834. yOffset = (-r * (1 - Math.cos(a1)) * Math.sin(a2)),
  4835. xOffset = r * (Math.cos(b1) - 1) * Math.cos(a2);
  4836. // Apply perspective on label positions
  4837. [
  4838. labelPosition.natural,
  4839. connectorPosition.breakAt,
  4840. connectorPosition.touchingSliceAt
  4841. ].forEach(function (coordinates) {
  4842. coordinates.x += xOffset;
  4843. coordinates.y += yOffset;
  4844. });
  4845. });
  4846. }
  4847. _super.prototype.drawDataLabels.apply(this, arguments);
  4848. };
  4849. /**
  4850. * @private
  4851. */
  4852. Pie3DSeries.prototype.pointAttribs = function (point) {
  4853. var attr = _super.prototype.pointAttribs.apply(this,
  4854. arguments),
  4855. options = this.options;
  4856. if (this.chart.is3d() && !this.chart.styledMode) {
  4857. attr.stroke = options.edgeColor || point.color || this.color;
  4858. attr['stroke-width'] = pick(options.edgeWidth, 1);
  4859. }
  4860. return attr;
  4861. };
  4862. /**
  4863. * @private
  4864. */
  4865. Pie3DSeries.prototype.translate = function () {
  4866. _super.prototype.translate.apply(this, arguments);
  4867. // Do not do this if the chart is not 3D
  4868. if (!this.chart.is3d()) {
  4869. return;
  4870. }
  4871. var series = this,
  4872. seriesOptions = series.options,
  4873. depth = seriesOptions.depth || 0,
  4874. options3d = series.chart.options.chart.options3d,
  4875. alpha = options3d.alpha,
  4876. beta = options3d.beta,
  4877. z = seriesOptions.stacking ?
  4878. (seriesOptions.stack || 0) * depth :
  4879. series._i * depth;
  4880. z += depth / 2;
  4881. if (seriesOptions.grouping !== false) {
  4882. z = 0;
  4883. }
  4884. series.data.forEach(function (point) {
  4885. var shapeArgs = point.shapeArgs,
  4886. angle;
  4887. point.shapeType = 'arc3d';
  4888. shapeArgs.z = z;
  4889. shapeArgs.depth = depth * 0.75;
  4890. shapeArgs.alpha = alpha;
  4891. shapeArgs.beta = beta;
  4892. shapeArgs.center = series.center;
  4893. angle = (shapeArgs.end + shapeArgs.start) / 2;
  4894. point.slicedTranslation = {
  4895. translateX: Math.round(Math.cos(angle) *
  4896. seriesOptions.slicedOffset *
  4897. Math.cos(alpha * deg2rad)),
  4898. translateY: Math.round(Math.sin(angle) *
  4899. seriesOptions.slicedOffset *
  4900. Math.cos(alpha * deg2rad))
  4901. };
  4902. });
  4903. };
  4904. return Pie3DSeries;
  4905. }(PieSeries));
  4906. extend(Pie3DSeries.prototype, {
  4907. pointClass: Pie3DPoint
  4908. });
  4909. /* *
  4910. *
  4911. * Default Export
  4912. *
  4913. * */
  4914. /* *
  4915. *
  4916. * API Options
  4917. *
  4918. * */
  4919. /**
  4920. * The thickness of a 3D pie.
  4921. *
  4922. * @type {number}
  4923. * @default 0
  4924. * @since 4.0
  4925. * @product highcharts
  4926. * @requires highcharts-3d
  4927. * @apioption plotOptions.pie.depth
  4928. */
  4929. ''; // keeps doclets above after transpilation
  4930. return Pie3DSeries;
  4931. });
  4932. _registerModule(_modules, 'Series/Pie3D/Pie3DComposition.js', [_modules['Series/Pie3D/Pie3DPoint.js'], _modules['Series/Pie3D/Pie3DSeries.js'], _modules['Core/Series/SeriesRegistry.js']], function (Pie3DPoint, Pie3DSeries, SeriesRegistry) {
  4933. /* *
  4934. *
  4935. * (c) 2010-2021 Torstein Honsi
  4936. *
  4937. * 3D pie series
  4938. *
  4939. * License: www.highcharts.com/license
  4940. *
  4941. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4942. *
  4943. * */
  4944. /* *
  4945. *
  4946. * Imports
  4947. *
  4948. * */
  4949. /* *
  4950. *
  4951. * Composition
  4952. *
  4953. * */
  4954. SeriesRegistry.seriesTypes.pie.prototype.pointClass.prototype.haloPath = Pie3DPoint.prototype.haloPath;
  4955. SeriesRegistry.seriesTypes.pie = Pie3DSeries;
  4956. });
  4957. _registerModule(_modules, 'Series/Scatter3D/Scatter3DPoint.js', [_modules['Series/Scatter/ScatterSeries.js'], _modules['Core/Utilities.js']], function (ScatterSeries, U) {
  4958. /* *
  4959. *
  4960. * (c) 2010-2021 Torstein Honsi
  4961. *
  4962. * Scatter 3D series.
  4963. *
  4964. * License: www.highcharts.com/license
  4965. *
  4966. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4967. *
  4968. * */
  4969. var __extends = (this && this.__extends) || (function () {
  4970. var extendStatics = function (d,
  4971. b) {
  4972. extendStatics = Object.setPrototypeOf ||
  4973. ({ __proto__: [] } instanceof Array && function (d,
  4974. b) { d.__proto__ = b; }) ||
  4975. function (d,
  4976. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4977. return extendStatics(d, b);
  4978. };
  4979. return function (d, b) {
  4980. extendStatics(d, b);
  4981. function __() { this.constructor = d; }
  4982. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4983. };
  4984. })();
  4985. var defined = U.defined;
  4986. /* *
  4987. *
  4988. * Class
  4989. *
  4990. * */
  4991. var Scatter3DPoint = /** @class */ (function (_super) {
  4992. __extends(Scatter3DPoint, _super);
  4993. function Scatter3DPoint() {
  4994. /* *
  4995. *
  4996. * Properties
  4997. *
  4998. * */
  4999. var _this = _super !== null && _super.apply(this,
  5000. arguments) || this;
  5001. _this.options = void 0;
  5002. _this.series = void 0;
  5003. return _this;
  5004. }
  5005. /* *
  5006. *
  5007. * Functions
  5008. *
  5009. * */
  5010. Scatter3DPoint.prototype.applyOptions = function () {
  5011. _super.prototype.applyOptions.apply(this, arguments);
  5012. if (!defined(this.z)) {
  5013. this.z = 0;
  5014. }
  5015. return this;
  5016. };
  5017. return Scatter3DPoint;
  5018. }(ScatterSeries.prototype.pointClass));
  5019. /* *
  5020. *
  5021. * Default Export
  5022. *
  5023. * */
  5024. return Scatter3DPoint;
  5025. });
  5026. _registerModule(_modules, 'Series/Scatter3D/Scatter3DSeries.js', [_modules['Extensions/Math3D.js'], _modules['Series/Scatter3D/Scatter3DPoint.js'], _modules['Series/Scatter/ScatterSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Math3D, Scatter3DPoint, ScatterSeries, SeriesRegistry, U) {
  5027. /* *
  5028. *
  5029. * (c) 2010-2021 Torstein Honsi
  5030. *
  5031. * Scatter 3D series.
  5032. *
  5033. * License: www.highcharts.com/license
  5034. *
  5035. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5036. *
  5037. * */
  5038. var __extends = (this && this.__extends) || (function () {
  5039. var extendStatics = function (d,
  5040. b) {
  5041. extendStatics = Object.setPrototypeOf ||
  5042. ({ __proto__: [] } instanceof Array && function (d,
  5043. b) { d.__proto__ = b; }) ||
  5044. function (d,
  5045. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5046. return extendStatics(d, b);
  5047. };
  5048. return function (d, b) {
  5049. extendStatics(d, b);
  5050. function __() { this.constructor = d; }
  5051. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5052. };
  5053. })();
  5054. var pointCameraDistance = Math3D.pointCameraDistance;
  5055. var extend = U.extend,
  5056. merge = U.merge;
  5057. /* *
  5058. *
  5059. * Class
  5060. *
  5061. * */
  5062. /**
  5063. * @private
  5064. * @class
  5065. * @name Highcharts.seriesTypes.scatter3d
  5066. *
  5067. * @augments Highcharts.Series
  5068. */
  5069. var Scatter3DSeries = /** @class */ (function (_super) {
  5070. __extends(Scatter3DSeries, _super);
  5071. function Scatter3DSeries() {
  5072. /* *
  5073. *
  5074. * Static Properties
  5075. *
  5076. * */
  5077. var _this = _super !== null && _super.apply(this,
  5078. arguments) || this;
  5079. /* *
  5080. *
  5081. * Properties
  5082. *
  5083. * */
  5084. _this.data = void 0;
  5085. _this.options = void 0;
  5086. _this.points = void 0;
  5087. return _this;
  5088. }
  5089. /* *
  5090. *
  5091. * Functions
  5092. *
  5093. * */
  5094. Scatter3DSeries.prototype.pointAttribs = function (point) {
  5095. var attribs = _super.prototype.pointAttribs.apply(this,
  5096. arguments);
  5097. if (this.chart.is3d() && point) {
  5098. attribs.zIndex =
  5099. pointCameraDistance(point, this.chart);
  5100. }
  5101. return attribs;
  5102. };
  5103. /**
  5104. * A 3D scatter plot uses x, y and z coordinates to display values for three
  5105. * variables for a set of data.
  5106. *
  5107. * @sample {highcharts} highcharts/3d/scatter/
  5108. * Simple 3D scatter
  5109. * @sample {highcharts} highcharts/demo/3d-scatter-draggable
  5110. * Draggable 3d scatter
  5111. *
  5112. * @extends plotOptions.scatter
  5113. * @excluding dragDrop, cluster, boostThreshold, boostBlending
  5114. * @product highcharts
  5115. * @requires highcharts-3d
  5116. * @optionparent plotOptions.scatter3d
  5117. */
  5118. Scatter3DSeries.defaultOptions = merge(ScatterSeries.defaultOptions, {
  5119. tooltip: {
  5120. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>z: <b>{point.z}</b><br/>'
  5121. }
  5122. });
  5123. return Scatter3DSeries;
  5124. }(ScatterSeries));
  5125. extend(Scatter3DSeries.prototype, {
  5126. axisTypes: ['xAxis', 'yAxis', 'zAxis'],
  5127. // Require direct touch rather than using the k-d-tree, because the
  5128. // k-d-tree currently doesn't take the xyz coordinate system into
  5129. // account (#4552)
  5130. directTouch: true,
  5131. parallelArrays: ['x', 'y', 'z'],
  5132. pointArrayMap: ['x', 'y', 'z'],
  5133. pointClass: Scatter3DPoint
  5134. });
  5135. SeriesRegistry.registerSeriesType('scatter3d', Scatter3DSeries);
  5136. /* *
  5137. *
  5138. * Default Export
  5139. *
  5140. * */
  5141. /* *
  5142. *
  5143. * API Options
  5144. *
  5145. * */
  5146. /**
  5147. * A `scatter3d` series. If the [type](#series.scatter3d.type) option is
  5148. * not specified, it is inherited from [chart.type](#chart.type).
  5149. *
  5150. * scatter3d](#plotOptions.scatter3d).
  5151. *
  5152. * @extends series,plotOptions.scatter3d
  5153. * @excluding boostThreshold, boostBlending
  5154. * @product highcharts
  5155. * @requires highcharts-3d
  5156. * @apioption series.scatter3d
  5157. */
  5158. /**
  5159. * An array of data points for the series. For the `scatter3d` series
  5160. * type, points can be given in the following ways:
  5161. *
  5162. * 1. An array of arrays with 3 values. In this case, the values correspond
  5163. * to `x,y,z`. If the first value is a string, it is applied as the name
  5164. * of the point, and the `x` value is inferred.
  5165. *
  5166. * ```js
  5167. * data: [
  5168. * [0, 0, 1],
  5169. * [1, 8, 7],
  5170. * [2, 9, 2]
  5171. * ]
  5172. * ```
  5173. *
  5174. * 3. An array of objects with named values. The following snippet shows only a
  5175. * few settings, see the complete options set below. If the total number of data
  5176. * points exceeds the series'
  5177. * [turboThreshold](#series.scatter3d.turboThreshold), this option is not
  5178. * available.
  5179. *
  5180. * ```js
  5181. * data: [{
  5182. * x: 1,
  5183. * y: 2,
  5184. * z: 24,
  5185. * name: "Point2",
  5186. * color: "#00FF00"
  5187. * }, {
  5188. * x: 1,
  5189. * y: 4,
  5190. * z: 12,
  5191. * name: "Point1",
  5192. * color: "#FF00FF"
  5193. * }]
  5194. * ```
  5195. *
  5196. * @sample {highcharts} highcharts/chart/reflow-true/
  5197. * Numerical values
  5198. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  5199. * Arrays of numeric x and y
  5200. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  5201. * Arrays of datetime x and y
  5202. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  5203. * Arrays of point.name and y
  5204. * @sample {highcharts} highcharts/series/data-array-of-objects/
  5205. * Config objects
  5206. *
  5207. * @type {Array<Array<number>|*>}
  5208. * @extends series.scatter.data
  5209. * @product highcharts
  5210. * @apioption series.scatter3d.data
  5211. */
  5212. /**
  5213. * The z value for each data point.
  5214. *
  5215. * @type {number}
  5216. * @product highcharts
  5217. * @apioption series.scatter3d.data.z
  5218. */
  5219. ''; // adds doclets above to transpiled file
  5220. return Scatter3DSeries;
  5221. });
  5222. _registerModule(_modules, 'Series/Area3DSeries.js', [_modules['Extensions/Math3D.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Math3D, SeriesRegistry, U) {
  5223. /* *
  5224. *
  5225. * (c) 2010-2021 Grzegorz Blachliński
  5226. *
  5227. * License: www.highcharts.com/license
  5228. *
  5229. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5230. *
  5231. * */
  5232. var perspective = Math3D.perspective;
  5233. var _a = SeriesRegistry.seriesTypes,
  5234. AreaSeriesClass = _a.area,
  5235. LineSeriesClass = _a.line;
  5236. var pick = U.pick,
  5237. wrap = U.wrap;
  5238. /* eslint-disable no-invalid-this */
  5239. wrap(AreaSeriesClass.prototype, 'getGraphPath', function (proceed) {
  5240. var series = this,
  5241. svgPath = proceed.apply(series,
  5242. [].slice.call(arguments, 1));
  5243. // Do not do this if the chart is not 3D
  5244. if (!series.chart.is3d()) {
  5245. return svgPath;
  5246. }
  5247. var getGraphPath = LineSeriesClass.prototype.getGraphPath,
  5248. graphPath = [],
  5249. options = series.options,
  5250. stacking = options.stacking,
  5251. bottomPath,
  5252. bottomPoints = [],
  5253. graphPoints = [],
  5254. i,
  5255. areaPath,
  5256. connectNulls = pick(// #10574
  5257. options.connectNulls,
  5258. stacking === 'percent'),
  5259. translatedThreshold = Math.round(// #10909
  5260. series.yAxis.getThreshold(options.threshold)),
  5261. options3d;
  5262. if (series.rawPointsX) {
  5263. for (var i_1 = 0; i_1 < series.points.length; i_1++) {
  5264. bottomPoints.push({
  5265. x: series.rawPointsX[i_1],
  5266. y: options.stacking ? series.points[i_1].yBottom : translatedThreshold,
  5267. z: series.zPadding
  5268. });
  5269. }
  5270. }
  5271. options3d = series.chart.options.chart.options3d;
  5272. bottomPoints = perspective(bottomPoints, series.chart, true).map(function (point) {
  5273. return { plotX: point.x, plotY: point.y, plotZ: point.z };
  5274. });
  5275. if (series.group && options3d && options3d.depth && options3d.beta) {
  5276. // Markers should take the global zIndex of series group.
  5277. if (series.markerGroup) {
  5278. series.markerGroup.add(series.group);
  5279. series.markerGroup.attr({
  5280. translateX: 0,
  5281. translateY: 0
  5282. });
  5283. }
  5284. series.group.attr({
  5285. zIndex: Math.max(1, (options3d.beta > 270 || options3d.beta < 90) ?
  5286. options3d.depth - Math.round(series.zPadding || 0) :
  5287. Math.round(series.zPadding || 0))
  5288. });
  5289. }
  5290. bottomPoints.reversed = true;
  5291. bottomPath = getGraphPath.call(series, bottomPoints, true, true);
  5292. if (bottomPath[0] && bottomPath[0][0] === 'M') {
  5293. bottomPath[0] = ['L', bottomPath[0][1], bottomPath[0][2]];
  5294. }
  5295. if (series.areaPath) {
  5296. // Remove previously used bottomPath and add the new one.
  5297. areaPath = series.areaPath.splice(0, series.areaPath.length / 2).concat(bottomPath);
  5298. areaPath.xMap = series.areaPath.xMap; // Use old xMap in the new areaPath
  5299. series.areaPath = areaPath;
  5300. graphPath = getGraphPath.call(series, graphPoints, false, connectNulls);
  5301. }
  5302. return svgPath;
  5303. });
  5304. });
  5305. _registerModule(_modules, 'masters/highcharts-3d.src.js', [], function () {
  5306. });
  5307. }));