Series.js 214 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499
  1. /* *
  2. *
  3. * (c) 2010-2020 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. import H from './Globals.js';
  12. import LegendSymbolMixin from '../mixins/legend-symbol.js';
  13. import O from './Options.js';
  14. var defaultOptions = O.defaultOptions;
  15. import Point from './Point.js';
  16. import SVGElement from './SVGElement.js';
  17. import U from './Utilities.js';
  18. var addEvent = U.addEvent, animObject = U.animObject, arrayMax = U.arrayMax, arrayMin = U.arrayMin, clamp = U.clamp, correctFloat = U.correctFloat, defined = U.defined, erase = U.erase, error = U.error, extend = U.extend, find = U.find, fireEvent = U.fireEvent, getNestedProperty = U.getNestedProperty, isArray = U.isArray, isFunction = U.isFunction, isNumber = U.isNumber, isString = U.isString, merge = U.merge, objectEach = U.objectEach, pick = U.pick, removeEvent = U.removeEvent, seriesType = U.seriesType, splat = U.splat, syncTimeout = U.syncTimeout;
  19. /**
  20. * This is a placeholder type of the possible series options for
  21. * [Highcharts](../highcharts/series), [Highstock](../highstock/series),
  22. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  23. *
  24. * In TypeScript is this dynamically generated to reference all possible types
  25. * of series options.
  26. *
  27. * @ignore-declaration
  28. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  29. */
  30. /**
  31. * Options for `dataSorting`.
  32. *
  33. * @interface Highcharts.DataSortingOptionsObject
  34. * @since 8.0.0
  35. */ /**
  36. * Enable or disable data sorting for the series.
  37. * @name Highcharts.DataSortingOptionsObject#enabled
  38. * @type {boolean|undefined}
  39. */ /**
  40. * Whether to allow matching points by name in an update.
  41. * @name Highcharts.DataSortingOptionsObject#matchByName
  42. * @type {boolean|undefined}
  43. */ /**
  44. * Determines what data value should be used to sort by.
  45. * @name Highcharts.DataSortingOptionsObject#sortKey
  46. * @type {string|undefined}
  47. */
  48. /**
  49. * Function callback when a series has been animated.
  50. *
  51. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  52. *
  53. * @param {Highcharts.Series} this
  54. * The series where the event occured.
  55. *
  56. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  57. * Event arguments.
  58. */
  59. /**
  60. * Event information regarding completed animation of a series.
  61. *
  62. * @interface Highcharts.SeriesAfterAnimateEventObject
  63. */ /**
  64. * Animated series.
  65. * @name Highcharts.SeriesAfterAnimateEventObject#target
  66. * @type {Highcharts.Series}
  67. */ /**
  68. * Event type.
  69. * @name Highcharts.SeriesAfterAnimateEventObject#type
  70. * @type {"afterAnimate"}
  71. */
  72. /**
  73. * Function callback when the checkbox next to the series' name in the legend is
  74. * clicked.
  75. *
  76. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  77. *
  78. * @param {Highcharts.Series} this
  79. * The series where the event occured.
  80. *
  81. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  82. * Event arguments.
  83. */
  84. /**
  85. * Event information regarding check of a series box.
  86. *
  87. * @interface Highcharts.SeriesCheckboxClickEventObject
  88. */ /**
  89. * Whether the box has been checked.
  90. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  91. * @type {boolean}
  92. */ /**
  93. * Related series.
  94. * @name Highcharts.SeriesCheckboxClickEventObject#item
  95. * @type {Highcharts.Series}
  96. */ /**
  97. * Related series.
  98. * @name Highcharts.SeriesCheckboxClickEventObject#target
  99. * @type {Highcharts.Series}
  100. */ /**
  101. * Event type.
  102. * @name Highcharts.SeriesCheckboxClickEventObject#type
  103. * @type {"checkboxClick"}
  104. */
  105. /**
  106. * Function callback when a series is clicked. Return false to cancel toogle
  107. * actions.
  108. *
  109. * @callback Highcharts.SeriesClickCallbackFunction
  110. *
  111. * @param {Highcharts.Series} this
  112. * The series where the event occured.
  113. *
  114. * @param {Highcharts.SeriesClickEventObject} event
  115. * Event arguments.
  116. */
  117. /**
  118. * Common information for a click event on a series.
  119. *
  120. * @interface Highcharts.SeriesClickEventObject
  121. * @extends global.Event
  122. */ /**
  123. * Nearest point on the graph.
  124. * @name Highcharts.SeriesClickEventObject#point
  125. * @type {Highcharts.Point}
  126. */
  127. /**
  128. * Gets fired when the series is hidden after chart generation time, either by
  129. * clicking the legend item or by calling `.hide()`.
  130. *
  131. * @callback Highcharts.SeriesHideCallbackFunction
  132. *
  133. * @param {Highcharts.Series} this
  134. * The series where the event occured.
  135. *
  136. * @param {global.Event} event
  137. * The event that occured.
  138. */
  139. /**
  140. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  141. * graph.
  142. *
  143. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  144. */
  145. /**
  146. * Gets fired when the legend item belonging to the series is clicked. The
  147. * default action is to toggle the visibility of the series. This can be
  148. * prevented by returning `false` or calling `event.preventDefault()`.
  149. *
  150. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  151. *
  152. * @param {Highcharts.Series} this
  153. * The series where the event occured.
  154. *
  155. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  156. * The event that occured.
  157. */
  158. /**
  159. * Information about the event.
  160. *
  161. * @interface Highcharts.SeriesLegendItemClickEventObject
  162. */ /**
  163. * Related browser event.
  164. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  165. * @type {global.PointerEvent}
  166. */ /**
  167. * Prevent the default action of toggle the visibility of the series.
  168. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  169. * @type {Function}
  170. */ /**
  171. * Related series.
  172. * @name Highcharts.SeriesCheckboxClickEventObject#target
  173. * @type {Highcharts.Series}
  174. */ /**
  175. * Event type.
  176. * @name Highcharts.SeriesCheckboxClickEventObject#type
  177. * @type {"checkboxClick"}
  178. */
  179. /**
  180. * Gets fired when the mouse leaves the graph.
  181. *
  182. * @callback Highcharts.SeriesMouseOutCallbackFunction
  183. *
  184. * @param {Highcharts.Series} this
  185. * Series where the event occured.
  186. *
  187. * @param {global.PointerEvent} event
  188. * Event that occured.
  189. */
  190. /**
  191. * Gets fired when the mouse enters the graph.
  192. *
  193. * @callback Highcharts.SeriesMouseOverCallbackFunction
  194. *
  195. * @param {Highcharts.Series} this
  196. * Series where the event occured.
  197. *
  198. * @param {global.PointerEvent} event
  199. * Event that occured.
  200. */
  201. /**
  202. * Translation and scale for the plot area of a series.
  203. *
  204. * @interface Highcharts.SeriesPlotBoxObject
  205. */ /**
  206. * @name Highcharts.SeriesPlotBoxObject#scaleX
  207. * @type {number}
  208. */ /**
  209. * @name Highcharts.SeriesPlotBoxObject#scaleY
  210. * @type {number}
  211. */ /**
  212. * @name Highcharts.SeriesPlotBoxObject#translateX
  213. * @type {number}
  214. */ /**
  215. * @name Highcharts.SeriesPlotBoxObject#translateY
  216. * @type {number}
  217. */
  218. /**
  219. * Gets fired when the series is shown after chart generation time, either by
  220. * clicking the legend item or by calling `.show()`.
  221. *
  222. * @callback Highcharts.SeriesShowCallbackFunction
  223. *
  224. * @param {Highcharts.Series} this
  225. * Series where the event occured.
  226. *
  227. * @param {global.Event} event
  228. * Event that occured.
  229. */
  230. /**
  231. * Possible key values for the series state options.
  232. *
  233. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  234. */
  235. ''; // detach doclets above
  236. var seriesTypes = H.seriesTypes, win = H.win;
  237. /**
  238. * This is the base series prototype that all other series types inherit from.
  239. * A new series is initialized either through the
  240. * [series](https://api.highcharts.com/highcharts/series)
  241. * option structure, or after the chart is initialized, through
  242. * {@link Highcharts.Chart#addSeries}.
  243. *
  244. * The object can be accessed in a number of ways. All series and point event
  245. * handlers give a reference to the `series` object. The chart object has a
  246. * {@link Highcharts.Chart#series|series} property that is a collection of all
  247. * the chart's series. The point objects and axis objects also have the same
  248. * reference.
  249. *
  250. * Another way to reference the series programmatically is by `id`. Add an id
  251. * in the series configuration options, and get the series object by
  252. * {@link Highcharts.Chart#get}.
  253. *
  254. * Configuration options for the series are given in three levels. Options for
  255. * all series in a chart are given in the
  256. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  257. * object. Then options for all series of a specific type
  258. * are given in the plotOptions of that type, for example `plotOptions.line`.
  259. * Next, options for one single series are given in the series array, or as
  260. * arguments to `chart.addSeries`.
  261. *
  262. * The data in the series is stored in various arrays.
  263. *
  264. * - First, `series.options.data` contains all the original config options for
  265. * each point whether added by options or methods like `series.addPoint`.
  266. *
  267. * - Next, `series.data` contains those values converted to points, but in case
  268. * the series data length exceeds the `cropThreshold`, or if the data is
  269. * grouped, `series.data` doesn't contain all the points. It only contains the
  270. * points that have been created on demand.
  271. *
  272. * - Then there's `series.points` that contains all currently visible point
  273. * objects. In case of cropping, the cropped-away points are not part of this
  274. * array. The `series.points` array starts at `series.cropStart` compared to
  275. * `series.data` and `series.options.data`. If however the series data is
  276. * grouped, these can't be correlated one to one.
  277. *
  278. * - `series.xData` and `series.processedXData` contain clean x values,
  279. * equivalent to `series.data` and `series.points`.
  280. *
  281. * - `series.yData` and `series.processedYData` contain clean y values,
  282. * equivalent to `series.data` and `series.points`.
  283. *
  284. * @class
  285. * @name Highcharts.Series
  286. *
  287. * @param {Highcharts.Chart} chart
  288. * The chart instance.
  289. *
  290. * @param {Highcharts.SeriesOptionsType|object} options
  291. * The series options.
  292. */ /**
  293. * The line series is the base type and is therefor the series base prototype.
  294. *
  295. * @private
  296. * @class
  297. * @name Highcharts.seriesTypes.line
  298. *
  299. * @augments Highcharts.Series
  300. */
  301. H.Series = seriesType('line',
  302. /**
  303. * Series options for specific data and the data itself. In TypeScript you
  304. * have to cast the series options to specific series types, to get all
  305. * possible options for a series.
  306. *
  307. * @example
  308. * // TypeScript example
  309. * Highcharts.chart('container', {
  310. * series: [{
  311. * color: '#06C',
  312. * data: [[0, 1], [2, 3]]
  313. * } as Highcharts.SeriesLineOptions ]
  314. * });
  315. *
  316. * @type {Array<*>}
  317. * @apioption series
  318. */
  319. /**
  320. * An id for the series. This can be used after render time to get a pointer
  321. * to the series object through `chart.get()`.
  322. *
  323. * @sample {highcharts} highcharts/plotoptions/series-id/
  324. * Get series by id
  325. *
  326. * @type {string}
  327. * @since 1.2.0
  328. * @apioption series.id
  329. */
  330. /**
  331. * The index of the series in the chart, affecting the internal index in the
  332. * `chart.series` array, the visible Z index as well as the order in the
  333. * legend.
  334. *
  335. * @type {number}
  336. * @since 2.3.0
  337. * @apioption series.index
  338. */
  339. /**
  340. * The sequential index of the series in the legend.
  341. *
  342. * @see [legend.reversed](#legend.reversed),
  343. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  344. *
  345. * @sample {highcharts|highstock} highcharts/series/legendindex/
  346. * Legend in opposite order
  347. *
  348. * @type {number}
  349. * @apioption series.legendIndex
  350. */
  351. /**
  352. * The name of the series as shown in the legend, tooltip etc.
  353. *
  354. * @sample {highcharts} highcharts/series/name/
  355. * Series name
  356. * @sample {highmaps} maps/demo/category-map/
  357. * Series name
  358. *
  359. * @type {string}
  360. * @apioption series.name
  361. */
  362. /**
  363. * This option allows grouping series in a stacked chart. The stack option
  364. * can be a string or anything else, as long as the grouped series' stack
  365. * options match each other after conversion into a string.
  366. *
  367. * @sample {highcharts} highcharts/series/stack/
  368. * Stacked and grouped columns
  369. *
  370. * @type {number|string}
  371. * @since 2.1
  372. * @product highcharts highstock
  373. * @apioption series.stack
  374. */
  375. /**
  376. * The type of series, for example `line` or `column`. By default, the
  377. * series type is inherited from [chart.type](#chart.type), so unless the
  378. * chart is a combination of series types, there is no need to set it on the
  379. * series level.
  380. *
  381. * @sample {highcharts} highcharts/series/type/
  382. * Line and column in the same chart
  383. * @sample highcharts/series/type-dynamic/
  384. * Dynamic types with button selector
  385. * @sample {highmaps} maps/demo/mapline-mappoint/
  386. * Multiple types in the same map
  387. *
  388. * @type {string}
  389. * @apioption series.type
  390. */
  391. /**
  392. * When using dual or multiple x axes, this number defines which xAxis the
  393. * particular series is connected to. It refers to either the
  394. * {@link #xAxis.id|axis id}
  395. * or the index of the axis in the xAxis array, with 0 being the first.
  396. *
  397. * @type {number|string}
  398. * @default 0
  399. * @product highcharts highstock
  400. * @apioption series.xAxis
  401. */
  402. /**
  403. * When using dual or multiple y axes, this number defines which yAxis the
  404. * particular series is connected to. It refers to either the
  405. * {@link #yAxis.id|axis id}
  406. * or the index of the axis in the yAxis array, with 0 being the first.
  407. *
  408. * @sample {highcharts} highcharts/series/yaxis/
  409. * Apply the column series to the secondary Y axis
  410. *
  411. * @type {number|string}
  412. * @default 0
  413. * @product highcharts highstock
  414. * @apioption series.yAxis
  415. */
  416. /**
  417. * Define the visual z index of the series.
  418. *
  419. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  420. * With no z index, the series defined last are on top
  421. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  422. * With a z index, the series with the highest z index is on top
  423. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  424. * With no z index, the series defined last are on top
  425. * @sample {highstock} highcharts/plotoptions/series-zindex/
  426. * With a z index, the series with the highest z index is on top
  427. *
  428. * @type {number}
  429. * @product highcharts highstock
  430. * @apioption series.zIndex
  431. */
  432. null,
  433. /**
  434. * General options for all series types.
  435. *
  436. * @optionparent plotOptions.series
  437. */
  438. {
  439. /**
  440. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  441. * of a line graph. Round means that lines are rounded in the ends and
  442. * bends.
  443. *
  444. * @type {Highcharts.SeriesLinecapValue}
  445. * @default round
  446. * @since 3.0.7
  447. * @apioption plotOptions.line.linecap
  448. */
  449. /**
  450. * Pixel width of the graph line.
  451. *
  452. * @see In styled mode, the line stroke-width can be set with the
  453. * `.highcharts-graph` class name.
  454. *
  455. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  456. * On all series
  457. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  458. * On one single series
  459. *
  460. * @product highcharts highstock
  461. *
  462. * @private
  463. */
  464. lineWidth: 2,
  465. /**
  466. * For some series, there is a limit that shuts down initial animation
  467. * by default when the total number of points in the chart is too high.
  468. * For example, for a column chart and its derivatives, animation does
  469. * not run if there is more than 250 points totally. To disable this
  470. * cap, set `animationLimit` to `Infinity`.
  471. *
  472. * @type {number}
  473. * @apioption plotOptions.series.animationLimit
  474. */
  475. /**
  476. * Allow this series' points to be selected by clicking on the graphic
  477. * (columns, point markers, pie slices, map areas etc).
  478. *
  479. * The selected points can be handled by point select and unselect
  480. * events, or collectively by the [getSelectedPoints
  481. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  482. *
  483. * And alternative way of selecting points is through dragging.
  484. *
  485. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  486. * Line
  487. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  488. * Column
  489. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  490. * Pie
  491. * @sample {highcharts} highcharts/chart/events-selection-points/
  492. * Select a range of points through a drag selection
  493. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  494. * Map area
  495. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  496. * Map bubble
  497. *
  498. * @since 1.2.0
  499. *
  500. * @private
  501. */
  502. allowPointSelect: false,
  503. /**
  504. * When true, each point or column edge is rounded to its nearest pixel
  505. * in order to render sharp on screen. In some cases, when there are a
  506. * lot of densely packed columns, this leads to visible difference
  507. * in column widths or distance between columns. In these cases,
  508. * setting `crisp` to `false` may look better, even though each column
  509. * is rendered blurry.
  510. *
  511. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  512. * Crisp is false
  513. *
  514. * @since 5.0.10
  515. * @product highcharts highstock gantt
  516. *
  517. * @private
  518. */
  519. crisp: true,
  520. /**
  521. * If true, a checkbox is displayed next to the legend item to allow
  522. * selecting the series. The state of the checkbox is determined by
  523. * the `selected` option.
  524. *
  525. * @productdesc {highmaps}
  526. * Note that if a `colorAxis` is defined, the color axis is represented
  527. * in the legend, not the series.
  528. *
  529. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  530. * Show select box
  531. *
  532. * @since 1.2.0
  533. *
  534. * @private
  535. */
  536. showCheckbox: false,
  537. /**
  538. * Enable or disable the initial animation when a series is displayed.
  539. * The animation can also be set as a configuration object. Please
  540. * note that this option only applies to the initial animation of the
  541. * series itself. For other animations, see [chart.animation](
  542. * #chart.animation) and the animation parameter under the API methods.
  543. * The following properties are supported:
  544. *
  545. * - `duration`: The duration of the animation in milliseconds.
  546. *
  547. * - `easing`: Can be a string reference to an easing function set on
  548. * the `Math` object or a function. See the _Custom easing function_
  549. * demo below.
  550. *
  551. * Due to poor performance, animation is disabled in old IE browsers
  552. * for several chart types.
  553. *
  554. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  555. * Animation disabled
  556. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  557. * Slower animation
  558. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  559. * Custom easing function
  560. * @sample {highstock} stock/plotoptions/animation-slower/
  561. * Slower animation
  562. * @sample {highstock} stock/plotoptions/animation-easing/
  563. * Custom easing function
  564. * @sample {highmaps} maps/plotoptions/series-animation-true/
  565. * Animation enabled on map series
  566. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  567. * Disabled on mapbubble series
  568. *
  569. * @type {boolean|Highcharts.AnimationOptionsObject}
  570. * @default {highcharts} true
  571. * @default {highstock} true
  572. * @default {highmaps} false
  573. *
  574. * @private
  575. */
  576. animation: {
  577. /** @internal */
  578. duration: 1000
  579. },
  580. /**
  581. * An additional class name to apply to the series' graphical elements.
  582. * This option does not replace default class names of the graphical
  583. * element.
  584. *
  585. * @type {string}
  586. * @since 5.0.0
  587. * @apioption plotOptions.series.className
  588. */
  589. /**
  590. * Disable this option to allow series rendering in the whole plotting
  591. * area.
  592. *
  593. * **Note:** Clipping should be always enabled when
  594. * [chart.zoomType](#chart.zoomType) is set
  595. *
  596. * @sample {highcharts} highcharts/plotoptions/series-clip/
  597. * Disabled clipping
  598. *
  599. * @default true
  600. * @type {boolean}
  601. * @since 3.0.0
  602. * @apioption plotOptions.series.clip
  603. */
  604. /**
  605. * The main color of the series. In line type series it applies to the
  606. * line and the point markers unless otherwise specified. In bar type
  607. * series it applies to the bars unless a color is specified per point.
  608. * The default value is pulled from the `options.colors` array.
  609. *
  610. * In styled mode, the color can be defined by the
  611. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  612. * color can be set with the `.highcharts-series`,
  613. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  614. * `.highcharts-series-{n}` class, or individual classes given by the
  615. * `className` option.
  616. *
  617. * @productdesc {highmaps}
  618. * In maps, the series color is rarely used, as most choropleth maps use
  619. * the color to denote the value of each point. The series color can
  620. * however be used in a map with multiple series holding categorized
  621. * data.
  622. *
  623. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  624. * General plot option
  625. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  626. * One specific series
  627. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  628. * Area color
  629. * @sample {highcharts} highcharts/series/infographic/
  630. * Pattern fill
  631. * @sample {highmaps} maps/demo/category-map/
  632. * Category map by multiple series
  633. *
  634. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  635. * @apioption plotOptions.series.color
  636. */
  637. /**
  638. * Styled mode only. A specific color index to use for the series, so
  639. * its graphic representations are given the class name
  640. * `highcharts-color-{n}`.
  641. *
  642. * @type {number}
  643. * @since 5.0.0
  644. * @apioption plotOptions.series.colorIndex
  645. */
  646. /**
  647. * Whether to connect a graph line across null points, or render a gap
  648. * between the two points on either side of the null.
  649. *
  650. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  651. * False by default
  652. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  653. * True
  654. *
  655. * @type {boolean}
  656. * @default false
  657. * @product highcharts highstock
  658. * @apioption plotOptions.series.connectNulls
  659. */
  660. /**
  661. * You can set the cursor to "pointer" if you have click events attached
  662. * to the series, to signal to the user that the points and lines can
  663. * be clicked.
  664. *
  665. * In styled mode, the series cursor can be set with the same classes
  666. * as listed under [series.color](#plotOptions.series.color).
  667. *
  668. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  669. * On line graph
  670. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  671. * On columns
  672. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  673. * On scatter markers
  674. * @sample {highstock} stock/plotoptions/cursor/
  675. * Pointer on a line graph
  676. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  677. * Map area
  678. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  679. * Map bubble
  680. *
  681. * @type {string|Highcharts.CursorValue}
  682. * @apioption plotOptions.series.cursor
  683. */
  684. /**
  685. * A reserved subspace to store options and values for customized
  686. * functionality. Here you can add additional data for your own event
  687. * callbacks and formatter callbacks.
  688. *
  689. * @sample {highcharts} highcharts/point/custom/
  690. * Point and series with custom data
  691. *
  692. * @type {Highcharts.Dictionary<*>}
  693. * @apioption plotOptions.series.custom
  694. */
  695. /**
  696. * Name of the dash style to use for the graph, or for some series types
  697. * the outline of each shape.
  698. *
  699. * In styled mode, the
  700. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  701. * can be set with the same classes as listed under
  702. * [series.color](#plotOptions.series.color).
  703. *
  704. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  705. * Possible values demonstrated
  706. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  707. * Chart suitable for printing in black and white
  708. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  709. * Possible values demonstrated
  710. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  711. * Possible values demonstrated
  712. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  713. * Dotted borders on a map
  714. *
  715. * @type {Highcharts.DashStyleValue}
  716. * @default Solid
  717. * @since 2.1
  718. * @apioption plotOptions.series.dashStyle
  719. */
  720. /**
  721. * A description of the series to add to the screen reader information
  722. * about the series.
  723. *
  724. * @type {string}
  725. * @since 5.0.0
  726. * @requires modules/accessibility
  727. * @apioption plotOptions.series.description
  728. */
  729. /**
  730. * Options for the series data sorting.
  731. *
  732. * @type {Highcharts.DataSortingOptionsObject}
  733. * @since 8.0.0
  734. * @product highcharts highstock
  735. * @apioption plotOptions.series.dataSorting
  736. */
  737. /**
  738. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  739. * #xAxis.reversed) to change the sorting order.
  740. *
  741. * @sample {highcharts} highcharts/datasorting/animation/
  742. * Data sorting in scatter-3d
  743. * @sample {highcharts} highcharts/datasorting/labels-animation/
  744. * Axis labels animation
  745. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  746. * Dependent series sorting
  747. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  748. * Independent series sorting
  749. *
  750. * @type {boolean}
  751. * @since 8.0.0
  752. * @apioption plotOptions.series.dataSorting.enabled
  753. */
  754. /**
  755. * Whether to allow matching points by name in an update. If this option
  756. * is disabled, points will be matched by order.
  757. *
  758. * @sample {highcharts} highcharts/datasorting/match-by-name/
  759. * Enabled match by name
  760. *
  761. * @type {boolean}
  762. * @since 8.0.0
  763. * @apioption plotOptions.series.dataSorting.matchByName
  764. */
  765. /**
  766. * Determines what data value should be used to sort by.
  767. *
  768. * @sample {highcharts} highcharts/datasorting/sort-key/
  769. * Sort key as `z` value
  770. *
  771. * @type {string}
  772. * @since 8.0.0
  773. * @default y
  774. * @apioption plotOptions.series.dataSorting.sortKey
  775. */
  776. /**
  777. * Enable or disable the mouse tracking for a specific series. This
  778. * includes point tooltips and click events on graphs and points. For
  779. * large datasets it improves performance.
  780. *
  781. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  782. * No mouse tracking
  783. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  784. * No mouse tracking
  785. *
  786. * @type {boolean}
  787. * @default true
  788. * @apioption plotOptions.series.enableMouseTracking
  789. */
  790. /**
  791. * Whether to use the Y extremes of the total chart width or only the
  792. * zoomed area when zooming in on parts of the X axis. By default, the
  793. * Y axis adjusts to the min and max of the visible data. Cartesian
  794. * series only.
  795. *
  796. * @type {boolean}
  797. * @default false
  798. * @since 4.1.6
  799. * @product highcharts highstock gantt
  800. * @apioption plotOptions.series.getExtremesFromAll
  801. */
  802. /**
  803. * An array specifying which option maps to which key in the data point
  804. * array. This makes it convenient to work with unstructured data arrays
  805. * from different sources.
  806. *
  807. * @see [series.data](#series.line.data)
  808. *
  809. * @sample {highcharts|highstock} highcharts/series/data-keys/
  810. * An extended data array with keys
  811. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  812. * Nested keys used to access object properties
  813. *
  814. * @type {Array<string>}
  815. * @since 4.1.6
  816. * @apioption plotOptions.series.keys
  817. */
  818. /**
  819. * The line cap used for line ends and line joins on the graph.
  820. *
  821. * @type {Highcharts.SeriesLinecapValue}
  822. * @default round
  823. * @product highcharts highstock
  824. * @apioption plotOptions.series.linecap
  825. */
  826. /**
  827. * The [id](#series.id) of another series to link to. Additionally,
  828. * the value can be ":previous" to link to the previous series. When
  829. * two series are linked, only the first one appears in the legend.
  830. * Toggling the visibility of this also toggles the linked series.
  831. *
  832. * If master series uses data sorting and linked series does not have
  833. * its own sorting definition, the linked series will be sorted in the
  834. * same order as the master one.
  835. *
  836. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  837. * Linked series
  838. *
  839. * @type {string}
  840. * @since 3.0
  841. * @product highcharts highstock gantt
  842. * @apioption plotOptions.series.linkedTo
  843. */
  844. /**
  845. * Options for the corresponding navigator series if `showInNavigator`
  846. * is `true` for this series. Available options are the same as any
  847. * series, documented at [plotOptions](#plotOptions.series) and
  848. * [series](#series).
  849. *
  850. * These options are merged with options in [navigator.series](
  851. * #navigator.series), and will take precedence if the same option is
  852. * defined both places.
  853. *
  854. * @see [navigator.series](#navigator.series)
  855. *
  856. * @type {Highcharts.PlotSeriesOptions}
  857. * @since 5.0.0
  858. * @product highstock
  859. * @apioption plotOptions.series.navigatorOptions
  860. */
  861. /**
  862. * The color for the parts of the graph or points that are below the
  863. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  864. * precedence over the negative color. Using `negativeColor` is
  865. * equivalent to applying a zone with value of 0.
  866. *
  867. * @see In styled mode, a negative color is applied by setting this option
  868. * to `true` combined with the `.highcharts-negative` class name.
  869. *
  870. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  871. * Spline, area and column
  872. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  873. * Arearange
  874. * @sample {highcharts} highcharts/css/series-negative-color/
  875. * Styled mode
  876. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  877. * Spline, area and column
  878. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  879. * Arearange
  880. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  881. * Spline, area and column
  882. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  883. * Arearange
  884. *
  885. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  886. * @since 3.0
  887. * @apioption plotOptions.series.negativeColor
  888. */
  889. /**
  890. * Same as
  891. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  892. * but for an individual series. Overrides the chart wide configuration.
  893. *
  894. * @type {Function}
  895. * @since 5.0.12
  896. * @apioption plotOptions.series.pointDescriptionFormatter
  897. */
  898. /**
  899. * If no x values are given for the points in a series, `pointInterval`
  900. * defines the interval of the x values. For example, if a series
  901. * contains one value every decade starting from year 0, set
  902. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  903. * is set in milliseconds.
  904. *
  905. * It can be also be combined with `pointIntervalUnit` to draw irregular
  906. * time intervals.
  907. *
  908. * Please note that this options applies to the _series data_, not the
  909. * interval of the axis ticks, which is independent.
  910. *
  911. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  912. * Datetime X axis
  913. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  914. * Using pointStart and pointInterval
  915. *
  916. * @type {number}
  917. * @default 1
  918. * @product highcharts highstock gantt
  919. * @apioption plotOptions.series.pointInterval
  920. */
  921. /**
  922. * On datetime series, this allows for setting the
  923. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  924. * units, `day`, `month` and `year`. A day is usually the same as 24
  925. * hours, but `pointIntervalUnit` also takes the DST crossover into
  926. * consideration when dealing with local time. Combine this option with
  927. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  928. *
  929. * Please note that this options applies to the _series data_, not the
  930. * interval of the axis ticks, which is independent.
  931. *
  932. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  933. * One point a month
  934. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  935. * One point a month
  936. *
  937. * @type {string}
  938. * @since 4.1.0
  939. * @product highcharts highstock gantt
  940. * @validvalue ["day", "month", "year"]
  941. * @apioption plotOptions.series.pointIntervalUnit
  942. */
  943. /**
  944. * Possible values: `"on"`, `"between"`, `number`.
  945. *
  946. * In a column chart, when pointPlacement is `"on"`, the point will not
  947. * create any padding of the X axis. In a polar column chart this means
  948. * that the first column points directly north. If the pointPlacement is
  949. * `"between"`, the columns will be laid out between ticks. This is
  950. * useful for example for visualising an amount between two points in
  951. * time or in a certain sector of a polar chart.
  952. *
  953. * Since Highcharts 3.0.2, the point placement can also be numeric,
  954. * where 0 is on the axis value, -0.5 is between this value and the
  955. * previous, and 0.5 is between this value and the next. Unlike the
  956. * textual options, numeric point placement options won't affect axis
  957. * padding.
  958. *
  959. * Note that pointPlacement needs a [pointRange](
  960. * #plotOptions.series.pointRange) to work. For column series this is
  961. * computed, but for line-type series it needs to be set.
  962. *
  963. * For the `xrange` series type and gantt charts, if the Y axis is a
  964. * category axis, the `pointPlacement` applies to the Y axis rather than
  965. * the (typically datetime) X axis.
  966. *
  967. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  968. * charts.
  969. *
  970. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  971. *
  972. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  973. * Between in a column chart
  974. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  975. * Numeric placement for custom layout
  976. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  977. * Placement in heatmap
  978. *
  979. * @type {string|number}
  980. * @since 2.3.0
  981. * @product highcharts highstock gantt
  982. * @apioption plotOptions.series.pointPlacement
  983. */
  984. /**
  985. * If no x values are given for the points in a series, pointStart
  986. * defines on what value to start. For example, if a series contains one
  987. * yearly value starting from 1945, set pointStart to 1945.
  988. *
  989. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  990. * Linear
  991. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  992. * Datetime
  993. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  994. * Using pointStart and pointInterval
  995. *
  996. * @type {number}
  997. * @default 0
  998. * @product highcharts highstock gantt
  999. * @apioption plotOptions.series.pointStart
  1000. */
  1001. /**
  1002. * Whether to select the series initially. If `showCheckbox` is true,
  1003. * the checkbox next to the series name in the legend will be checked
  1004. * for a selected series.
  1005. *
  1006. * @sample {highcharts} highcharts/plotoptions/series-selected/
  1007. * One out of two series selected
  1008. *
  1009. * @type {boolean}
  1010. * @default false
  1011. * @since 1.2.0
  1012. * @apioption plotOptions.series.selected
  1013. */
  1014. /**
  1015. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  1016. * shadow can be an object configuration containing `color`, `offsetX`,
  1017. * `offsetY`, `opacity` and `width`.
  1018. *
  1019. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  1020. * Shadow enabled
  1021. *
  1022. * @type {boolean|Highcharts.ShadowOptionsObject}
  1023. * @default false
  1024. * @apioption plotOptions.series.shadow
  1025. */
  1026. /**
  1027. * Whether to display this particular series or series type in the
  1028. * legend. Standalone series are shown in legend by default, and linked
  1029. * series are not. Since v7.2.0 it is possible to show series that use
  1030. * colorAxis by setting this option to `true`.
  1031. *
  1032. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  1033. * One series in the legend, one hidden
  1034. *
  1035. * @type {boolean}
  1036. * @apioption plotOptions.series.showInLegend
  1037. */
  1038. /**
  1039. * Whether or not to show the series in the navigator. Takes precedence
  1040. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  1041. *
  1042. * @type {boolean}
  1043. * @since 5.0.0
  1044. * @product highstock
  1045. * @apioption plotOptions.series.showInNavigator
  1046. */
  1047. /**
  1048. * If set to `true`, the accessibility module will skip past the points
  1049. * in this series for keyboard navigation.
  1050. *
  1051. * @type {boolean}
  1052. * @since 5.0.12
  1053. * @apioption plotOptions.series.skipKeyboardNavigation
  1054. */
  1055. /**
  1056. * Whether to stack the values of each series on top of each other.
  1057. * Possible values are `undefined` to disable, `"normal"` to stack by
  1058. * value or `"percent"`.
  1059. *
  1060. * When stacking is enabled, data must be sorted
  1061. * in ascending X order.
  1062. *
  1063. * Some stacking options are related to specific series types. In the
  1064. * streamgraph series type, the stacking option is set to `"stream"`.
  1065. * The second one is `"overlap"`, which only applies to waterfall
  1066. * series.
  1067. *
  1068. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  1069. *
  1070. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  1071. * Line
  1072. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  1073. * Column
  1074. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  1075. * Bar
  1076. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  1077. * Area
  1078. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  1079. * Line
  1080. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  1081. * Column
  1082. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  1083. * Bar
  1084. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  1085. * Area
  1086. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  1087. * Waterfall with normal stacking
  1088. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  1089. * Waterfall with overlap stacking
  1090. * @sample {highstock} stock/plotoptions/stacking/
  1091. * Area
  1092. *
  1093. * @type {string}
  1094. * @product highcharts highstock
  1095. * @validvalue ["normal", "overlap", "percent", "stream"]
  1096. * @apioption plotOptions.series.stacking
  1097. */
  1098. /**
  1099. * Whether to apply steps to the line. Possible values are `left`,
  1100. * `center` and `right`.
  1101. *
  1102. * @sample {highcharts} highcharts/plotoptions/line-step/
  1103. * Different step line options
  1104. * @sample {highcharts} highcharts/plotoptions/area-step/
  1105. * Stepped, stacked area
  1106. * @sample {highstock} stock/plotoptions/line-step/
  1107. * Step line
  1108. *
  1109. * @type {string}
  1110. * @since 1.2.5
  1111. * @product highcharts highstock
  1112. * @validvalue ["left", "center", "right"]
  1113. * @apioption plotOptions.series.step
  1114. */
  1115. /**
  1116. * The threshold, also called zero level or base level. For line type
  1117. * series this is only used in conjunction with
  1118. * [negativeColor](#plotOptions.series.negativeColor).
  1119. *
  1120. * @see [softThreshold](#plotOptions.series.softThreshold).
  1121. *
  1122. * @type {number}
  1123. * @default 0
  1124. * @since 3.0
  1125. * @product highcharts highstock
  1126. * @apioption plotOptions.series.threshold
  1127. */
  1128. /**
  1129. * Set the initial visibility of the series.
  1130. *
  1131. * @sample {highcharts} highcharts/plotoptions/series-visible/
  1132. * Two series, one hidden and one visible
  1133. * @sample {highstock} stock/plotoptions/series-visibility/
  1134. * Hidden series
  1135. *
  1136. * @type {boolean}
  1137. * @default true
  1138. * @apioption plotOptions.series.visible
  1139. */
  1140. /**
  1141. * Defines the Axis on which the zones are applied.
  1142. *
  1143. * @see [zones](#plotOptions.series.zones)
  1144. *
  1145. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  1146. * Zones on the X-Axis
  1147. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  1148. * Zones on the X-Axis
  1149. *
  1150. * @type {string}
  1151. * @default y
  1152. * @since 4.1.0
  1153. * @product highcharts highstock
  1154. * @apioption plotOptions.series.zoneAxis
  1155. */
  1156. /**
  1157. * General event handlers for the series items. These event hooks can
  1158. * also be attached to the series at run time using the
  1159. * `Highcharts.addEvent` function.
  1160. *
  1161. * @declare Highcharts.SeriesEventsOptionsObject
  1162. *
  1163. * @private
  1164. */
  1165. events: {},
  1166. /**
  1167. * Fires after the series has finished its initial animation, or in case
  1168. * animation is disabled, immediately as the series is displayed.
  1169. *
  1170. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  1171. * Show label after animate
  1172. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  1173. * Show label after animate
  1174. *
  1175. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  1176. * @since 4.0
  1177. * @product highcharts highstock gantt
  1178. * @context Highcharts.Series
  1179. * @apioption plotOptions.series.events.afterAnimate
  1180. */
  1181. /**
  1182. * Fires when the checkbox next to the series' name in the legend is
  1183. * clicked. One parameter, `event`, is passed to the function. The state
  1184. * of the checkbox is found by `event.checked`. The checked item is
  1185. * found by `event.item`. Return `false` to prevent the default action
  1186. * which is to toggle the select state of the series.
  1187. *
  1188. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  1189. * Alert checkbox status
  1190. *
  1191. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  1192. * @since 1.2.0
  1193. * @context Highcharts.Series
  1194. * @apioption plotOptions.series.events.checkboxClick
  1195. */
  1196. /**
  1197. * Fires when the series is clicked. One parameter, `event`, is passed
  1198. * to the function, containing common event information. Additionally,
  1199. * `event.point` holds a pointer to the nearest point on the graph.
  1200. *
  1201. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  1202. * Alert click info
  1203. * @sample {highstock} stock/plotoptions/series-events-click/
  1204. * Alert click info
  1205. * @sample {highmaps} maps/plotoptions/series-events-click/
  1206. * Display click info in subtitle
  1207. *
  1208. * @type {Highcharts.SeriesClickCallbackFunction}
  1209. * @context Highcharts.Series
  1210. * @apioption plotOptions.series.events.click
  1211. */
  1212. /**
  1213. * Fires when the series is hidden after chart generation time, either
  1214. * by clicking the legend item or by calling `.hide()`.
  1215. *
  1216. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  1217. * Alert when the series is hidden by clicking the legend item
  1218. *
  1219. * @type {Highcharts.SeriesHideCallbackFunction}
  1220. * @since 1.2.0
  1221. * @context Highcharts.Series
  1222. * @apioption plotOptions.series.events.hide
  1223. */
  1224. /**
  1225. * Fires when the legend item belonging to the series is clicked. One
  1226. * parameter, `event`, is passed to the function. The default action
  1227. * is to toggle the visibility of the series. This can be prevented
  1228. * by returning `false` or calling `event.preventDefault()`.
  1229. *
  1230. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  1231. * Confirm hiding and showing
  1232. *
  1233. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  1234. * @context Highcharts.Series
  1235. * @apioption plotOptions.series.events.legendItemClick
  1236. */
  1237. /**
  1238. * Fires when the mouse leaves the graph. One parameter, `event`, is
  1239. * passed to the function, containing common event information. If the
  1240. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  1241. * doesn't happen before the mouse enters another graph or leaves the
  1242. * plot area.
  1243. *
  1244. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  1245. * With sticky tracking by default
  1246. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  1247. * Without sticky tracking
  1248. *
  1249. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  1250. * @context Highcharts.Series
  1251. * @apioption plotOptions.series.events.mouseOut
  1252. */
  1253. /**
  1254. * Fires when the mouse enters the graph. One parameter, `event`, is
  1255. * passed to the function, containing common event information.
  1256. *
  1257. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  1258. * With sticky tracking by default
  1259. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  1260. * Without sticky tracking
  1261. *
  1262. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  1263. * @context Highcharts.Series
  1264. * @apioption plotOptions.series.events.mouseOver
  1265. */
  1266. /**
  1267. * Fires when the series is shown after chart generation time, either
  1268. * by clicking the legend item or by calling `.show()`.
  1269. *
  1270. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  1271. * Alert when the series is shown by clicking the legend item.
  1272. *
  1273. * @type {Highcharts.SeriesShowCallbackFunction}
  1274. * @since 1.2.0
  1275. * @context Highcharts.Series
  1276. * @apioption plotOptions.series.events.show
  1277. */
  1278. /**
  1279. * Options for the point markers of line-like series. Properties like
  1280. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  1281. * of the markers. Other series types, like column series, don't have
  1282. * markers, but have visual options on the series level instead.
  1283. *
  1284. * In styled mode, the markers can be styled with the
  1285. * `.highcharts-point`, `.highcharts-point-hover` and
  1286. * `.highcharts-point-select` class names.
  1287. *
  1288. * @declare Highcharts.PointMarkerOptionsObject
  1289. *
  1290. * @private
  1291. */
  1292. marker: {
  1293. /**
  1294. * Enable or disable the point marker. If `undefined`, the markers
  1295. * are hidden when the data is dense, and shown for more widespread
  1296. * data points.
  1297. *
  1298. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  1299. * Disabled markers
  1300. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  1301. * Disabled in normal state but enabled on hover
  1302. * @sample {highstock} stock/plotoptions/series-marker/
  1303. * Enabled markers
  1304. *
  1305. * @type {boolean}
  1306. * @default {highcharts} undefined
  1307. * @default {highstock} false
  1308. * @apioption plotOptions.series.marker.enabled
  1309. */
  1310. /**
  1311. * The threshold for how dense the point markers should be before
  1312. * they are hidden, given that `enabled` is not defined. The number
  1313. * indicates the horizontal distance between the two closest points
  1314. * in the series, as multiples of the `marker.radius`. In other
  1315. * words, the default value of 2 means points are hidden if
  1316. * overlapping horizontally.
  1317. *
  1318. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  1319. * A higher threshold
  1320. *
  1321. * @since 6.0.5
  1322. */
  1323. enabledThreshold: 2,
  1324. /**
  1325. * The fill color of the point marker. When `undefined`, the series'
  1326. * or point's color is used.
  1327. *
  1328. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  1329. * White fill
  1330. *
  1331. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1332. * @apioption plotOptions.series.marker.fillColor
  1333. */
  1334. /**
  1335. * Image markers only. Set the image width explicitly. When using
  1336. * this option, a `width` must also be set.
  1337. *
  1338. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  1339. * Fixed width and height
  1340. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  1341. * Fixed width and height
  1342. *
  1343. * @type {number}
  1344. * @since 4.0.4
  1345. * @apioption plotOptions.series.marker.height
  1346. */
  1347. /**
  1348. * The color of the point marker's outline. When `undefined`, the
  1349. * series' or point's color is used.
  1350. *
  1351. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  1352. * Inherit from series color (undefined)
  1353. *
  1354. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1355. */
  1356. lineColor: '#ffffff',
  1357. /**
  1358. * The width of the point marker's outline.
  1359. *
  1360. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  1361. * 2px blue marker
  1362. */
  1363. lineWidth: 0,
  1364. /**
  1365. * The radius of the point marker.
  1366. *
  1367. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  1368. * Bigger markers
  1369. *
  1370. * @default {highstock} 2
  1371. */
  1372. radius: 4,
  1373. /**
  1374. * A predefined shape or symbol for the marker. When undefined, the
  1375. * symbol is pulled from options.symbols. Other possible values are
  1376. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  1377. * `'triangle-down'`.
  1378. *
  1379. * Additionally, the URL to a graphic can be given on this form:
  1380. * `'url(graphic.png)'`. Note that for the image to be applied to
  1381. * exported charts, its URL needs to be accessible by the export
  1382. * server.
  1383. *
  1384. * Custom callbacks for symbol path generation can also be added to
  1385. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  1386. * used by its method name, as shown in the demo.
  1387. *
  1388. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  1389. * Predefined, graphic and custom markers
  1390. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  1391. * Predefined, graphic and custom markers
  1392. *
  1393. * @type {string}
  1394. * @apioption plotOptions.series.marker.symbol
  1395. */
  1396. /**
  1397. * Image markers only. Set the image width explicitly. When using
  1398. * this option, a `height` must also be set.
  1399. *
  1400. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  1401. * Fixed width and height
  1402. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  1403. * Fixed width and height
  1404. *
  1405. * @type {number}
  1406. * @since 4.0.4
  1407. * @apioption plotOptions.series.marker.width
  1408. */
  1409. /**
  1410. * States for a single point marker.
  1411. *
  1412. * @declare Highcharts.PointStatesOptionsObject
  1413. */
  1414. states: {
  1415. /**
  1416. * The normal state of a single point marker. Currently only
  1417. * used for setting animation when returning to normal state
  1418. * from hover.
  1419. *
  1420. * @declare Highcharts.PointStatesNormalOptionsObject
  1421. */
  1422. normal: {
  1423. /**
  1424. * Animation when returning to normal state after hovering.
  1425. *
  1426. * @type {boolean|Highcharts.AnimationOptionsObject}
  1427. */
  1428. animation: true
  1429. },
  1430. /**
  1431. * The hover state for a single point marker.
  1432. *
  1433. * @declare Highcharts.PointStatesHoverOptionsObject
  1434. */
  1435. hover: {
  1436. /**
  1437. * Animation when hovering over the marker.
  1438. *
  1439. * @type {boolean|Highcharts.AnimationOptionsObject}
  1440. */
  1441. animation: {
  1442. /** @internal */
  1443. duration: 50
  1444. },
  1445. /**
  1446. * Enable or disable the point marker.
  1447. *
  1448. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  1449. * Disabled hover state
  1450. */
  1451. enabled: true,
  1452. /**
  1453. * The fill color of the marker in hover state. When
  1454. * `undefined`, the series' or point's fillColor for normal
  1455. * state is used.
  1456. *
  1457. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1458. * @apioption plotOptions.series.marker.states.hover.fillColor
  1459. */
  1460. /**
  1461. * The color of the point marker's outline. When
  1462. * `undefined`, the series' or point's lineColor for normal
  1463. * state is used.
  1464. *
  1465. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  1466. * White fill color, black line color
  1467. *
  1468. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1469. * @apioption plotOptions.series.marker.states.hover.lineColor
  1470. */
  1471. /**
  1472. * The width of the point marker's outline. When
  1473. * `undefined`, the series' or point's lineWidth for normal
  1474. * state is used.
  1475. *
  1476. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  1477. * 3px line width
  1478. *
  1479. * @type {number}
  1480. * @apioption plotOptions.series.marker.states.hover.lineWidth
  1481. */
  1482. /**
  1483. * The radius of the point marker. In hover state, it
  1484. * defaults to the normal state's radius + 2 as per the
  1485. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  1486. * option.
  1487. *
  1488. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  1489. * 10px radius
  1490. *
  1491. * @type {number}
  1492. * @apioption plotOptions.series.marker.states.hover.radius
  1493. */
  1494. /**
  1495. * The number of pixels to increase the radius of the
  1496. * hovered point.
  1497. *
  1498. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  1499. * 5 pixels greater radius on hover
  1500. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  1501. * 5 pixels greater radius on hover
  1502. *
  1503. * @since 4.0.3
  1504. */
  1505. radiusPlus: 2,
  1506. /**
  1507. * The additional line width for a hovered point.
  1508. *
  1509. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  1510. * 2 pixels wider on hover
  1511. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  1512. * 2 pixels wider on hover
  1513. *
  1514. * @since 4.0.3
  1515. */
  1516. lineWidthPlus: 1
  1517. },
  1518. /**
  1519. * The appearance of the point marker when selected. In order to
  1520. * allow a point to be selected, set the
  1521. * `series.allowPointSelect` option to true.
  1522. *
  1523. * @declare Highcharts.PointStatesSelectOptionsObject
  1524. */
  1525. select: {
  1526. /**
  1527. * Enable or disable visible feedback for selection.
  1528. *
  1529. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  1530. * Disabled select state
  1531. *
  1532. * @type {boolean}
  1533. * @default true
  1534. * @apioption plotOptions.series.marker.states.select.enabled
  1535. */
  1536. /**
  1537. * The radius of the point marker. In hover state, it
  1538. * defaults to the normal state's radius + 2.
  1539. *
  1540. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  1541. * 10px radius for selected points
  1542. *
  1543. * @type {number}
  1544. * @apioption plotOptions.series.marker.states.select.radius
  1545. */
  1546. /**
  1547. * The fill color of the point marker.
  1548. *
  1549. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  1550. * Solid red discs for selected points
  1551. *
  1552. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1553. */
  1554. fillColor: '#cccccc',
  1555. /**
  1556. * The color of the point marker's outline. When
  1557. * `undefined`, the series' or point's color is used.
  1558. *
  1559. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  1560. * Red line color for selected points
  1561. *
  1562. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1563. */
  1564. lineColor: '#000000',
  1565. /**
  1566. * The width of the point marker's outline.
  1567. *
  1568. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  1569. * 3px line width for selected points
  1570. */
  1571. lineWidth: 2
  1572. }
  1573. }
  1574. },
  1575. /**
  1576. * Properties for each single point.
  1577. *
  1578. * @declare Highcharts.PlotSeriesPointOptions
  1579. *
  1580. * @private
  1581. */
  1582. point: {
  1583. /**
  1584. * Fires when a point is clicked. One parameter, `event`, is passed
  1585. * to the function, containing common event information.
  1586. *
  1587. * If the `series.allowPointSelect` option is true, the default
  1588. * action for the point's click event is to toggle the point's
  1589. * select state. Returning `false` cancels this action.
  1590. *
  1591. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  1592. * Click marker to alert values
  1593. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  1594. * Click column
  1595. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  1596. * Go to URL
  1597. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  1598. * Click marker to display values
  1599. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  1600. * Go to URL
  1601. *
  1602. * @type {Highcharts.PointClickCallbackFunction}
  1603. * @context Highcharts.Point
  1604. * @apioption plotOptions.series.point.events.click
  1605. */
  1606. /**
  1607. * Fires when the mouse leaves the area close to the point. One
  1608. * parameter, `event`, is passed to the function, containing common
  1609. * event information.
  1610. *
  1611. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  1612. * Show values in the chart's corner on mouse over
  1613. *
  1614. * @type {Highcharts.PointMouseOutCallbackFunction}
  1615. * @context Highcharts.Point
  1616. * @apioption plotOptions.series.point.events.mouseOut
  1617. */
  1618. /**
  1619. * Fires when the mouse enters the area close to the point. One
  1620. * parameter, `event`, is passed to the function, containing common
  1621. * event information.
  1622. *
  1623. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  1624. * Show values in the chart's corner on mouse over
  1625. *
  1626. * @type {Highcharts.PointMouseOverCallbackFunction}
  1627. * @context Highcharts.Point
  1628. * @apioption plotOptions.series.point.events.mouseOver
  1629. */
  1630. /**
  1631. * Fires when the point is removed using the `.remove()` method. One
  1632. * parameter, `event`, is passed to the function. Returning `false`
  1633. * cancels the operation.
  1634. *
  1635. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  1636. * Remove point and confirm
  1637. *
  1638. * @type {Highcharts.PointRemoveCallbackFunction}
  1639. * @since 1.2.0
  1640. * @context Highcharts.Point
  1641. * @apioption plotOptions.series.point.events.remove
  1642. */
  1643. /**
  1644. * Fires when the point is selected either programmatically or
  1645. * following a click on the point. One parameter, `event`, is passed
  1646. * to the function. Returning `false` cancels the operation.
  1647. *
  1648. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  1649. * Report the last selected point
  1650. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  1651. * Report select and unselect
  1652. *
  1653. * @type {Highcharts.PointSelectCallbackFunction}
  1654. * @since 1.2.0
  1655. * @context Highcharts.Point
  1656. * @apioption plotOptions.series.point.events.select
  1657. */
  1658. /**
  1659. * Fires when the point is unselected either programmatically or
  1660. * following a click on the point. One parameter, `event`, is passed
  1661. * to the function.
  1662. * Returning `false` cancels the operation.
  1663. *
  1664. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  1665. * Report the last unselected point
  1666. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  1667. * Report select and unselect
  1668. *
  1669. * @type {Highcharts.PointUnselectCallbackFunction}
  1670. * @since 1.2.0
  1671. * @context Highcharts.Point
  1672. * @apioption plotOptions.series.point.events.unselect
  1673. */
  1674. /**
  1675. * Fires when the point is updated programmatically through the
  1676. * `.update()` method. One parameter, `event`, is passed to the
  1677. * function. The new point options can be accessed through
  1678. * `event.options`. Returning `false` cancels the operation.
  1679. *
  1680. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  1681. * Confirm point updating
  1682. *
  1683. * @type {Highcharts.PointUpdateCallbackFunction}
  1684. * @since 1.2.0
  1685. * @context Highcharts.Point
  1686. * @apioption plotOptions.series.point.events.update
  1687. */
  1688. /**
  1689. * Events for each single point.
  1690. *
  1691. * @declare Highcharts.PointEventsOptionsObject
  1692. */
  1693. events: {}
  1694. },
  1695. /**
  1696. * Options for the series data labels, appearing next to each data
  1697. * point.
  1698. *
  1699. * Since v6.2.0, multiple data labels can be applied to each single
  1700. * point by defining them as an array of configs.
  1701. *
  1702. * In styled mode, the data labels can be styled with the
  1703. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  1704. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  1705. *
  1706. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  1707. * Data labels enabled
  1708. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  1709. * Multiple data labels on a bar series
  1710. * @sample {highcharts} highcharts/css/series-datalabels
  1711. * Style mode example
  1712. *
  1713. * @type {*|Array<*>}
  1714. * @product highcharts highstock highmaps gantt
  1715. *
  1716. * @private
  1717. */
  1718. dataLabels: {
  1719. /**
  1720. * The alignment of the data label compared to the point. If
  1721. * `right`, the right side of the label should be touching the
  1722. * point. For points with an extent, like columns, the alignments
  1723. * also dictates how to align it inside the box, as given with the
  1724. * [inside](#plotOptions.column.dataLabels.inside)
  1725. * option. Can be one of `left`, `center` or `right`.
  1726. *
  1727. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  1728. * Left aligned
  1729. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  1730. * Data labels inside the bar
  1731. *
  1732. * @type {Highcharts.AlignValue|null}
  1733. */
  1734. align: 'center',
  1735. /**
  1736. * Whether to allow data labels to overlap. To make the labels less
  1737. * sensitive for overlapping, the
  1738. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  1739. * can be set to 0.
  1740. *
  1741. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  1742. * Don't allow overlap
  1743. *
  1744. * @type {boolean}
  1745. * @default false
  1746. * @since 4.1.0
  1747. * @apioption plotOptions.series.dataLabels.allowOverlap
  1748. */
  1749. /**
  1750. * The background color or gradient for the data label.
  1751. *
  1752. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  1753. * Data labels box options
  1754. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  1755. * Data labels box options
  1756. *
  1757. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1758. * @since 2.2.1
  1759. * @apioption plotOptions.series.dataLabels.backgroundColor
  1760. */
  1761. /**
  1762. * The border color for the data label. Defaults to `undefined`.
  1763. *
  1764. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  1765. * Data labels box options
  1766. *
  1767. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1768. * @since 2.2.1
  1769. * @apioption plotOptions.series.dataLabels.borderColor
  1770. */
  1771. /**
  1772. * The border radius in pixels for the data label.
  1773. *
  1774. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  1775. * Data labels box options
  1776. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  1777. * Data labels box options
  1778. *
  1779. * @type {number}
  1780. * @default 0
  1781. * @since 2.2.1
  1782. * @apioption plotOptions.series.dataLabels.borderRadius
  1783. */
  1784. /**
  1785. * The border width in pixels for the data label.
  1786. *
  1787. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  1788. * Data labels box options
  1789. *
  1790. * @type {number}
  1791. * @default 0
  1792. * @since 2.2.1
  1793. * @apioption plotOptions.series.dataLabels.borderWidth
  1794. */
  1795. /**
  1796. * A class name for the data label. Particularly in styled mode,
  1797. * this can be used to give each series' or point's data label
  1798. * unique styling. In addition to this option, a default color class
  1799. * name is added so that we can give the labels a contrast text
  1800. * shadow.
  1801. *
  1802. * @sample {highcharts} highcharts/css/data-label-contrast/
  1803. * Contrast text shadow
  1804. * @sample {highcharts} highcharts/css/series-datalabels/
  1805. * Styling by CSS
  1806. *
  1807. * @type {string}
  1808. * @since 5.0.0
  1809. * @apioption plotOptions.series.dataLabels.className
  1810. */
  1811. /**
  1812. * The text color for the data labels. Defaults to `undefined`. For
  1813. * certain series types, like column or map, the data labels can be
  1814. * drawn inside the points. In this case the data label will be
  1815. * drawn with maximum contrast by default. Additionally, it will be
  1816. * given a `text-outline` style with the opposite color, to further
  1817. * increase the contrast. This can be overridden by setting the
  1818. * `text-outline` style to `none` in the `dataLabels.style` option.
  1819. *
  1820. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  1821. * Red data labels
  1822. * @sample {highmaps} maps/demo/color-axis/
  1823. * White data labels
  1824. *
  1825. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  1826. * @apioption plotOptions.series.dataLabels.color
  1827. */
  1828. /**
  1829. * Whether to hide data labels that are outside the plot area. By
  1830. * default, the data label is moved inside the plot area according
  1831. * to the
  1832. * [overflow](#plotOptions.series.dataLabels.overflow)
  1833. * option.
  1834. *
  1835. * @type {boolean}
  1836. * @default true
  1837. * @since 2.3.3
  1838. * @apioption plotOptions.series.dataLabels.crop
  1839. */
  1840. /**
  1841. * Whether to defer displaying the data labels until the initial
  1842. * series animation has finished.
  1843. *
  1844. * @type {boolean}
  1845. * @default true
  1846. * @since 4.0.0
  1847. * @product highcharts highstock gantt
  1848. * @apioption plotOptions.series.dataLabels.defer
  1849. */
  1850. /**
  1851. * Enable or disable the data labels.
  1852. *
  1853. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  1854. * Data labels enabled
  1855. * @sample {highmaps} maps/demo/color-axis/
  1856. * Data labels enabled
  1857. *
  1858. * @type {boolean}
  1859. * @default false
  1860. * @apioption plotOptions.series.dataLabels.enabled
  1861. */
  1862. /**
  1863. * A declarative filter to control of which data labels to display.
  1864. * The declarative filter is designed for use when callback
  1865. * functions are not available, like when the chart options require
  1866. * a pure JSON structure or for use with graphical editors. For
  1867. * programmatic control, use the `formatter` instead, and return
  1868. * `undefined` to disable a single data label.
  1869. *
  1870. * @example
  1871. * filter: {
  1872. * property: 'percentage',
  1873. * operator: '>',
  1874. * value: 4
  1875. * }
  1876. *
  1877. * @sample {highcharts} highcharts/demo/pie-monochrome
  1878. * Data labels filtered by percentage
  1879. *
  1880. * @declare Highcharts.DataLabelsFilterOptionsObject
  1881. * @since 6.0.3
  1882. * @apioption plotOptions.series.dataLabels.filter
  1883. */
  1884. /**
  1885. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  1886. * `==`, and `===`.
  1887. *
  1888. * @type {string}
  1889. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  1890. * @apioption plotOptions.series.dataLabels.filter.operator
  1891. */
  1892. /**
  1893. * The point property to filter by. Point options are passed
  1894. * directly to properties, additionally there are `y` value,
  1895. * `percentage` and others listed under {@link Highcharts.Point}
  1896. * members.
  1897. *
  1898. * @type {string}
  1899. * @apioption plotOptions.series.dataLabels.filter.property
  1900. */
  1901. /**
  1902. * The value to compare against.
  1903. *
  1904. * @type {number}
  1905. * @apioption plotOptions.series.dataLabels.filter.value
  1906. */
  1907. /**
  1908. * A
  1909. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  1910. * for the data label. Available variables are the same as for
  1911. * `formatter`.
  1912. *
  1913. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  1914. * Add a unit
  1915. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  1916. * Formatted value in the data label
  1917. *
  1918. * @type {string}
  1919. * @default y
  1920. * @default point.value
  1921. * @since 3.0
  1922. * @apioption plotOptions.series.dataLabels.format
  1923. */
  1924. // eslint-disable-next-line valid-jsdoc
  1925. /**
  1926. * Callback JavaScript function to format the data label. Note that
  1927. * if a `format` is defined, the format takes precedence and the
  1928. * formatter is ignored.
  1929. *
  1930. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  1931. * Formatted value
  1932. *
  1933. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  1934. */
  1935. formatter: function () {
  1936. var numberFormatter = this.series.chart.numberFormatter;
  1937. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  1938. },
  1939. /**
  1940. * For points with an extent, like columns or map areas, whether to
  1941. * align the data label inside the box or to the actual value point.
  1942. * Defaults to `false` in most cases, `true` in stacked columns.
  1943. *
  1944. * @type {boolean}
  1945. * @since 3.0
  1946. * @apioption plotOptions.series.dataLabels.inside
  1947. */
  1948. /**
  1949. * Format for points with the value of null. Works analogously to
  1950. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  1951. * be applied only to series which support displaying null points.
  1952. *
  1953. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  1954. * Format data label and tooltip for null point.
  1955. *
  1956. * @type {boolean|string}
  1957. * @since 7.1.0
  1958. * @apioption plotOptions.series.dataLabels.nullFormat
  1959. */
  1960. /**
  1961. * Callback JavaScript function that defines formatting for points
  1962. * with the value of null. Works analogously to
  1963. * [formatter](#plotOptions.series.dataLabels.formatter).
  1964. * `nullPointFormatter` can be applied only to series which support
  1965. * displaying null points.
  1966. *
  1967. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  1968. * Format data label and tooltip for null point.
  1969. *
  1970. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  1971. * @since 7.1.0
  1972. * @apioption plotOptions.series.dataLabels.nullFormatter
  1973. */
  1974. /**
  1975. * How to handle data labels that flow outside the plot area. The
  1976. * default is `"justify"`, which aligns them inside the plot area.
  1977. * For columns and bars, this means it will be moved inside the bar.
  1978. * To display data labels outside the plot area, set `crop` to
  1979. * `false` and `overflow` to `"allow"`.
  1980. *
  1981. * @type {Highcharts.DataLabelsOverflowValue}
  1982. * @default justify
  1983. * @since 3.0.6
  1984. * @apioption plotOptions.series.dataLabels.overflow
  1985. */
  1986. /**
  1987. * When either the `borderWidth` or the `backgroundColor` is set,
  1988. * this is the padding within the box.
  1989. *
  1990. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  1991. * Data labels box options
  1992. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  1993. * Data labels box options
  1994. *
  1995. * @since 2.2.1
  1996. */
  1997. padding: 5,
  1998. /**
  1999. * Aligns data labels relative to points. If `center` alignment is
  2000. * not possible, it defaults to `right`.
  2001. *
  2002. * @type {Highcharts.AlignValue}
  2003. * @default center
  2004. * @apioption plotOptions.series.dataLabels.position
  2005. */
  2006. /**
  2007. * Text rotation in degrees. Note that due to a more complex
  2008. * structure, backgrounds, borders and padding will be lost on a
  2009. * rotated data label.
  2010. *
  2011. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  2012. * Vertical labels
  2013. *
  2014. * @type {number}
  2015. * @default 0
  2016. * @apioption plotOptions.series.dataLabels.rotation
  2017. */
  2018. /**
  2019. * The shadow of the box. Works best with `borderWidth` or
  2020. * `backgroundColor`. Since 2.3 the shadow can be an object
  2021. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  2022. * and `width`.
  2023. *
  2024. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  2025. * Data labels box options
  2026. *
  2027. * @type {boolean|Highcharts.ShadowOptionsObject}
  2028. * @default false
  2029. * @since 2.2.1
  2030. * @apioption plotOptions.series.dataLabels.shadow
  2031. */
  2032. /**
  2033. * The name of a symbol to use for the border around the label.
  2034. * Symbols are predefined functions on the Renderer object.
  2035. *
  2036. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  2037. * A callout for annotations
  2038. *
  2039. * @type {string}
  2040. * @default square
  2041. * @since 4.1.2
  2042. * @apioption plotOptions.series.dataLabels.shape
  2043. */
  2044. /**
  2045. * Styles for the label. The default `color` setting is
  2046. * `"contrast"`, which is a pseudo color that Highcharts picks up
  2047. * and applies the maximum contrast to the underlying point item,
  2048. * for example the bar in a bar chart.
  2049. *
  2050. * The `textOutline` is a pseudo property that applies an outline of
  2051. * the given width with the given color, which by default is the
  2052. * maximum contrast to the text. So a bright text color will result
  2053. * in a black text outline for maximum readability on a mixed
  2054. * background. In some cases, especially with grayscale text, the
  2055. * text outline doesn't work well, in which cases it can be disabled
  2056. * by setting it to `"none"`. When `useHTML` is true, the
  2057. * `textOutline` will not be picked up. In this, case, the same
  2058. * effect can be acheived through the `text-shadow` CSS property.
  2059. *
  2060. * For some series types, where each point has an extent, like for
  2061. * example tree maps, the data label may overflow the point. There
  2062. * are two strategies for handling overflow. By default, the text
  2063. * will wrap to multiple lines. The other strategy is to set
  2064. * `style.textOverflow` to `ellipsis`, which will keep the text on
  2065. * one line plus it will break inside long words.
  2066. *
  2067. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  2068. * Bold labels
  2069. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  2070. * Long labels truncated with an ellipsis in a pie
  2071. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  2072. * Long labels are wrapped in a pie
  2073. * @sample {highmaps} maps/demo/color-axis/
  2074. * Bold labels
  2075. *
  2076. * @type {Highcharts.CSSObject}
  2077. * @since 4.1.0
  2078. * @apioption plotOptions.series.dataLabels.style
  2079. */
  2080. style: {
  2081. /** @internal */
  2082. fontSize: '11px',
  2083. /** @internal */
  2084. fontWeight: 'bold',
  2085. /** @internal */
  2086. color: 'contrast',
  2087. /** @internal */
  2088. textOutline: '1px contrast'
  2089. },
  2090. /**
  2091. * Options for a label text which should follow marker's shape.
  2092. * Border and background are disabled for a label that follows a
  2093. * path.
  2094. *
  2095. * **Note:** Only SVG-based renderer supports this option. Setting
  2096. * `useHTML` to true will disable this option.
  2097. *
  2098. * @declare Highcharts.DataLabelsTextPathOptionsObject
  2099. * @since 7.1.0
  2100. * @apioption plotOptions.series.dataLabels.textPath
  2101. */
  2102. /**
  2103. * Presentation attributes for the text path.
  2104. *
  2105. * @type {Highcharts.SVGAttributes}
  2106. * @since 7.1.0
  2107. * @apioption plotOptions.series.dataLabels.textPath.attributes
  2108. */
  2109. /**
  2110. * Enable or disable `textPath` option for link's or marker's data
  2111. * labels.
  2112. *
  2113. * @type {boolean}
  2114. * @since 7.1.0
  2115. * @apioption plotOptions.series.dataLabels.textPath.enabled
  2116. */
  2117. /**
  2118. * Whether to
  2119. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  2120. * to render the labels.
  2121. *
  2122. * @type {boolean}
  2123. * @default false
  2124. * @apioption plotOptions.series.dataLabels.useHTML
  2125. */
  2126. /**
  2127. * The vertical alignment of a data label. Can be one of `top`,
  2128. * `middle` or `bottom`. The default value depends on the data, for
  2129. * instance in a column chart, the label is above positive values
  2130. * and below negative values.
  2131. *
  2132. * @type {Highcharts.VerticalAlignValue|null}
  2133. * @since 2.3.3
  2134. */
  2135. verticalAlign: 'bottom',
  2136. /**
  2137. * The x position offset of the label relative to the point in
  2138. * pixels.
  2139. *
  2140. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  2141. * Vertical and positioned
  2142. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  2143. * Data labels inside the bar
  2144. */
  2145. x: 0,
  2146. /**
  2147. * The Z index of the data labels. The default Z index puts it above
  2148. * the series. Use a Z index of 2 to display it behind the series.
  2149. *
  2150. * @type {number}
  2151. * @default 6
  2152. * @since 2.3.5
  2153. * @apioption plotOptions.series.dataLabels.z
  2154. */
  2155. /**
  2156. * The y position offset of the label relative to the point in
  2157. * pixels.
  2158. *
  2159. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  2160. * Vertical and positioned
  2161. */
  2162. y: 0
  2163. },
  2164. /**
  2165. * When the series contains less points than the crop threshold, all
  2166. * points are drawn, even if the points fall outside the visible plot
  2167. * area at the current zoom. The advantage of drawing all points
  2168. * (including markers and columns), is that animation is performed on
  2169. * updates. On the other hand, when the series contains more points than
  2170. * the crop threshold, the series data is cropped to only contain points
  2171. * that fall within the plot area. The advantage of cropping away
  2172. * invisible points is to increase performance on large series.
  2173. *
  2174. * @since 2.2
  2175. * @product highcharts highstock
  2176. *
  2177. * @private
  2178. */
  2179. cropThreshold: 300,
  2180. /**
  2181. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  2182. *
  2183. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  2184. *
  2185. * @since 7.1.0
  2186. *
  2187. * @private
  2188. */
  2189. opacity: 1,
  2190. /**
  2191. * The width of each point on the x axis. For example in a column chart
  2192. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  2193. * * 1000 milliseconds). This is normally computed automatically, but
  2194. * this option can be used to override the automatic value.
  2195. *
  2196. * @product highstock
  2197. *
  2198. * @private
  2199. */
  2200. pointRange: 0,
  2201. /**
  2202. * When this is true, the series will not cause the Y axis to cross
  2203. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  2204. * unless the data actually crosses the plane.
  2205. *
  2206. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  2207. * 3 will make the Y axis show negative values according to the
  2208. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  2209. * at 0.
  2210. *
  2211. * @since 4.1.9
  2212. * @product highcharts highstock
  2213. *
  2214. * @private
  2215. */
  2216. softThreshold: true,
  2217. /**
  2218. * @declare Highcharts.SeriesStatesOptionsObject
  2219. *
  2220. * @private
  2221. */
  2222. states: {
  2223. /**
  2224. * The normal state of a series, or for point items in column, pie
  2225. * and similar series. Currently only used for setting animation
  2226. * when returning to normal state from hover.
  2227. *
  2228. * @declare Highcharts.SeriesStatesNormalOptionsObject
  2229. */
  2230. normal: {
  2231. /**
  2232. * Animation when returning to normal state after hovering.
  2233. *
  2234. * @type {boolean|Highcharts.AnimationOptionsObject}
  2235. */
  2236. animation: true
  2237. },
  2238. /**
  2239. * Options for the hovered series. These settings override the
  2240. * normal state options when a series is moused over or touched.
  2241. *
  2242. * @declare Highcharts.SeriesStatesHoverOptionsObject
  2243. */
  2244. hover: {
  2245. /**
  2246. * Enable separate styles for the hovered series to visualize
  2247. * that the user hovers either the series itself or the legend.
  2248. *
  2249. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  2250. * Line
  2251. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  2252. * Column
  2253. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  2254. * Pie
  2255. *
  2256. * @type {boolean}
  2257. * @default true
  2258. * @since 1.2
  2259. * @apioption plotOptions.series.states.hover.enabled
  2260. */
  2261. /**
  2262. * Animation setting for hovering the graph in line-type series.
  2263. *
  2264. * @type {boolean|Highcharts.AnimationOptionsObject}
  2265. * @since 5.0.8
  2266. * @product highcharts highstock
  2267. */
  2268. animation: {
  2269. /**
  2270. * The duration of the hover animation in milliseconds. By
  2271. * default the hover state animates quickly in, and slowly
  2272. * back to normal.
  2273. *
  2274. * @internal
  2275. */
  2276. duration: 50
  2277. },
  2278. /**
  2279. * Pixel width of the graph line. By default this property is
  2280. * undefined, and the `lineWidthPlus` property dictates how much
  2281. * to increase the linewidth from normal state.
  2282. *
  2283. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  2284. * 5px line on hover
  2285. *
  2286. * @type {number}
  2287. * @product highcharts highstock
  2288. * @apioption plotOptions.series.states.hover.lineWidth
  2289. */
  2290. /**
  2291. * The additional line width for the graph of a hovered series.
  2292. *
  2293. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  2294. * 5 pixels wider
  2295. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  2296. * 5 pixels wider
  2297. *
  2298. * @since 4.0.3
  2299. * @product highcharts highstock
  2300. */
  2301. lineWidthPlus: 1,
  2302. /**
  2303. * In Highcharts 1.0, the appearance of all markers belonging
  2304. * to the hovered series. For settings on the hover state of the
  2305. * individual point, see
  2306. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  2307. *
  2308. * @deprecated
  2309. *
  2310. * @extends plotOptions.series.marker
  2311. * @excluding states
  2312. * @product highcharts highstock
  2313. */
  2314. marker: {
  2315. // lineWidth: base + 1,
  2316. // radius: base + 1
  2317. },
  2318. /**
  2319. * Options for the halo appearing around the hovered point in
  2320. * line-type series as well as outside the hovered slice in pie
  2321. * charts. By default the halo is filled by the current point or
  2322. * series color with an opacity of 0.25\. The halo can be
  2323. * disabled by setting the `halo` option to `null`.
  2324. *
  2325. * In styled mode, the halo is styled with the
  2326. * `.highcharts-halo` class, with colors inherited from
  2327. * `.highcharts-color-{n}`.
  2328. *
  2329. * @sample {highcharts} highcharts/plotoptions/halo/
  2330. * Halo options
  2331. * @sample {highstock} highcharts/plotoptions/halo/
  2332. * Halo options
  2333. *
  2334. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  2335. * @type {null|*}
  2336. * @since 4.0
  2337. * @product highcharts highstock
  2338. */
  2339. halo: {
  2340. /**
  2341. * A collection of SVG attributes to override the appearance
  2342. * of the halo, for example `fill`, `stroke` and
  2343. * `stroke-width`.
  2344. *
  2345. * @type {Highcharts.SVGAttributes}
  2346. * @since 4.0
  2347. * @product highcharts highstock
  2348. * @apioption plotOptions.series.states.hover.halo.attributes
  2349. */
  2350. /**
  2351. * The pixel size of the halo. For point markers this is the
  2352. * radius of the halo. For pie slices it is the width of the
  2353. * halo outside the slice. For bubbles it defaults to 5 and
  2354. * is the width of the halo outside the bubble.
  2355. *
  2356. * @since 4.0
  2357. * @product highcharts highstock
  2358. */
  2359. size: 10,
  2360. /**
  2361. * Opacity for the halo unless a specific fill is overridden
  2362. * using the `attributes` setting. Note that Highcharts is
  2363. * only able to apply opacity to colors of hex or rgb(a)
  2364. * formats.
  2365. *
  2366. * @since 4.0
  2367. * @product highcharts highstock
  2368. */
  2369. opacity: 0.25
  2370. }
  2371. },
  2372. /**
  2373. * Specific options for point in selected states, after being
  2374. * selected by
  2375. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  2376. * or programmatically.
  2377. *
  2378. * @sample maps/plotoptions/series-allowpointselect/
  2379. * Allow point select demo
  2380. *
  2381. * @declare Highcharts.SeriesStatesSelectOptionsObject
  2382. * @extends plotOptions.series.states.hover
  2383. * @excluding brightness
  2384. */
  2385. select: {
  2386. animation: {
  2387. /** @internal */
  2388. duration: 0
  2389. }
  2390. },
  2391. /**
  2392. * The opposite state of a hover for series.
  2393. *
  2394. * @sample highcharts/plotoptions/series-states-inactive-disabled
  2395. * Disabled inactive state
  2396. *
  2397. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  2398. */
  2399. inactive: {
  2400. /**
  2401. * Enable or disable the inactive state for a series
  2402. *
  2403. * @sample highcharts/plotoptions/series-states-inactive-disabled
  2404. * Disabled inactive state
  2405. *
  2406. * @type {boolean}
  2407. * @default true
  2408. * @apioption plotOptions.series.states.inactive.enabled
  2409. */
  2410. /**
  2411. * The animation for entering the inactive state.
  2412. *
  2413. * @type {boolean|Highcharts.AnimationOptionsObject}
  2414. */
  2415. animation: {
  2416. /** @internal */
  2417. duration: 50
  2418. },
  2419. /**
  2420. * Opacity of series elements (dataLabels, line, area).
  2421. *
  2422. * @type {number}
  2423. */
  2424. opacity: 0.2
  2425. }
  2426. },
  2427. /**
  2428. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  2429. * series isn't triggered until the mouse moves over another series, or
  2430. * out of the plot area. When false, the `mouseOut` event on a series is
  2431. * triggered when the mouse leaves the area around the series' graph or
  2432. * markers. This also implies the tooltip when not shared. When
  2433. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  2434. * will be hidden when moving the mouse between series. Defaults to true
  2435. * for line and area type series, but to false for columns, pies etc.
  2436. *
  2437. * **Note:** The boost module will force this option because of
  2438. * technical limitations.
  2439. *
  2440. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  2441. * True by default
  2442. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  2443. * False
  2444. *
  2445. * @default {highcharts} true
  2446. * @default {highstock} true
  2447. * @default {highmaps} false
  2448. * @since 2.0
  2449. *
  2450. * @private
  2451. */
  2452. stickyTracking: true,
  2453. /**
  2454. * A configuration object for the tooltip rendering of each single
  2455. * series. Properties are inherited from [tooltip](#tooltip), but only
  2456. * the following properties can be defined on a series level.
  2457. *
  2458. * @declare Highcharts.SeriesTooltipOptionsObject
  2459. * @since 2.3
  2460. * @extends tooltip
  2461. * @excluding animation, backgroundColor, borderColor, borderRadius,
  2462. * borderWidth, className, crosshairs, enabled, formatter,
  2463. * headerShape, hideDelay, outside, padding, positioner,
  2464. * shadow, shape, shared, snap, split, style, useHTML
  2465. * @apioption plotOptions.series.tooltip
  2466. */
  2467. /**
  2468. * When a series contains a data array that is longer than this, only
  2469. * one dimensional arrays of numbers, or two dimensional arrays with
  2470. * x and y values are allowed. Also, only the first point is tested,
  2471. * and the rest are assumed to be the same format. This saves expensive
  2472. * data checking and indexing in long series. Set it to `0` disable.
  2473. *
  2474. * Note:
  2475. * In boost mode turbo threshold is forced. Only array of numbers or
  2476. * two dimensional arrays are allowed.
  2477. *
  2478. * @since 2.2
  2479. * @product highcharts highstock gantt
  2480. *
  2481. * @private
  2482. */
  2483. turboThreshold: 1000,
  2484. /**
  2485. * An array defining zones within a series. Zones can be applied to the
  2486. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  2487. * option. The zone definitions have to be in ascending order regarding
  2488. * to the value.
  2489. *
  2490. * In styled mode, the color zones are styled with the
  2491. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  2492. * option
  2493. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  2494. *
  2495. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  2496. *
  2497. * @sample {highcharts} highcharts/series/color-zones-simple/
  2498. * Color zones
  2499. * @sample {highstock} highcharts/series/color-zones-simple/
  2500. * Color zones
  2501. *
  2502. * @declare Highcharts.SeriesZonesOptionsObject
  2503. * @type {Array<*>}
  2504. * @since 4.1.0
  2505. * @product highcharts highstock
  2506. * @apioption plotOptions.series.zones
  2507. */
  2508. /**
  2509. * Styled mode only. A custom class name for the zone.
  2510. *
  2511. * @sample highcharts/css/color-zones/
  2512. * Zones styled by class name
  2513. *
  2514. * @type {string}
  2515. * @since 5.0.0
  2516. * @apioption plotOptions.series.zones.className
  2517. */
  2518. /**
  2519. * Defines the color of the series.
  2520. *
  2521. * @see [series color](#plotOptions.series.color)
  2522. *
  2523. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2524. * @since 4.1.0
  2525. * @product highcharts highstock
  2526. * @apioption plotOptions.series.zones.color
  2527. */
  2528. /**
  2529. * A name for the dash style to use for the graph.
  2530. *
  2531. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  2532. *
  2533. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  2534. * Dashed line indicates prognosis
  2535. *
  2536. * @type {Highcharts.DashStyleValue}
  2537. * @since 4.1.0
  2538. * @product highcharts highstock
  2539. * @apioption plotOptions.series.zones.dashStyle
  2540. */
  2541. /**
  2542. * Defines the fill color for the series (in area type series)
  2543. *
  2544. * @see [fillColor](#plotOptions.area.fillColor)
  2545. *
  2546. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2547. * @since 4.1.0
  2548. * @product highcharts highstock
  2549. * @apioption plotOptions.series.zones.fillColor
  2550. */
  2551. /**
  2552. * The value up to where the zone extends, if undefined the zones
  2553. * stretches to the last value in the series.
  2554. *
  2555. * @type {number}
  2556. * @since 4.1.0
  2557. * @product highcharts highstock
  2558. * @apioption plotOptions.series.zones.value
  2559. */
  2560. /**
  2561. * When using dual or multiple color axes, this number defines which
  2562. * colorAxis the particular series is connected to. It refers to
  2563. * either the
  2564. * {@link #colorAxis.id|axis id}
  2565. * or the index of the axis in the colorAxis array, with 0 being the
  2566. * first. Set this option to false to prevent a series from connecting
  2567. * to the default color axis.
  2568. *
  2569. * Since v7.2.0 the option can also be an axis id or an axis index
  2570. * instead of a boolean flag.
  2571. *
  2572. * @sample highcharts/coloraxis/coloraxis-with-pie/
  2573. * Color axis with pie series
  2574. * @sample highcharts/coloraxis/multiple-coloraxis/
  2575. * Multiple color axis
  2576. *
  2577. * @type {number|string|boolean}
  2578. * @default 0
  2579. * @product highcharts highstock highmaps
  2580. * @apioption plotOptions.series.colorAxis
  2581. */
  2582. /**
  2583. * Determines what data value should be used to calculate point color
  2584. * if `colorAxis` is used. Requires to set `min` and `max` if some
  2585. * custom point property is used or if approximation for data grouping
  2586. * is set to `'sum'`.
  2587. *
  2588. * @sample highcharts/coloraxis/custom-color-key/
  2589. * Custom color key
  2590. * @sample highcharts/coloraxis/changed-default-color-key/
  2591. * Changed default color key
  2592. *
  2593. * @type {string}
  2594. * @default y
  2595. * @since 7.2.0
  2596. * @product highcharts highstock highmaps
  2597. * @apioption plotOptions.series.colorKey
  2598. */
  2599. /**
  2600. * Determines whether the series should look for the nearest point
  2601. * in both dimensions or just the x-dimension when hovering the series.
  2602. * Defaults to `'xy'` for scatter series and `'x'` for most other
  2603. * series. If the data has duplicate x-values, it is recommended to
  2604. * set this to `'xy'` to allow hovering over all points.
  2605. *
  2606. * Applies only to series types using nearest neighbor search (not
  2607. * direct hover) for tooltip.
  2608. *
  2609. * @sample {highcharts} highcharts/series/findnearestpointby/
  2610. * Different hover behaviors
  2611. * @sample {highstock} highcharts/series/findnearestpointby/
  2612. * Different hover behaviors
  2613. * @sample {highmaps} highcharts/series/findnearestpointby/
  2614. * Different hover behaviors
  2615. *
  2616. * @since 5.0.10
  2617. * @validvalue ["x", "xy"]
  2618. *
  2619. * @private
  2620. */
  2621. findNearestPointBy: 'x'
  2622. },
  2623. /* eslint-disable no-invalid-this, valid-jsdoc */
  2624. /** @lends Highcharts.Series.prototype */
  2625. {
  2626. axisTypes: ['xAxis', 'yAxis'],
  2627. coll: 'series',
  2628. colorCounter: 0,
  2629. cropShoulder: 1,
  2630. directTouch: false,
  2631. eventsToUnbind: [],
  2632. isCartesian: true,
  2633. // each point's x and y values are stored in this.xData and this.yData
  2634. parallelArrays: ['x', 'y'],
  2635. pointClass: Point,
  2636. requireSorting: true,
  2637. sorted: true,
  2638. init: function (chart, options) {
  2639. fireEvent(this, 'init', { options: options });
  2640. var series = this, events, chartSeries = chart.series, lastSeries;
  2641. // A lookup over those events that are added by _options_ (not
  2642. // programmatically). These are updated through Series.update()
  2643. // (#10861).
  2644. this.eventOptions = this.eventOptions || {};
  2645. /**
  2646. * Read only. The chart that the series belongs to.
  2647. *
  2648. * @name Highcharts.Series#chart
  2649. * @type {Highcharts.Chart}
  2650. */
  2651. series.chart = chart;
  2652. /**
  2653. * Read only. The series' type, like "line", "area", "column" etc.
  2654. * The type in the series options anc can be altered using
  2655. * {@link Series#update}.
  2656. *
  2657. * @name Highcharts.Series#type
  2658. * @type {string}
  2659. */
  2660. /**
  2661. * Read only. The series' current options. To update, use
  2662. * {@link Series#update}.
  2663. *
  2664. * @name Highcharts.Series#options
  2665. * @type {Highcharts.SeriesOptionsType}
  2666. */
  2667. series.options = options = series.setOptions(options);
  2668. series.linkedSeries = [];
  2669. // bind the axes
  2670. series.bindAxes();
  2671. // set some variables
  2672. extend(series, {
  2673. /**
  2674. * The series name as given in the options. Defaults to
  2675. * "Series {n}".
  2676. *
  2677. * @name Highcharts.Series#name
  2678. * @type {string}
  2679. */
  2680. name: options.name,
  2681. state: '',
  2682. /**
  2683. * Read only. The series' visibility state as set by {@link
  2684. * Series#show}, {@link Series#hide}, or in the initial
  2685. * configuration.
  2686. *
  2687. * @name Highcharts.Series#visible
  2688. * @type {boolean}
  2689. */
  2690. visible: options.visible !== false,
  2691. /**
  2692. * Read only. The series' selected state as set by {@link
  2693. * Highcharts.Series#select}.
  2694. *
  2695. * @name Highcharts.Series#selected
  2696. * @type {boolean}
  2697. */
  2698. selected: options.selected === true // false by default
  2699. });
  2700. // Register event listeners
  2701. events = options.events;
  2702. objectEach(events, function (event, eventType) {
  2703. if (isFunction(event)) {
  2704. // If event does not exist, or is changed by Series.update
  2705. if (series.eventOptions[eventType] !== event) {
  2706. // Remove existing if set by option
  2707. if (isFunction(series.eventOptions[eventType])) {
  2708. removeEvent(series, eventType, series.eventOptions[eventType]);
  2709. }
  2710. series.eventOptions[eventType] = event;
  2711. addEvent(series, eventType, event);
  2712. }
  2713. }
  2714. });
  2715. if ((events && events.click) ||
  2716. (options.point &&
  2717. options.point.events &&
  2718. options.point.events.click) ||
  2719. options.allowPointSelect) {
  2720. chart.runTrackerClick = true;
  2721. }
  2722. series.getColor();
  2723. series.getSymbol();
  2724. // Initialize the parallel data arrays
  2725. series.parallelArrays.forEach(function (key) {
  2726. if (!series[key + 'Data']) {
  2727. series[key + 'Data'] = [];
  2728. }
  2729. });
  2730. // Mark cartesian
  2731. if (series.isCartesian) {
  2732. chart.hasCartesianSeries = true;
  2733. }
  2734. // Get the index and register the series in the chart. The index is
  2735. // one more than the current latest series index (#5960).
  2736. if (chartSeries.length) {
  2737. lastSeries = chartSeries[chartSeries.length - 1];
  2738. }
  2739. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  2740. series.opacity = series.options.opacity;
  2741. // Insert the series and re-order all series above the insertion
  2742. // point.
  2743. chart.orderSeries(this.insert(chartSeries));
  2744. // Set options for series with sorting and set data later.
  2745. if (options.dataSorting && options.dataSorting.enabled) {
  2746. series.setDataSortingOptions();
  2747. }
  2748. else if (!series.points && !series.data) {
  2749. series.setData(options.data, false);
  2750. }
  2751. fireEvent(this, 'afterInit');
  2752. },
  2753. /**
  2754. * Check whether the series item is itself or inherits from a certain
  2755. * series type.
  2756. *
  2757. * @function Highcharts.Series#is
  2758. * @param {string} type The type of series to check for, can be either
  2759. * featured or custom series types. For example `column`, `pie`,
  2760. * `ohlc` etc.
  2761. *
  2762. * @return {boolean}
  2763. * True if this item is or inherits from the given type.
  2764. */
  2765. is: function (type) {
  2766. return seriesTypes[type] && this instanceof seriesTypes[type];
  2767. },
  2768. /**
  2769. * Insert the series in a collection with other series, either the chart
  2770. * series or yAxis series, in the correct order according to the index
  2771. * option. Used internally when adding series.
  2772. *
  2773. * @private
  2774. * @function Highcharts.Series#insert
  2775. * @param {Array<Highcharts.Series>} collection
  2776. * A collection of series, like `chart.series` or `xAxis.series`.
  2777. * @return {number}
  2778. * The index of the series in the collection.
  2779. */
  2780. insert: function (collection) {
  2781. var indexOption = this.options.index, i;
  2782. // Insert by index option
  2783. if (isNumber(indexOption)) {
  2784. i = collection.length;
  2785. while (i--) {
  2786. // Loop down until the interted element has higher index
  2787. if (indexOption >=
  2788. pick(collection[i].options.index, collection[i]._i)) {
  2789. collection.splice(i + 1, 0, this);
  2790. break;
  2791. }
  2792. }
  2793. if (i === -1) {
  2794. collection.unshift(this);
  2795. }
  2796. i = i + 1;
  2797. // Or just push it to the end
  2798. }
  2799. else {
  2800. collection.push(this);
  2801. }
  2802. return pick(i, collection.length - 1);
  2803. },
  2804. /**
  2805. * Set the xAxis and yAxis properties of cartesian series, and register
  2806. * the series in the `axis.series` array.
  2807. *
  2808. * @private
  2809. * @function Highcharts.Series#bindAxes
  2810. * @return {void}
  2811. * @exception 18
  2812. */
  2813. bindAxes: function () {
  2814. var series = this, seriesOptions = series.options, chart = series.chart, axisOptions;
  2815. fireEvent(this, 'bindAxes', null, function () {
  2816. // repeat for xAxis and yAxis
  2817. (series.axisTypes || []).forEach(function (AXIS) {
  2818. // loop through the chart's axis objects
  2819. chart[AXIS].forEach(function (axis) {
  2820. axisOptions = axis.options;
  2821. // apply if the series xAxis or yAxis option mathches
  2822. // the number of the axis, or if undefined, use the
  2823. // first axis
  2824. if (seriesOptions[AXIS] ===
  2825. axisOptions.index ||
  2826. (typeof seriesOptions[AXIS] !==
  2827. 'undefined' &&
  2828. seriesOptions[AXIS] === axisOptions.id) ||
  2829. (typeof seriesOptions[AXIS] ===
  2830. 'undefined' &&
  2831. axisOptions.index === 0)) {
  2832. // register this series in the axis.series lookup
  2833. series.insert(axis.series);
  2834. // set this series.xAxis or series.yAxis reference
  2835. /**
  2836. * Read only. The unique xAxis object associated
  2837. * with the series.
  2838. *
  2839. * @name Highcharts.Series#xAxis
  2840. * @type {Highcharts.Axis}
  2841. */
  2842. /**
  2843. * Read only. The unique yAxis object associated
  2844. * with the series.
  2845. *
  2846. * @name Highcharts.Series#yAxis
  2847. * @type {Highcharts.Axis}
  2848. */
  2849. series[AXIS] = axis;
  2850. // mark dirty for redraw
  2851. axis.isDirty = true;
  2852. }
  2853. });
  2854. // The series needs an X and an Y axis
  2855. if (!series[AXIS] &&
  2856. series.optionalAxis !== AXIS) {
  2857. error(18, true, chart);
  2858. }
  2859. });
  2860. });
  2861. fireEvent(this, 'afterBindAxes');
  2862. },
  2863. /**
  2864. * For simple series types like line and column, the data values are
  2865. * held in arrays like xData and yData for quick lookup to find extremes
  2866. * and more. For multidimensional series like bubble and map, this can
  2867. * be extended with arrays like zData and valueData by adding to the
  2868. * `series.parallelArrays` array.
  2869. *
  2870. * @private
  2871. * @function Highcharts.Series#updateParallelArrays
  2872. * @param {Highcharts.Point} point
  2873. * @param {number|string} i
  2874. * @return {void}
  2875. */
  2876. updateParallelArrays: function (point, i) {
  2877. var series = point.series, args = arguments, fn = isNumber(i) ?
  2878. // Insert the value in the given position
  2879. function (key) {
  2880. var val = key === 'y' && series.toYData ?
  2881. series.toYData(point) :
  2882. point[key];
  2883. series[key + 'Data'][i] = val;
  2884. } :
  2885. // Apply the method specified in i with the following
  2886. // arguments as arguments
  2887. function (key) {
  2888. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  2889. };
  2890. series.parallelArrays.forEach(fn);
  2891. },
  2892. /**
  2893. * Define hasData functions for series. These return true if there
  2894. * are data points on this series within the plot area.
  2895. *
  2896. * @private
  2897. * @function Highcharts.Series#hasData
  2898. * @return {boolean}
  2899. */
  2900. hasData: function () {
  2901. return ((this.visible &&
  2902. typeof this.dataMax !== 'undefined' &&
  2903. typeof this.dataMin !== 'undefined') || ( // #3703
  2904. this.visible &&
  2905. this.yData &&
  2906. this.yData.length > 0) // #9758
  2907. );
  2908. },
  2909. /**
  2910. * Return an auto incremented x value based on the pointStart and
  2911. * pointInterval options. This is only used if an x value is not given
  2912. * for the point that calls autoIncrement.
  2913. *
  2914. * @private
  2915. * @function Highcharts.Series#autoIncrement
  2916. * @return {number}
  2917. */
  2918. autoIncrement: function () {
  2919. var options = this.options, xIncrement = this.xIncrement, date, pointInterval, pointIntervalUnit = options.pointIntervalUnit, time = this.chart.time;
  2920. xIncrement = pick(xIncrement, options.pointStart, 0);
  2921. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  2922. // Added code for pointInterval strings
  2923. if (pointIntervalUnit) {
  2924. date = new time.Date(xIncrement);
  2925. if (pointIntervalUnit === 'day') {
  2926. time.set('Date', date, time.get('Date', date) + pointInterval);
  2927. }
  2928. else if (pointIntervalUnit === 'month') {
  2929. time.set('Month', date, time.get('Month', date) + pointInterval);
  2930. }
  2931. else if (pointIntervalUnit === 'year') {
  2932. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  2933. }
  2934. pointInterval = date.getTime() - xIncrement;
  2935. }
  2936. this.xIncrement = xIncrement + pointInterval;
  2937. return xIncrement;
  2938. },
  2939. /**
  2940. * Internal function to set properties for series if data sorting is
  2941. * enabled.
  2942. *
  2943. * @private
  2944. * @function Highcharts.Series#setDataSortingOptions
  2945. * @return {void}
  2946. */
  2947. setDataSortingOptions: function () {
  2948. var options = this.options;
  2949. extend(this, {
  2950. requireSorting: false,
  2951. sorted: false,
  2952. enabledDataSorting: true,
  2953. allowDG: false
  2954. });
  2955. // To allow unsorted data for column series.
  2956. if (!defined(options.pointRange)) {
  2957. options.pointRange = 1;
  2958. }
  2959. },
  2960. /**
  2961. * Set the series options by merging from the options tree. Called
  2962. * internally on initializing and updating series. This function will
  2963. * not redraw the series. For API usage, use {@link Series#update}.
  2964. * @private
  2965. * @function Highcharts.Series#setOptions
  2966. * @param {Highcharts.SeriesOptionsType} itemOptions
  2967. * The series options.
  2968. * @return {Highcharts.SeriesOptionsType}
  2969. * @fires Highcharts.Series#event:afterSetOptions
  2970. */
  2971. setOptions: function (itemOptions) {
  2972. var chart = this.chart, chartOptions = chart.options, plotOptions = chartOptions.plotOptions, userOptions = chart.userOptions || {}, seriesUserOptions = merge(itemOptions), options, zones, zone, styledMode = chart.styledMode, e = {
  2973. plotOptions: plotOptions,
  2974. userOptions: seriesUserOptions
  2975. };
  2976. fireEvent(this, 'setOptions', e);
  2977. // These may be modified by the event
  2978. var typeOptions = e.plotOptions[this.type], userPlotOptions = (userOptions.plotOptions || {});
  2979. // use copy to prevent undetected changes (#9762)
  2980. /**
  2981. * Contains series options by the user without defaults.
  2982. * @name Highcharts.Series#userOptions
  2983. * @type {Highcharts.SeriesOptionsType}
  2984. */
  2985. this.userOptions = e.userOptions;
  2986. options = merge(typeOptions, plotOptions.series,
  2987. // #3881, chart instance plotOptions[type] should trump
  2988. // plotOptions.series
  2989. userOptions.plotOptions &&
  2990. userOptions.plotOptions[this.type], seriesUserOptions);
  2991. // The tooltip options are merged between global and series specific
  2992. // options. Importance order asscendingly:
  2993. // globals: (1)tooltip, (2)plotOptions.series,
  2994. // (3)plotOptions[this.type]
  2995. // init userOptions with possible later updates: 4-6 like 1-3 and
  2996. // (7)this series options
  2997. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  2998. defaultOptions.plotOptions.series &&
  2999. defaultOptions.plotOptions.series.tooltip, // 2
  3000. defaultOptions.plotOptions[this.type].tooltip, // 3
  3001. chartOptions.tooltip.userOptions, // 4
  3002. plotOptions.series &&
  3003. plotOptions.series.tooltip, // 5
  3004. plotOptions[this.type].tooltip, // 6
  3005. seriesUserOptions.tooltip // 7
  3006. );
  3007. // When shared tooltip, stickyTracking is true by default,
  3008. // unless user says otherwise.
  3009. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  3010. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  3011. true :
  3012. options.stickyTracking));
  3013. // Delete marker object if not allowed (#1125)
  3014. if (typeOptions.marker === null) {
  3015. delete options.marker;
  3016. }
  3017. // Handle color zones
  3018. this.zoneAxis = options.zoneAxis;
  3019. zones = this.zones = (options.zones || []).slice();
  3020. if ((options.negativeColor || options.negativeFillColor) &&
  3021. !options.zones) {
  3022. zone = {
  3023. value: options[this.zoneAxis + 'Threshold'] ||
  3024. options.threshold ||
  3025. 0,
  3026. className: 'highcharts-negative'
  3027. };
  3028. if (!styledMode) {
  3029. zone.color = options.negativeColor;
  3030. zone.fillColor = options.negativeFillColor;
  3031. }
  3032. zones.push(zone);
  3033. }
  3034. if (zones.length) { // Push one extra zone for the rest
  3035. if (defined(zones[zones.length - 1].value)) {
  3036. zones.push(styledMode ? {} : {
  3037. color: this.color,
  3038. fillColor: this.fillColor
  3039. });
  3040. }
  3041. }
  3042. fireEvent(this, 'afterSetOptions', { options: options });
  3043. return options;
  3044. },
  3045. /**
  3046. * Return series name in "Series {Number}" format or the one defined by
  3047. * a user. This method can be simply overridden as series name format
  3048. * can vary (e.g. technical indicators).
  3049. *
  3050. * @function Highcharts.Series#getName
  3051. * @return {string}
  3052. * The series name.
  3053. */
  3054. getName: function () {
  3055. // #4119
  3056. return pick(this.options.name, 'Series ' + (this.index + 1));
  3057. },
  3058. /**
  3059. * @private
  3060. * @function Highcharts.Series#getCyclic
  3061. * @param {string} prop
  3062. * @param {*} [value]
  3063. * @param {Highcharts.Dictionary<any>} [defaults]
  3064. * @return {void}
  3065. */
  3066. getCyclic: function (prop, value, defaults) {
  3067. var i, chart = this.chart, userOptions = this.userOptions, indexName = prop + 'Index', counterName = prop + 'Counter', len = defaults ? defaults.length : pick(chart.options.chart[prop + 'Count'], chart[prop + 'Count']), setting;
  3068. if (!value) {
  3069. // Pick up either the colorIndex option, or the _colorIndex
  3070. // after Series.update()
  3071. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  3072. if (defined(setting)) { // after Series.update()
  3073. i = setting;
  3074. }
  3075. else {
  3076. // #6138
  3077. if (!chart.series.length) {
  3078. chart[counterName] = 0;
  3079. }
  3080. userOptions['_' + indexName] = i =
  3081. chart[counterName] % len;
  3082. chart[counterName] += 1;
  3083. }
  3084. if (defaults) {
  3085. value = defaults[i];
  3086. }
  3087. }
  3088. // Set the colorIndex
  3089. if (typeof i !== 'undefined') {
  3090. this[indexName] = i;
  3091. }
  3092. this[prop] = value;
  3093. },
  3094. /**
  3095. * Get the series' color based on either the options or pulled from
  3096. * global options.
  3097. *
  3098. * @private
  3099. * @function Highcharts.Series#getColor
  3100. * @return {void}
  3101. */
  3102. getColor: function () {
  3103. if (this.chart.styledMode) {
  3104. this.getCyclic('color');
  3105. }
  3106. else if (this.options.colorByPoint) {
  3107. // #4359, selected slice got series.color even when colorByPoint
  3108. // was set.
  3109. this.options.color = null;
  3110. }
  3111. else {
  3112. this.getCyclic('color', this.options.color ||
  3113. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  3114. }
  3115. },
  3116. /**
  3117. * Get all points' instances created for this series.
  3118. *
  3119. * @private
  3120. * @function Highcharts.Series#getPointsCollection
  3121. * @return {Array<Highcharts.Point>}
  3122. */
  3123. getPointsCollection: function () {
  3124. return (this.hasGroupedData ? this.points : this.data) || [];
  3125. },
  3126. /**
  3127. * Get the series' symbol based on either the options or pulled from
  3128. * global options.
  3129. *
  3130. * @private
  3131. * @function Highcharts.Series#getSymbol
  3132. * @return {void}
  3133. */
  3134. getSymbol: function () {
  3135. var seriesMarkerOption = this.options.marker;
  3136. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  3137. },
  3138. /**
  3139. * Finds the index of an existing point that matches the given point
  3140. * options.
  3141. *
  3142. * @private
  3143. * @function Highcharts.Series#findPointIndex
  3144. * @param {Highcharts.PointOptionsObject} optionsObject
  3145. * The options of the point.
  3146. * @param {number} fromIndex
  3147. * The index to start searching from, used for optimizing
  3148. * series with required sorting.
  3149. * @returns {number|undefined}
  3150. * Returns the index of a matching point, or undefined if no
  3151. * match is found.
  3152. */
  3153. findPointIndex: function (optionsObject, fromIndex) {
  3154. var id = optionsObject.id, x = optionsObject.x, oldData = this.points, matchingPoint, matchedById, pointIndex, matchKey, dataSorting = this.options.dataSorting;
  3155. if (id) {
  3156. matchingPoint = this.chart.get(id);
  3157. }
  3158. else if (this.linkedParent || this.enabledDataSorting) {
  3159. matchKey = (dataSorting && dataSorting.matchByName) ?
  3160. 'name' : 'index';
  3161. matchingPoint = find(oldData, function (oldPoint) {
  3162. return !oldPoint.touched && oldPoint[matchKey] ===
  3163. optionsObject[matchKey];
  3164. });
  3165. // Add unmatched point as a new point
  3166. if (!matchingPoint) {
  3167. return void 0;
  3168. }
  3169. }
  3170. if (matchingPoint) {
  3171. pointIndex = matchingPoint && matchingPoint.index;
  3172. if (typeof pointIndex !== 'undefined') {
  3173. matchedById = true;
  3174. }
  3175. }
  3176. // Search for the same X in the existing data set
  3177. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  3178. pointIndex = this.xData.indexOf(x, fromIndex);
  3179. }
  3180. // Reduce pointIndex if data is cropped
  3181. if (pointIndex !== -1 &&
  3182. typeof pointIndex !== 'undefined' &&
  3183. this.cropped) {
  3184. pointIndex = (pointIndex >= this.cropStart) ?
  3185. pointIndex - this.cropStart : pointIndex;
  3186. }
  3187. if (!matchedById &&
  3188. oldData[pointIndex] && oldData[pointIndex].touched) {
  3189. pointIndex = void 0;
  3190. }
  3191. return pointIndex;
  3192. },
  3193. /**
  3194. * @private
  3195. * @borrows LegendSymbolMixin.drawLineMarker as Highcharts.Series#drawLegendSymbol
  3196. */
  3197. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  3198. /**
  3199. * Internal function called from setData. If the point count is the same
  3200. * as is was, or if there are overlapping X values, just run
  3201. * Point.update which is cheaper, allows animation, and keeps references
  3202. * to points. This also allows adding or removing points if the X-es
  3203. * don't match.
  3204. *
  3205. * @private
  3206. * @function Highcharts.Series#updateData
  3207. *
  3208. * @param {Array<Highcharts.PointOptionsType>} data
  3209. *
  3210. * @return {boolean}
  3211. */
  3212. updateData: function (data, animation) {
  3213. var options = this.options, dataSorting = options.dataSorting, oldData = this.points, pointsToAdd = [], hasUpdatedByKey, i, point, lastIndex, requireSorting = this.requireSorting, equalLength = data.length === oldData.length, succeeded = true;
  3214. this.xIncrement = null;
  3215. // Iterate the new data
  3216. data.forEach(function (pointOptions, i) {
  3217. var id, x, pointIndex, optionsObject = (defined(pointOptions) &&
  3218. this.pointClass.prototype.optionsToObject.call({ series: this }, pointOptions)) || {};
  3219. // Get the x of the new data point
  3220. x = optionsObject.x;
  3221. id = optionsObject.id;
  3222. if (id || isNumber(x)) {
  3223. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  3224. // Matching X not found
  3225. // or used already due to ununique x values (#8995),
  3226. // add point (but later)
  3227. if (pointIndex === -1 ||
  3228. typeof pointIndex === 'undefined') {
  3229. pointsToAdd.push(pointOptions);
  3230. // Matching X found, update
  3231. }
  3232. else if (oldData[pointIndex] &&
  3233. pointOptions !== options.data[pointIndex]) {
  3234. oldData[pointIndex].update(pointOptions, false, null, false);
  3235. // Mark it touched, below we will remove all points that
  3236. // are not touched.
  3237. oldData[pointIndex].touched = true;
  3238. // Speed optimize by only searching after last known
  3239. // index. Performs ~20% bettor on large data sets.
  3240. if (requireSorting) {
  3241. lastIndex = pointIndex + 1;
  3242. }
  3243. // Point exists, no changes, don't remove it
  3244. }
  3245. else if (oldData[pointIndex]) {
  3246. oldData[pointIndex].touched = true;
  3247. }
  3248. // If the length is equal and some of the nodes had a
  3249. // match in the same position, we don't want to remove
  3250. // non-matches.
  3251. if (!equalLength ||
  3252. i !== pointIndex ||
  3253. (dataSorting && dataSorting.enabled) ||
  3254. this.hasDerivedData) {
  3255. hasUpdatedByKey = true;
  3256. }
  3257. }
  3258. else {
  3259. // Gather all points that are not matched
  3260. pointsToAdd.push(pointOptions);
  3261. }
  3262. }, this);
  3263. // Remove points that don't exist in the updated data set
  3264. if (hasUpdatedByKey) {
  3265. i = oldData.length;
  3266. while (i--) {
  3267. point = oldData[i];
  3268. if (point && !point.touched && point.remove) {
  3269. point.remove(false, animation);
  3270. }
  3271. }
  3272. // If we did not find keys (ids or x-values), and the length is the
  3273. // same, update one-to-one
  3274. }
  3275. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  3276. data.forEach(function (point, i) {
  3277. // .update doesn't exist on a linked, hidden series (#3709)
  3278. // (#10187)
  3279. if (oldData[i].update && point !== oldData[i].y) {
  3280. oldData[i].update(point, false, null, false);
  3281. }
  3282. });
  3283. // Don't add new points since those configs are used above
  3284. pointsToAdd.length = 0;
  3285. // Did not succeed in updating data
  3286. }
  3287. else {
  3288. succeeded = false;
  3289. }
  3290. oldData.forEach(function (point) {
  3291. if (point) {
  3292. point.touched = false;
  3293. }
  3294. });
  3295. if (!succeeded) {
  3296. return false;
  3297. }
  3298. // Add new points
  3299. pointsToAdd.forEach(function (point) {
  3300. this.addPoint(point, false, null, null, false);
  3301. }, this);
  3302. if (this.xIncrement === null &&
  3303. this.xData &&
  3304. this.xData.length) {
  3305. this.xIncrement = arrayMax(this.xData);
  3306. this.autoIncrement();
  3307. }
  3308. return true;
  3309. },
  3310. /**
  3311. * Apply a new set of data to the series and optionally redraw it. The
  3312. * new data array is passed by reference (except in case of
  3313. * `updatePoints`), and may later be mutated when updating the chart
  3314. * data.
  3315. *
  3316. * Note the difference in behaviour when setting the same amount of
  3317. * points, or a different amount of points, as handled by the
  3318. * `updatePoints` parameter.
  3319. *
  3320. * @sample highcharts/members/series-setdata/
  3321. * Set new data from a button
  3322. * @sample highcharts/members/series-setdata-pie/
  3323. * Set data in a pie
  3324. * @sample stock/members/series-setdata/
  3325. * Set new data in Highstock
  3326. * @sample maps/members/series-setdata/
  3327. * Set new data in Highmaps
  3328. *
  3329. * @function Highcharts.Series#setData
  3330. *
  3331. * @param {Array<Highcharts.PointOptionsType>} data
  3332. * Takes an array of data in the same format as described under
  3333. * `series.{type}.data` for the given series type, for example a
  3334. * line series would take data in the form described under
  3335. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  3336. *
  3337. * @param {boolean} [redraw=true]
  3338. * Whether to redraw the chart after the series is altered. If
  3339. * doing more operations on the chart, it is a good idea to set
  3340. * redraw to false and call {@link Chart#redraw} after.
  3341. *
  3342. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  3343. * When the updated data is the same length as the existing data,
  3344. * points will be updated by default, and animation visualizes
  3345. * how the points are changed. Set false to disable animation, or
  3346. * a configuration object to set duration or easing.
  3347. *
  3348. * @param {boolean} [updatePoints=true]
  3349. * When this is true, points will be updated instead of replaced
  3350. * whenever possible. This occurs a) when the updated data is the
  3351. * same length as the existing data, b) when points are matched
  3352. * by their id's, or c) when points can be matched by X values.
  3353. * This allows updating with animation and performs better. In
  3354. * this case, the original array is not passed by reference. Set
  3355. * `false` to prevent.
  3356. *
  3357. * @return {void}
  3358. */
  3359. setData: function (data, redraw, animation, updatePoints) {
  3360. var series = this, oldData = series.points, oldDataLength = (oldData && oldData.length) || 0, dataLength, options = series.options, chart = series.chart, dataSorting = options.dataSorting, firstPoint = null, xAxis = series.xAxis, i, turboThreshold = options.turboThreshold, pt, xData = this.xData, yData = this.yData, pointArrayMap = series.pointArrayMap, valueCount = pointArrayMap && pointArrayMap.length, keys = options.keys, indexOfX = 0, indexOfY = 1, updatedData;
  3361. data = data || [];
  3362. dataLength = data.length;
  3363. redraw = pick(redraw, true);
  3364. if (dataSorting && dataSorting.enabled) {
  3365. data = this.sortData(data);
  3366. }
  3367. // First try to run Point.update which is cheaper, allows animation,
  3368. // and keeps references to points.
  3369. if (updatePoints !== false &&
  3370. dataLength &&
  3371. oldDataLength &&
  3372. !series.cropped &&
  3373. !series.hasGroupedData &&
  3374. series.visible &&
  3375. // Soft updating has no benefit in boost, and causes JS error
  3376. // (#8355)
  3377. !series.isSeriesBoosting) {
  3378. updatedData = this.updateData(data, animation);
  3379. }
  3380. if (!updatedData) {
  3381. // Reset properties
  3382. series.xIncrement = null;
  3383. series.colorCounter = 0; // for series with colorByPoint (#1547)
  3384. // Update parallel arrays
  3385. this.parallelArrays.forEach(function (key) {
  3386. series[key + 'Data'].length = 0;
  3387. });
  3388. // In turbo mode, only one- or twodimensional arrays of numbers
  3389. // are allowed. The first value is tested, and we assume that
  3390. // all the rest are defined the same way. Although the 'for'
  3391. // loops are similar, they are repeated inside each if-else
  3392. // conditional for max performance.
  3393. if (turboThreshold && dataLength > turboThreshold) {
  3394. firstPoint = series.getFirstValidPoint(data);
  3395. if (isNumber(firstPoint)) { // assume all points are numbers
  3396. for (i = 0; i < dataLength; i++) {
  3397. xData[i] = this.autoIncrement();
  3398. yData[i] = data[i];
  3399. }
  3400. // Assume all points are arrays when first point is
  3401. }
  3402. else if (isArray(firstPoint)) {
  3403. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  3404. for (i = 0; i < dataLength; i++) {
  3405. pt = data[i];
  3406. xData[i] = pt[0];
  3407. yData[i] =
  3408. pt.slice(1, valueCount + 1);
  3409. }
  3410. }
  3411. else { // [x, y]
  3412. if (keys) {
  3413. indexOfX = keys.indexOf('x');
  3414. indexOfY = keys.indexOf('y');
  3415. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  3416. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  3417. }
  3418. for (i = 0; i < dataLength; i++) {
  3419. pt = data[i];
  3420. xData[i] = pt[indexOfX];
  3421. yData[i] = pt[indexOfY];
  3422. }
  3423. }
  3424. }
  3425. else {
  3426. // Highcharts expects configs to be numbers or arrays in
  3427. // turbo mode
  3428. error(12, false, chart);
  3429. }
  3430. }
  3431. else {
  3432. for (i = 0; i < dataLength; i++) {
  3433. // stray commas in oldIE:
  3434. if (typeof data[i] !== 'undefined') {
  3435. pt = { series: series };
  3436. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  3437. series.updateParallelArrays(pt, i);
  3438. }
  3439. }
  3440. }
  3441. // Forgetting to cast strings to numbers is a common caveat when
  3442. // handling CSV or JSON
  3443. if (yData && isString(yData[0])) {
  3444. error(14, true, chart);
  3445. }
  3446. series.data = [];
  3447. series.options.data = series.userOptions.data = data;
  3448. // destroy old points
  3449. i = oldDataLength;
  3450. while (i--) {
  3451. if (oldData[i] && oldData[i].destroy) {
  3452. oldData[i].destroy();
  3453. }
  3454. }
  3455. // reset minRange (#878)
  3456. if (xAxis) {
  3457. xAxis.minRange = xAxis.userMinRange;
  3458. }
  3459. // redraw
  3460. series.isDirty = chart.isDirtyBox = true;
  3461. series.isDirtyData = !!oldData;
  3462. animation = false;
  3463. }
  3464. // Typically for pie series, points need to be processed and
  3465. // generated prior to rendering the legend
  3466. if (options.legendType === 'point') {
  3467. this.processData();
  3468. this.generatePoints();
  3469. }
  3470. if (redraw) {
  3471. chart.redraw(animation);
  3472. }
  3473. },
  3474. /**
  3475. * Internal function to sort series data
  3476. *
  3477. * @private
  3478. * @function Highcharts.Series#sortData
  3479. * @param {Array<Highcharts.PointOptionsType>} data
  3480. * Force data grouping.
  3481. * @return {Array<Highcharts.PointOptionsObject>}
  3482. */
  3483. sortData: function (data) {
  3484. var series = this, options = series.options, dataSorting = options.dataSorting, sortKey = dataSorting.sortKey || 'y', sortedData, getPointOptionsObject = function (series, pointOptions) {
  3485. return (defined(pointOptions) &&
  3486. series.pointClass.prototype.optionsToObject.call({
  3487. series: series
  3488. }, pointOptions)) || {};
  3489. };
  3490. data.forEach(function (pointOptions, i) {
  3491. data[i] = getPointOptionsObject(series, pointOptions);
  3492. data[i].index = i;
  3493. }, this);
  3494. // Sorting
  3495. sortedData = data.concat().sort(function (a, b) {
  3496. var aValue = getNestedProperty(sortKey, a);
  3497. var bValue = getNestedProperty(sortKey, b);
  3498. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  3499. });
  3500. // Set x value depending on the position in the array
  3501. sortedData.forEach(function (point, i) {
  3502. point.x = i;
  3503. }, this);
  3504. // Set the same x for linked series points if they don't have their
  3505. // own sorting
  3506. if (series.linkedSeries) {
  3507. series.linkedSeries.forEach(function (linkedSeries) {
  3508. var options = linkedSeries.options, seriesData = options.data;
  3509. if ((!options.dataSorting ||
  3510. !options.dataSorting.enabled) &&
  3511. seriesData) {
  3512. seriesData.forEach(function (pointOptions, i) {
  3513. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  3514. if (data[i]) {
  3515. seriesData[i].x = data[i].x;
  3516. seriesData[i].index = i;
  3517. }
  3518. });
  3519. linkedSeries.setData(seriesData, false);
  3520. }
  3521. });
  3522. }
  3523. return data;
  3524. },
  3525. /**
  3526. * Internal function to process the data by cropping away unused data
  3527. * points if the series is longer than the crop threshold. This saves
  3528. * computing time for large series.
  3529. *
  3530. * @private
  3531. * @function Highcharts.Series#getProcessedData
  3532. * @param {boolean} [forceExtremesFromAll]
  3533. * Force getting extremes of a total series data range.
  3534. * @return {Highcharts.SeriesProcessedDataObject}
  3535. */
  3536. getProcessedData: function (forceExtremesFromAll) {
  3537. var series = this,
  3538. // copied during slice operation:
  3539. processedXData = series.xData, processedYData = series.yData, dataLength = processedXData.length, croppedData, cropStart = 0, cropped, distance, closestPointRange, xAxis = series.xAxis, i, // loop variable
  3540. options = series.options, cropThreshold = options.cropThreshold, getExtremesFromAll = forceExtremesFromAll ||
  3541. series.getExtremesFromAll ||
  3542. options.getExtremesFromAll, // #4599
  3543. isCartesian = series.isCartesian, xExtremes, val2lin = xAxis && xAxis.val2lin, isLog = !!(xAxis && xAxis.logarithmic), throwOnUnsorted = series.requireSorting, min, max;
  3544. if (xAxis) {
  3545. // corrected for log axis (#3053)
  3546. xExtremes = xAxis.getExtremes();
  3547. min = xExtremes.min;
  3548. max = xExtremes.max;
  3549. }
  3550. // optionally filter out points outside the plot area
  3551. if (isCartesian &&
  3552. series.sorted &&
  3553. !getExtremesFromAll &&
  3554. (!cropThreshold ||
  3555. dataLength > cropThreshold ||
  3556. series.forceCrop)) {
  3557. // it's outside current extremes
  3558. if (processedXData[dataLength - 1] < min ||
  3559. processedXData[0] > max) {
  3560. processedXData = [];
  3561. processedYData = [];
  3562. // only crop if it's actually spilling out
  3563. }
  3564. else if (series.yData && (processedXData[0] < min ||
  3565. processedXData[dataLength - 1] > max)) {
  3566. croppedData = this.cropData(series.xData, series.yData, min, max);
  3567. processedXData = croppedData.xData;
  3568. processedYData = croppedData.yData;
  3569. cropStart = croppedData.start;
  3570. cropped = true;
  3571. }
  3572. }
  3573. // Find the closest distance between processed points
  3574. i = processedXData.length || 1;
  3575. while (--i) {
  3576. distance = (isLog ?
  3577. (val2lin(processedXData[i]) -
  3578. val2lin(processedXData[i - 1])) :
  3579. (processedXData[i] -
  3580. processedXData[i - 1]));
  3581. if (distance > 0 &&
  3582. (typeof closestPointRange === 'undefined' ||
  3583. distance < closestPointRange)) {
  3584. closestPointRange = distance;
  3585. // Unsorted data is not supported by the line tooltip, as well
  3586. // as data grouping and navigation in Stock charts (#725) and
  3587. // width calculation of columns (#1900)
  3588. }
  3589. else if (distance < 0 && throwOnUnsorted) {
  3590. error(15, false, series.chart);
  3591. throwOnUnsorted = false; // Only once
  3592. }
  3593. }
  3594. return {
  3595. xData: processedXData,
  3596. yData: processedYData,
  3597. cropped: cropped,
  3598. cropStart: cropStart,
  3599. closestPointRange: closestPointRange
  3600. };
  3601. },
  3602. /**
  3603. * Internal function to apply processed data.
  3604. * In Highstock, this function is extended to provide data grouping.
  3605. *
  3606. * @private
  3607. * @function Highcharts.Series#processData
  3608. * @param {boolean} [force]
  3609. * Force data grouping.
  3610. * @return {boolean|undefined}
  3611. */
  3612. processData: function (force) {
  3613. var series = this, xAxis = series.xAxis, processedData;
  3614. // If the series data or axes haven't changed, don't go through
  3615. // this. Return false to pass the message on to override methods
  3616. // like in data grouping.
  3617. if (series.isCartesian &&
  3618. !series.isDirty &&
  3619. !xAxis.isDirty &&
  3620. !series.yAxis.isDirty &&
  3621. !force) {
  3622. return false;
  3623. }
  3624. processedData = series.getProcessedData();
  3625. // Record the properties
  3626. series.cropped = processedData.cropped; // undefined or true
  3627. series.cropStart = processedData.cropStart;
  3628. series.processedXData = processedData.xData;
  3629. series.processedYData = processedData.yData;
  3630. series.closestPointRange =
  3631. series.basePointRange = processedData.closestPointRange;
  3632. },
  3633. /**
  3634. * Iterate over xData and crop values between min and max. Returns
  3635. * object containing crop start/end cropped xData with corresponding
  3636. * part of yData, dataMin and dataMax within the cropped range.
  3637. *
  3638. * @private
  3639. * @function Highcharts.Series#cropData
  3640. * @param {Array<number>} xData
  3641. * @param {Array<number>} yData
  3642. * @param {number} min
  3643. * @param {number} max
  3644. * @param {number} [cropShoulder]
  3645. * @return {Highcharts.SeriesCropDataObject}
  3646. */
  3647. cropData: function (xData, yData, min, max, cropShoulder) {
  3648. var dataLength = xData.length, cropStart = 0, cropEnd = dataLength, i, j;
  3649. // line-type series need one point outside
  3650. cropShoulder = pick(cropShoulder, this.cropShoulder);
  3651. // iterate up to find slice start
  3652. for (i = 0; i < dataLength; i++) {
  3653. if (xData[i] >= min) {
  3654. cropStart = Math.max(0, i - cropShoulder);
  3655. break;
  3656. }
  3657. }
  3658. // proceed to find slice end
  3659. for (j = i; j < dataLength; j++) {
  3660. if (xData[j] > max) {
  3661. cropEnd = j + cropShoulder;
  3662. break;
  3663. }
  3664. }
  3665. return {
  3666. xData: xData.slice(cropStart, cropEnd),
  3667. yData: yData.slice(cropStart, cropEnd),
  3668. start: cropStart,
  3669. end: cropEnd
  3670. };
  3671. },
  3672. /**
  3673. * Generate the data point after the data has been processed by cropping
  3674. * away unused points and optionally grouped in Highcharts Stock.
  3675. *
  3676. * @private
  3677. * @function Highcharts.Series#generatePoints
  3678. */
  3679. generatePoints: function () {
  3680. var series = this, options = series.options, dataOptions = options.data, data = series.data, dataLength, processedXData = series.processedXData, processedYData = series.processedYData, PointClass = series.pointClass, processedDataLength = processedXData.length, cropStart = series.cropStart || 0, cursor, hasGroupedData = series.hasGroupedData, keys = options.keys, point, points = [], i;
  3681. if (!data && !hasGroupedData) {
  3682. var arr = [];
  3683. arr.length = dataOptions.length;
  3684. data = series.data = arr;
  3685. }
  3686. if (keys && hasGroupedData) {
  3687. // grouped data has already applied keys (#6590)
  3688. series.options.keys = false;
  3689. }
  3690. for (i = 0; i < processedDataLength; i++) {
  3691. cursor = cropStart + i;
  3692. if (!hasGroupedData) {
  3693. point = data[cursor];
  3694. // #970:
  3695. if (!point &&
  3696. typeof dataOptions[cursor] !== 'undefined') {
  3697. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  3698. }
  3699. }
  3700. else {
  3701. // splat the y data in case of ohlc data array
  3702. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  3703. /**
  3704. * Highstock only. If a point object is created by data
  3705. * grouping, it doesn't reflect actual points in the raw
  3706. * data. In this case, the `dataGroup` property holds
  3707. * information that points back to the raw data.
  3708. *
  3709. * - `dataGroup.start` is the index of the first raw data
  3710. * point in the group.
  3711. *
  3712. * - `dataGroup.length` is the amount of points in the
  3713. * group.
  3714. *
  3715. * @product highstock
  3716. *
  3717. * @name Highcharts.Point#dataGroup
  3718. * @type {Highcharts.DataGroupingInfoObject|undefined}
  3719. */
  3720. point.dataGroup = series.groupMap[i];
  3721. if (point.dataGroup.options) {
  3722. point.options = point.dataGroup.options;
  3723. extend(point, point.dataGroup.options);
  3724. // Collision of props and options (#9770)
  3725. delete point.dataLabels;
  3726. }
  3727. }
  3728. if (point) { // #6279
  3729. /**
  3730. * Contains the point's index in the `Series.points` array.
  3731. *
  3732. * @name Highcharts.Point#index
  3733. * @type {number}
  3734. * @readonly
  3735. */
  3736. point.index = cursor; // For faster access in Point.update
  3737. points[i] = point;
  3738. }
  3739. }
  3740. // restore keys options (#6590)
  3741. series.options.keys = keys;
  3742. // Hide cropped-away points - this only runs when the number of
  3743. // points is above cropThreshold, or when swithching view from
  3744. // non-grouped data to grouped data (#637)
  3745. if (data &&
  3746. (processedDataLength !== (dataLength = data.length) ||
  3747. hasGroupedData)) {
  3748. for (i = 0; i < dataLength; i++) {
  3749. // when has grouped data, clear all points
  3750. if (i === cropStart && !hasGroupedData) {
  3751. i += processedDataLength;
  3752. }
  3753. if (data[i]) {
  3754. data[i].destroyElements();
  3755. data[i].plotX = void 0; // #1003
  3756. }
  3757. }
  3758. }
  3759. /**
  3760. * Read only. An array containing those values converted to points.
  3761. * In case the series data length exceeds the `cropThreshold`, or if
  3762. * the data is grouped, `series.data` doesn't contain all the
  3763. * points. Also, in case a series is hidden, the `data` array may be
  3764. * empty. To access raw values, `series.options.data` will always be
  3765. * up to date. `Series.data` only contains the points that have been
  3766. * created on demand. To modify the data, use
  3767. * {@link Highcharts.Series#setData} or
  3768. * {@link Highcharts.Point#update}.
  3769. *
  3770. * @see Series.points
  3771. *
  3772. * @name Highcharts.Series#data
  3773. * @type {Array<Highcharts.Point>}
  3774. */
  3775. series.data = data;
  3776. /**
  3777. * An array containing all currently visible point objects. In case
  3778. * of cropping, the cropped-away points are not part of this array.
  3779. * The `series.points` array starts at `series.cropStart` compared
  3780. * to `series.data` and `series.options.data`. If however the series
  3781. * data is grouped, these can't be correlated one to one. To modify
  3782. * the data, use {@link Highcharts.Series#setData} or
  3783. * {@link Highcharts.Point#update}.
  3784. *
  3785. * @name Highcharts.Series#points
  3786. * @type {Array<Highcharts.Point>}
  3787. */
  3788. series.points = points;
  3789. fireEvent(this, 'afterGeneratePoints');
  3790. },
  3791. /**
  3792. * Get current X extremes for the visible data.
  3793. *
  3794. * @private
  3795. * @function Highcharts.Series#getXExtremes
  3796. *
  3797. * @param {Array<number>} xData
  3798. * The data to inspect. Defaults to the current data within the
  3799. * visible range.
  3800. * @return {Highcharts.RangeObject}
  3801. */
  3802. getXExtremes: function (xData) {
  3803. return {
  3804. min: arrayMin(xData),
  3805. max: arrayMax(xData)
  3806. };
  3807. },
  3808. /**
  3809. * Calculate Y extremes for the visible data. The result is returned
  3810. * as an object with `dataMin` and `dataMax` properties.
  3811. *
  3812. * @private
  3813. * @function Highcharts.Series#getExtremes
  3814. * @param {Array<number>} [yData]
  3815. * The data to inspect. Defaults to the current data within the
  3816. * visible range.
  3817. * @param {boolean} [forceExtremesFromAll]
  3818. * Force getting extremes of a total series data range.
  3819. * @return {Highcharts.DataExtremesObject}
  3820. */
  3821. getExtremes: function (yData, forceExtremesFromAll) {
  3822. var xAxis = this.xAxis, yAxis = this.yAxis, xData = this.processedXData || this.xData, yDataLength, activeYData = [], activeCounter = 0,
  3823. // #2117, need to compensate for log X axis
  3824. xExtremes, xMin = 0, xMax = 0, validValue, withinRange,
  3825. // Handle X outside the viewed area. This does not work with
  3826. // non-sorted data like scatter (#7639).
  3827. shoulder = this.requireSorting ? this.cropShoulder : 0, positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false, x, y, i, j;
  3828. yData = yData || this.stackedYData || this.processedYData || [];
  3829. yDataLength = yData.length;
  3830. if (xAxis) {
  3831. xExtremes = xAxis.getExtremes();
  3832. xMin = xExtremes.min;
  3833. xMax = xExtremes.max;
  3834. }
  3835. for (i = 0; i < yDataLength; i++) {
  3836. x = xData[i];
  3837. y = yData[i];
  3838. // For points within the visible range, including the first
  3839. // point outside the visible range (#7061), consider y extremes.
  3840. validValue = ((isNumber(y) || isArray(y)) &&
  3841. ((y.length || y > 0) || !positiveValuesOnly));
  3842. withinRange = (forceExtremesFromAll ||
  3843. this.getExtremesFromAll ||
  3844. this.options.getExtremesFromAll ||
  3845. this.cropped ||
  3846. !xAxis || // for colorAxis support
  3847. ((xData[i + shoulder] || x) >= xMin &&
  3848. (xData[i - shoulder] || x) <= xMax));
  3849. if (validValue && withinRange) {
  3850. j = y.length;
  3851. if (j) { // array, like ohlc or range data
  3852. while (j--) {
  3853. if (isNumber(y[j])) { // #7380, #11513
  3854. activeYData[activeCounter++] = y[j];
  3855. }
  3856. }
  3857. }
  3858. else {
  3859. activeYData[activeCounter++] = y;
  3860. }
  3861. }
  3862. }
  3863. var dataExtremes = {
  3864. dataMin: arrayMin(activeYData),
  3865. dataMax: arrayMax(activeYData)
  3866. };
  3867. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  3868. return dataExtremes;
  3869. },
  3870. /**
  3871. * Set the current data extremes as `dataMin` and `dataMax` on the
  3872. * Series item. Use this only when the series properties should be
  3873. * updated.
  3874. *
  3875. * @private
  3876. * @function Highcharts.Series#applyExtremes
  3877. * @return {void}
  3878. */
  3879. applyExtremes: function () {
  3880. var dataExtremes = this.getExtremes();
  3881. /**
  3882. * Contains the minimum value of the series' data point.
  3883. * @name Highcharts.Series#dataMin
  3884. * @type {number}
  3885. * @readonly
  3886. */
  3887. this.dataMin = dataExtremes.dataMin;
  3888. /* *
  3889. * Contains the maximum value of the series' data point.
  3890. * @name Highcharts.Series#dataMax
  3891. * @type {number}
  3892. * @readonly
  3893. */
  3894. this.dataMax = dataExtremes.dataMax;
  3895. return dataExtremes;
  3896. },
  3897. /**
  3898. * Find and return the first non null point in the data
  3899. *
  3900. * @private
  3901. * @function Highcharts.Series.getFirstValidPoint
  3902. * @param {Array<Highcharts.PointOptionsType>} data
  3903. * Array of options for points
  3904. *
  3905. * @return {Highcharts.PointOptionsType}
  3906. */
  3907. getFirstValidPoint: function (data) {
  3908. var firstPoint = null, dataLength = data.length, i = 0;
  3909. while (firstPoint === null && i < dataLength) {
  3910. firstPoint = data[i];
  3911. i++;
  3912. }
  3913. return firstPoint;
  3914. },
  3915. /**
  3916. * Translate data points from raw data values to chart specific
  3917. * positioning data needed later in the `drawPoints` and `drawGraph`
  3918. * functions. This function can be overridden in plugins and custom
  3919. * series type implementations.
  3920. *
  3921. * @function Highcharts.Series#translate
  3922. * @return {void}
  3923. * @fires Highcharts.Series#events:translate
  3924. */
  3925. translate: function () {
  3926. if (!this.processedXData) { // hidden series
  3927. this.processData();
  3928. }
  3929. this.generatePoints();
  3930. var series = this, options = series.options, stacking = options.stacking, xAxis = series.xAxis, categories = xAxis.categories, enabledDataSorting = series.enabledDataSorting, yAxis = series.yAxis, points = series.points, dataLength = points.length, hasModifyValue = !!series.modifyValue, i, pointPlacement = series.pointPlacementToXValue(), // #7860
  3931. dynamicallyPlaced = Boolean(pointPlacement), threshold = options.threshold, stackThreshold = options.startFromThreshold ? threshold : 0, plotX, lastPlotX, stackIndicator, zoneAxis = this.zoneAxis || 'y', closestPointRangePx = Number.MAX_VALUE;
  3932. /**
  3933. * Plotted coordinates need to be within a limited range. Drawing
  3934. * too far outside the viewport causes various rendering issues
  3935. * (#3201, #3923, #7555).
  3936. * @private
  3937. */
  3938. function limitedRange(val) {
  3939. return clamp(val, -1e5, 1e5);
  3940. }
  3941. // Translate each point
  3942. for (i = 0; i < dataLength; i++) {
  3943. var point = points[i], xValue = point.x, yValue = point.y, yBottom = point.low, stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  3944. yValue <
  3945. (stackThreshold ? 0 : threshold) ?
  3946. '-' :
  3947. '') + series.stackKey], pointStack, stackValues;
  3948. // Discard disallowed y values for log axes (#3434)
  3949. if (yAxis.positiveValuesOnly &&
  3950. yValue !== null &&
  3951. yValue <= 0) {
  3952. point.isNull = true;
  3953. }
  3954. // Get the plotX translation
  3955. point.plotX = plotX = correctFloat(// #5236
  3956. limitedRange(xAxis.translate(// #3923
  3957. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  3958. );
  3959. // Calculate the bottom y value for stacked series
  3960. if (stacking &&
  3961. series.visible &&
  3962. stack &&
  3963. stack[xValue]) {
  3964. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  3965. if (!point.isNull) {
  3966. pointStack = stack[xValue];
  3967. stackValues =
  3968. pointStack.points[stackIndicator.key];
  3969. }
  3970. }
  3971. if (isArray(stackValues)) {
  3972. yBottom = stackValues[0];
  3973. yValue = stackValues[1];
  3974. if (yBottom === stackThreshold &&
  3975. stackIndicator.key ===
  3976. stack[xValue].base) {
  3977. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  3978. }
  3979. // #1200, #1232
  3980. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  3981. yBottom = null;
  3982. }
  3983. point.total = point.stackTotal = pointStack.total;
  3984. point.percentage =
  3985. pointStack.total &&
  3986. (point.y / pointStack.total * 100);
  3987. point.stackY = yValue;
  3988. // Place the stack label
  3989. // in case of variwide series (where widths of points are
  3990. // different in most cases), stack labels are positioned
  3991. // wrongly, so the call of the setOffset is omited here and
  3992. // labels are correctly positioned later, at the end of the
  3993. // variwide's translate function (#10962)
  3994. if (!series.irregularWidths) {
  3995. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  3996. }
  3997. }
  3998. // Set translated yBottom or remove it
  3999. point.yBottom = defined(yBottom) ?
  4000. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  4001. null;
  4002. // general hook, used for Highstock compare mode
  4003. if (hasModifyValue) {
  4004. yValue = series.modifyValue(yValue, point);
  4005. }
  4006. // Set the the plotY value, reset it for redraws
  4007. // #3201
  4008. point.plotY = ((typeof yValue === 'number' && yValue !== Infinity) ?
  4009. limitedRange(yAxis.translate(yValue, 0, 1, 0, 1)) :
  4010. void 0);
  4011. point.isInside = this.isPointInside(point);
  4012. // Set client related positions for mouse tracking
  4013. point.clientX = dynamicallyPlaced ?
  4014. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  4015. plotX; // #1514, #5383, #5518
  4016. // Negative points. For bubble charts, this means negative z
  4017. // values (#9728)
  4018. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  4019. threshold ||
  4020. 0);
  4021. // some API data
  4022. point.category = (categories &&
  4023. typeof categories[point.x] !== 'undefined' ?
  4024. categories[point.x] :
  4025. point.x);
  4026. // Determine auto enabling of markers (#3635, #5099)
  4027. if (!point.isNull && point.visible !== false) {
  4028. if (typeof lastPlotX !== 'undefined') {
  4029. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  4030. }
  4031. lastPlotX = plotX;
  4032. }
  4033. // Find point zone
  4034. point.zone = (this.zones.length && point.getZone());
  4035. // Animate new points with data sorting
  4036. if (!point.graphic && series.group && enabledDataSorting) {
  4037. point.isNew = true;
  4038. }
  4039. }
  4040. series.closestPointRangePx = closestPointRangePx;
  4041. fireEvent(this, 'afterTranslate');
  4042. },
  4043. /**
  4044. * Return the series points with null points filtered out.
  4045. *
  4046. * @function Highcharts.Series#getValidPoints
  4047. *
  4048. * @param {Array<Highcharts.Point>} [points]
  4049. * The points to inspect, defaults to {@link Series.points}.
  4050. *
  4051. * @param {boolean} [insideOnly=false]
  4052. * Whether to inspect only the points that are inside the visible
  4053. * view.
  4054. *
  4055. * @param {boolean} [allowNull=false]
  4056. * Whether to allow null points to pass as valid points.
  4057. *
  4058. * @return {Array<Highcharts.Point>}
  4059. * The valid points.
  4060. */
  4061. getValidPoints: function (points, insideOnly, allowNull) {
  4062. var chart = this.chart;
  4063. // #3916, #5029, #5085
  4064. return (points || this.points || []).filter(function isValidPoint(point) {
  4065. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) {
  4066. return false;
  4067. }
  4068. return point.visible !== false &&
  4069. (allowNull || !point.isNull);
  4070. });
  4071. },
  4072. /**
  4073. * Get the clipping for the series. Could be called for a series to
  4074. * initiate animating the clip or to set the final clip (only width
  4075. * and x).
  4076. *
  4077. * @private
  4078. * @function Highcharts.Series#getClip
  4079. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  4080. * Initialize the animation.
  4081. * @param {boolean} [finalBox]
  4082. * Final size for the clip - end state for the animation.
  4083. * @return {Highcharts.Dictionary<number>}
  4084. */
  4085. getClipBox: function (animation, finalBox) {
  4086. var series = this, options = series.options, chart = series.chart, inverted = chart.inverted, xAxis = series.xAxis, yAxis = xAxis && series.yAxis, clipBox, scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  4087. if (animation && options.clip === false && yAxis) {
  4088. // support for not clipped series animation (#10450)
  4089. clipBox = inverted ? {
  4090. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  4091. height: chart.chartWidth,
  4092. width: chart.chartHeight,
  4093. x: -chart.chartHeight + xAxis.len + xAxis.pos
  4094. } : {
  4095. y: -yAxis.pos,
  4096. height: chart.chartHeight,
  4097. width: chart.chartWidth,
  4098. x: -xAxis.pos
  4099. };
  4100. // x and width will be changed later when setting for animation
  4101. // initial state in Series.setClip
  4102. }
  4103. else {
  4104. clipBox = series.clipBox || chart.clipBox;
  4105. if (finalBox) {
  4106. clipBox.width = chart.plotSizeX;
  4107. clipBox.x = (chart.scrollablePixelsX || 0) *
  4108. (scrollablePlotAreaOptions.scrollPositionX || 0);
  4109. }
  4110. }
  4111. return !finalBox ? clipBox : {
  4112. width: clipBox.width,
  4113. x: clipBox.x
  4114. };
  4115. },
  4116. /**
  4117. * Set the clipping for the series. For animated series it is called
  4118. * twice, first to initiate animating the clip then the second time
  4119. * without the animation to set the final clip.
  4120. *
  4121. * @private
  4122. * @function Highcharts.Series#setClip
  4123. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  4124. */
  4125. setClip: function (animation) {
  4126. var chart = this.chart, options = this.options, renderer = chart.renderer, inverted = chart.inverted, seriesClipBox = this.clipBox, clipBox = this.getClipBox(animation), sharedClipKey = this.sharedClipKey ||
  4127. [
  4128. '_sharedClip',
  4129. animation && animation.duration,
  4130. animation && animation.easing,
  4131. clipBox.height,
  4132. options.xAxis,
  4133. options.yAxis
  4134. ].join(','), // #4526
  4135. clipRect = chart[sharedClipKey], markerClipRect = chart[sharedClipKey + 'm'];
  4136. if (animation) {
  4137. clipBox.width = 0;
  4138. if (inverted) {
  4139. clipBox.x = chart.plotHeight +
  4140. (options.clip !== false ? 0 : chart.plotTop);
  4141. }
  4142. }
  4143. // If a clipping rectangle with the same properties is currently
  4144. // present in the chart, use that.
  4145. if (!clipRect) {
  4146. // When animation is set, prepare the initial positions
  4147. if (animation) {
  4148. chart[sharedClipKey + 'm'] = markerClipRect =
  4149. renderer.clipRect(
  4150. // include the width of the first marker
  4151. inverted ? chart.plotSizeX + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  4152. }
  4153. chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  4154. // Create hashmap for series indexes
  4155. clipRect.count = { length: 0 };
  4156. // When the series is rendered again before starting animating, in
  4157. // compliance to a responsive rule
  4158. }
  4159. else if (!chart.hasLoaded) {
  4160. clipRect.attr(clipBox);
  4161. }
  4162. if (animation) {
  4163. if (!clipRect.count[this.index]) {
  4164. clipRect.count[this.index] = true;
  4165. clipRect.count.length += 1;
  4166. }
  4167. }
  4168. if (options.clip !== false || animation) {
  4169. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  4170. this.markerGroup.clip(markerClipRect);
  4171. this.sharedClipKey = sharedClipKey;
  4172. }
  4173. // Remove the shared clipping rectangle when all series are shown
  4174. if (!animation) {
  4175. if (clipRect.count[this.index]) {
  4176. delete clipRect.count[this.index];
  4177. clipRect.count.length -= 1;
  4178. }
  4179. if (clipRect.count.length === 0 &&
  4180. sharedClipKey &&
  4181. chart[sharedClipKey]) {
  4182. if (!seriesClipBox) {
  4183. chart[sharedClipKey] =
  4184. chart[sharedClipKey].destroy();
  4185. }
  4186. if (chart[sharedClipKey + 'm']) {
  4187. chart[sharedClipKey + 'm'] =
  4188. chart[sharedClipKey + 'm'].destroy();
  4189. }
  4190. }
  4191. }
  4192. },
  4193. /**
  4194. * Animate in the series. Called internally twice. First with the `init`
  4195. * parameter set to true, which sets up the initial state of the
  4196. * animation. Then when ready, it is called with the `init` parameter
  4197. * undefined, in order to perform the actual animation. After the
  4198. * second run, the function is removed.
  4199. *
  4200. * @function Highcharts.Series#animate
  4201. *
  4202. * @param {boolean} [init]
  4203. * Initialize the animation.
  4204. */
  4205. animate: function (init) {
  4206. var series = this, chart = series.chart, animation = animObject(series.options.animation), clipRect, sharedClipKey, finalBox;
  4207. // Initialize the animation. Set up the clipping rectangle.
  4208. if (!chart.hasRendered) {
  4209. if (init) {
  4210. series.setClip(animation);
  4211. // Run the animation
  4212. }
  4213. else {
  4214. sharedClipKey = this.sharedClipKey;
  4215. clipRect = chart[sharedClipKey];
  4216. finalBox = series.getClipBox(animation, true);
  4217. if (clipRect) {
  4218. clipRect.animate(finalBox, animation);
  4219. }
  4220. if (chart[sharedClipKey + 'm']) {
  4221. chart[sharedClipKey + 'm'].animate({
  4222. width: finalBox.width + 99,
  4223. x: finalBox.x - (chart.inverted ? 0 : 99)
  4224. }, animation);
  4225. }
  4226. }
  4227. }
  4228. },
  4229. /**
  4230. * This runs after animation to land on the final plot clipping.
  4231. *
  4232. * @private
  4233. * @function Highcharts.Series#afterAnimate
  4234. * @fires Highcharts.Series#event:afterAnimate
  4235. */
  4236. afterAnimate: function () {
  4237. this.setClip();
  4238. fireEvent(this, 'afterAnimate');
  4239. this.finishedAnimating = true;
  4240. },
  4241. /**
  4242. * Draw the markers for line-like series types, and columns or other
  4243. * graphical representation for {@link Point} objects for other series
  4244. * types. The resulting element is typically stored as
  4245. * {@link Point.graphic}, and is created on the first call and updated
  4246. * and moved on subsequent calls.
  4247. *
  4248. * @function Highcharts.Series#drawPoints
  4249. */
  4250. drawPoints: function () {
  4251. var series = this, points = series.points, chart = series.chart, i, point, graphic, verb, options = series.options, seriesMarkerOptions = options.marker, pointMarkerOptions, hasPointMarker, markerGroup = (series[series.specialGroup] ||
  4252. series.markerGroup), xAxis = series.xAxis, markerAttribs, globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  4253. // Use larger or equal as radius is null in bubbles (#6321)
  4254. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  4255. seriesMarkerOptions.radius));
  4256. if (seriesMarkerOptions.enabled !== false ||
  4257. series._hasPointMarkers) {
  4258. for (i = 0; i < points.length; i++) {
  4259. point = points[i];
  4260. graphic = point.graphic;
  4261. verb = graphic ? 'animate' : 'attr';
  4262. pointMarkerOptions = point.marker || {};
  4263. hasPointMarker = !!point.marker;
  4264. var shouldDrawMarker = ((globallyEnabled &&
  4265. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  4266. // only draw the point if y is defined
  4267. if (shouldDrawMarker) {
  4268. // Shortcuts
  4269. var symbol = pick(pointMarkerOptions.symbol, series.symbol);
  4270. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  4271. // Set starting position for point sliding animation.
  4272. if (series.enabledDataSorting) {
  4273. point.startXPos = xAxis.reversed ?
  4274. -markerAttribs.width :
  4275. xAxis.width;
  4276. }
  4277. var isInside = point.isInside !== false;
  4278. if (graphic) { // update
  4279. // Since the marker group isn't clipped, each
  4280. // individual marker must be toggled
  4281. graphic[isInside ? 'show' : 'hide'](isInside)
  4282. .animate(markerAttribs);
  4283. }
  4284. else if (isInside &&
  4285. (markerAttribs.width > 0 || point.hasImage)) {
  4286. /**
  4287. * The graphic representation of the point.
  4288. * Typically this is a simple shape, like a `rect`
  4289. * for column charts or `path` for line markers, but
  4290. * for some complex series types like boxplot or 3D
  4291. * charts, the graphic may be a `g` element
  4292. * containing other shapes. The graphic is generated
  4293. * the first time {@link Series#drawPoints} runs,
  4294. * and updated and moved on subsequent runs.
  4295. *
  4296. * @name Point#graphic
  4297. * @type {SVGElement}
  4298. */
  4299. point.graphic = graphic = chart.renderer
  4300. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  4301. pointMarkerOptions :
  4302. seriesMarkerOptions)
  4303. .add(markerGroup);
  4304. // Sliding animation for new points
  4305. if (series.enabledDataSorting &&
  4306. chart.hasRendered) {
  4307. graphic.attr({
  4308. x: point.startXPos
  4309. });
  4310. verb = 'animate';
  4311. }
  4312. }
  4313. if (graphic && verb === 'animate') { // update
  4314. // Since the marker group isn't clipped, each
  4315. // individual marker must be toggled
  4316. graphic[isInside ? 'show' : 'hide'](isInside)
  4317. .animate(markerAttribs);
  4318. }
  4319. // Presentational attributes
  4320. if (graphic && !chart.styledMode) {
  4321. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  4322. }
  4323. if (graphic) {
  4324. graphic.addClass(point.getClassName(), true);
  4325. }
  4326. }
  4327. else if (graphic) {
  4328. point.graphic = graphic.destroy(); // #1269
  4329. }
  4330. }
  4331. }
  4332. },
  4333. /**
  4334. * Get non-presentational attributes for a point. Used internally for
  4335. * both styled mode and classic. Can be overridden for different series
  4336. * types.
  4337. *
  4338. * @see Series#pointAttribs
  4339. *
  4340. * @function Highcharts.Series#markerAttribs
  4341. *
  4342. * @param {Highcharts.Point} point
  4343. * The Point to inspect.
  4344. *
  4345. * @param {string} [state]
  4346. * The state, can be either `hover`, `select` or undefined.
  4347. *
  4348. * @return {Highcharts.SVGAttributes}
  4349. * A hash containing those attributes that are not settable from
  4350. * CSS.
  4351. */
  4352. markerAttribs: function (point, state) {
  4353. var seriesOptions = this.options, seriesMarkerOptions = seriesOptions.marker, seriesStateOptions, pointMarkerOptions = point.marker || {}, symbol = (pointMarkerOptions.symbol ||
  4354. seriesMarkerOptions.symbol), pointStateOptions, radius = pick(pointMarkerOptions.radius, seriesMarkerOptions.radius), attribs;
  4355. // Handle hover and select states
  4356. if (state) {
  4357. seriesStateOptions = seriesMarkerOptions.states[state];
  4358. pointStateOptions = pointMarkerOptions.states &&
  4359. pointMarkerOptions.states[state];
  4360. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  4361. 0));
  4362. }
  4363. point.hasImage = symbol && symbol.indexOf('url') === 0;
  4364. if (point.hasImage) {
  4365. radius = 0; // and subsequently width and height is not set
  4366. }
  4367. attribs = {
  4368. // Math.floor for #1843:
  4369. x: seriesOptions.crisp ?
  4370. Math.floor(point.plotX) - radius :
  4371. point.plotX - radius,
  4372. y: point.plotY - radius
  4373. };
  4374. if (radius) {
  4375. attribs.width = attribs.height = 2 * radius;
  4376. }
  4377. return attribs;
  4378. },
  4379. /**
  4380. * Internal function to get presentational attributes for each point.
  4381. * Unlike {@link Series#markerAttribs}, this function should return
  4382. * those attributes that can also be set in CSS. In styled mode,
  4383. * `pointAttribs` won't be called.
  4384. *
  4385. * @private
  4386. * @function Highcharts.Series#pointAttribs
  4387. *
  4388. * @param {Highcharts.Point} [point]
  4389. * The point instance to inspect.
  4390. *
  4391. * @param {string} [state]
  4392. * The point state, can be either `hover`, `select` or 'normal'.
  4393. * If undefined, normal state is assumed.
  4394. *
  4395. * @return {Highcharts.SVGAttributes}
  4396. * The presentational attributes to be set on the point.
  4397. */
  4398. pointAttribs: function (point, state) {
  4399. var seriesMarkerOptions = this.options.marker, seriesStateOptions, pointOptions = point && point.options, pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}), pointStateOptions, color = this.color, pointColorOption = pointOptions && pointOptions.color, pointColor = point && point.color, strokeWidth = pick(pointMarkerOptions.lineWidth, seriesMarkerOptions.lineWidth), zoneColor = point && point.zone && point.zone.color, fill, stroke, opacity = 1;
  4400. color = (pointColorOption ||
  4401. zoneColor ||
  4402. pointColor ||
  4403. color);
  4404. fill = (pointMarkerOptions.fillColor ||
  4405. seriesMarkerOptions.fillColor ||
  4406. color);
  4407. stroke = (pointMarkerOptions.lineColor ||
  4408. seriesMarkerOptions.lineColor ||
  4409. color);
  4410. // Handle hover and select states
  4411. state = state || 'normal';
  4412. if (state) {
  4413. seriesStateOptions = seriesMarkerOptions.states[state];
  4414. pointStateOptions = (pointMarkerOptions.states &&
  4415. pointMarkerOptions.states[state]) || {};
  4416. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  4417. fill = (pointStateOptions.fillColor ||
  4418. seriesStateOptions.fillColor ||
  4419. fill);
  4420. stroke = (pointStateOptions.lineColor ||
  4421. seriesStateOptions.lineColor ||
  4422. stroke);
  4423. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  4424. }
  4425. return {
  4426. 'stroke': stroke,
  4427. 'stroke-width': strokeWidth,
  4428. 'fill': fill,
  4429. 'opacity': opacity
  4430. };
  4431. },
  4432. /**
  4433. * Clear DOM objects and free up memory.
  4434. *
  4435. * @private
  4436. * @function Highcharts.Series#destroy
  4437. * @param {boolean} [keepEventsForUpdate]
  4438. * @return {void}
  4439. * @fires Highcharts.Series#event:destroy
  4440. */
  4441. destroy: function (keepEventsForUpdate) {
  4442. var series = this, chart = series.chart, issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent), destroy, i, data = series.data || [], point, axis;
  4443. // add event hook
  4444. fireEvent(series, 'destroy');
  4445. // remove events
  4446. this.removeEvents(keepEventsForUpdate);
  4447. // erase from axes
  4448. (series.axisTypes || []).forEach(function (AXIS) {
  4449. axis = series[AXIS];
  4450. if (axis && axis.series) {
  4451. erase(axis.series, series);
  4452. axis.isDirty = axis.forceRedraw = true;
  4453. }
  4454. });
  4455. // remove legend items
  4456. if (series.legendItem) {
  4457. series.chart.legend.destroyItem(series);
  4458. }
  4459. // destroy all points with their elements
  4460. i = data.length;
  4461. while (i--) {
  4462. point = data[i];
  4463. if (point && point.destroy) {
  4464. point.destroy();
  4465. }
  4466. }
  4467. series.points = null;
  4468. // Clear the animation timeout if we are destroying the series
  4469. // during initial animation
  4470. U.clearTimeout(series.animationTimeout);
  4471. // Destroy all SVGElements associated to the series
  4472. objectEach(series, function (val, prop) {
  4473. // Survive provides a hook for not destroying
  4474. if (val instanceof SVGElement && !val.survive) {
  4475. // issue 134 workaround
  4476. destroy = issue134 && prop === 'group' ?
  4477. 'hide' :
  4478. 'destroy';
  4479. val[destroy]();
  4480. }
  4481. });
  4482. // remove from hoverSeries
  4483. if (chart.hoverSeries === series) {
  4484. chart.hoverSeries = null;
  4485. }
  4486. erase(chart.series, series);
  4487. chart.orderSeries();
  4488. // clear all members
  4489. objectEach(series, function (val, prop) {
  4490. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  4491. delete series[prop];
  4492. }
  4493. });
  4494. },
  4495. /**
  4496. * Get the graph path.
  4497. *
  4498. * @private
  4499. * @function Highcharts.Series#getGraphPath
  4500. * @param {Array<Highcharts.Point>} points
  4501. * @param {boolean} [nullsAsZeroes]
  4502. * @param {boolean} [connectCliffs]
  4503. * @return {Highcharts.SVGPathArray}
  4504. */
  4505. getGraphPath: function (points, nullsAsZeroes, connectCliffs) {
  4506. var series = this, options = series.options, step = options.step, reversed, graphPath = [], xMap = [], gap;
  4507. points = points || series.points;
  4508. // Bottom of a stack is reversed
  4509. reversed = points.reversed;
  4510. if (reversed) {
  4511. points.reverse();
  4512. }
  4513. // Reverse the steps (#5004)
  4514. step = {
  4515. right: 1,
  4516. center: 2
  4517. }[step] || (step && 3);
  4518. if (step && reversed) {
  4519. step = 4 - step;
  4520. }
  4521. // Remove invalid points, especially in spline (#5015)
  4522. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  4523. // Build the line
  4524. points.forEach(function (point, i) {
  4525. var plotX = point.plotX, plotY = point.plotY, lastPoint = points[i - 1],
  4526. // the path to this point from the previous
  4527. pathToPoint;
  4528. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  4529. !connectCliffs) {
  4530. gap = true; // ... and continue
  4531. }
  4532. // Line series, nullsAsZeroes is not handled
  4533. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  4534. gap = !options.connectNulls;
  4535. // Area series, nullsAsZeroes is set
  4536. }
  4537. else if (point.isNull && !nullsAsZeroes) {
  4538. gap = true;
  4539. }
  4540. else {
  4541. if (i === 0 || gap) {
  4542. pathToPoint = [[
  4543. 'M',
  4544. point.plotX,
  4545. point.plotY
  4546. ]];
  4547. // Generate the spline as defined in the SplineSeries object
  4548. }
  4549. else if (series.getPointSpline) {
  4550. pathToPoint = [series.getPointSpline(points, point, i)];
  4551. }
  4552. else if (step) {
  4553. if (step === 1) { // right
  4554. pathToPoint = [[
  4555. 'L',
  4556. lastPoint.plotX,
  4557. plotY
  4558. ]];
  4559. }
  4560. else if (step === 2) { // center
  4561. pathToPoint = [[
  4562. 'L',
  4563. (lastPoint.plotX + plotX) / 2,
  4564. lastPoint.plotY
  4565. ], [
  4566. 'L',
  4567. (lastPoint.plotX + plotX) / 2,
  4568. plotY
  4569. ]];
  4570. }
  4571. else {
  4572. pathToPoint = [[
  4573. 'L',
  4574. plotX,
  4575. lastPoint.plotY
  4576. ]];
  4577. }
  4578. pathToPoint.push([
  4579. 'L',
  4580. plotX,
  4581. plotY
  4582. ]);
  4583. }
  4584. else {
  4585. // normal line to next point
  4586. pathToPoint = [[
  4587. 'L',
  4588. plotX,
  4589. plotY
  4590. ]];
  4591. }
  4592. // Prepare for animation. When step is enabled, there are
  4593. // two path nodes for each x value.
  4594. xMap.push(point.x);
  4595. if (step) {
  4596. xMap.push(point.x);
  4597. if (step === 2) { // step = center (#8073)
  4598. xMap.push(point.x);
  4599. }
  4600. }
  4601. graphPath.push.apply(graphPath, pathToPoint);
  4602. gap = false;
  4603. }
  4604. });
  4605. graphPath.xMap = xMap;
  4606. series.graphPath = graphPath;
  4607. return graphPath;
  4608. },
  4609. /**
  4610. * Draw the graph. Called internally when rendering line-like series
  4611. * types. The first time it generates the `series.graph` item and
  4612. * optionally other series-wide items like `series.area` for area
  4613. * charts. On subsequent calls these items are updated with new
  4614. * positions and attributes.
  4615. *
  4616. * @function Highcharts.Series#drawGraph
  4617. */
  4618. drawGraph: function () {
  4619. var series = this, options = this.options, graphPath = (this.gappedPath || this.getGraphPath).call(this), styledMode = this.chart.styledMode, props = [[
  4620. 'graph',
  4621. 'highcharts-graph'
  4622. ]];
  4623. // Presentational properties
  4624. if (!styledMode) {
  4625. props[0].push((options.lineColor ||
  4626. this.color ||
  4627. '#cccccc' // when colorByPoint = true
  4628. ), options.dashStyle);
  4629. }
  4630. props = series.getZonesGraphs(props);
  4631. // Draw the graph
  4632. props.forEach(function (prop, i) {
  4633. var graphKey = prop[0], graph = series[graphKey], verb = graph ? 'animate' : 'attr', attribs;
  4634. if (graph) {
  4635. graph.endX = series.preventGraphAnimation ?
  4636. null :
  4637. graphPath.xMap;
  4638. graph.animate({ d: graphPath });
  4639. }
  4640. else if (graphPath.length) { // #1487
  4641. /**
  4642. * SVG element of area-based charts. Can be used for styling
  4643. * purposes. If zones are configured, this element will be
  4644. * hidden and replaced by multiple zone areas, accessible
  4645. * via `series['zone-area-x']` (where x is a number,
  4646. * starting with 0).
  4647. *
  4648. * @name Highcharts.Series#area
  4649. * @type {Highcharts.SVGElement|undefined}
  4650. */
  4651. /**
  4652. * SVG element of line-based charts. Can be used for styling
  4653. * purposes. If zones are configured, this element will be
  4654. * hidden and replaced by multiple zone lines, accessible
  4655. * via `series['zone-graph-x']` (where x is a number,
  4656. * starting with 0).
  4657. *
  4658. * @name Highcharts.Series#graph
  4659. * @type {Highcharts.SVGElement|undefined}
  4660. */
  4661. series[graphKey] = graph = series.chart.renderer
  4662. .path(graphPath)
  4663. .addClass(prop[1])
  4664. .attr({ zIndex: 1 }) // #1069
  4665. .add(series.group);
  4666. }
  4667. if (graph && !styledMode) {
  4668. attribs = {
  4669. 'stroke': prop[2],
  4670. 'stroke-width': options.lineWidth,
  4671. // Polygon series use filled graph
  4672. 'fill': (series.fillGraph && series.color) || 'none'
  4673. };
  4674. if (prop[3]) {
  4675. attribs.dashstyle = prop[3];
  4676. }
  4677. else if (options.linecap !== 'square') {
  4678. attribs['stroke-linecap'] =
  4679. attribs['stroke-linejoin'] = 'round';
  4680. }
  4681. graph[verb](attribs)
  4682. // Add shadow to normal series (0) or to first
  4683. // zone (1) #3932
  4684. .shadow((i < 2) && options.shadow);
  4685. }
  4686. // Helpers for animation
  4687. if (graph) {
  4688. graph.startX = graphPath.xMap;
  4689. graph.isArea = graphPath.isArea; // For arearange animation
  4690. }
  4691. });
  4692. },
  4693. /**
  4694. * Get zones properties for building graphs. Extendable by series with
  4695. * multiple lines within one series.
  4696. *
  4697. * @private
  4698. * @function Highcharts.Series#getZonesGraphs
  4699. *
  4700. * @param {Array<Array<string>>} props
  4701. *
  4702. * @return {Array<Array<string>>}
  4703. */
  4704. getZonesGraphs: function (props) {
  4705. // Add the zone properties if any
  4706. this.zones.forEach(function (zone, i) {
  4707. var propset = [
  4708. 'zone-graph-' + i,
  4709. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  4710. (zone.className || '')
  4711. ];
  4712. if (!this.chart.styledMode) {
  4713. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  4714. }
  4715. props.push(propset);
  4716. }, this);
  4717. return props;
  4718. },
  4719. /**
  4720. * Clip the graphs into zones for colors and styling.
  4721. *
  4722. * @private
  4723. * @function Highcharts.Series#applyZones
  4724. * @return {void}
  4725. */
  4726. applyZones: function () {
  4727. var series = this, chart = this.chart, renderer = chart.renderer, zones = this.zones, translatedFrom, translatedTo, clips = (this.clips || []), clipAttr, graph = this.graph, area = this.area, chartSizeMax = Math.max(chart.chartWidth, chart.chartHeight), axis = this[(this.zoneAxis || 'y') + 'Axis'], extremes, reversed, inverted = chart.inverted, horiz, pxRange, pxPosMin, pxPosMax, ignoreZones = false, zoneArea, zoneGraph;
  4728. if (zones.length &&
  4729. (graph || area) &&
  4730. axis &&
  4731. typeof axis.min !== 'undefined') {
  4732. reversed = axis.reversed;
  4733. horiz = axis.horiz;
  4734. // The use of the Color Threshold assumes there are no gaps
  4735. // so it is safe to hide the original graph and area
  4736. // unless it is not waterfall series, then use showLine property
  4737. // to set lines between columns to be visible (#7862)
  4738. if (graph && !this.showLine) {
  4739. graph.hide();
  4740. }
  4741. if (area) {
  4742. area.hide();
  4743. }
  4744. // Create the clips
  4745. extremes = axis.getExtremes();
  4746. zones.forEach(function (threshold, i) {
  4747. translatedFrom = reversed ?
  4748. (horiz ? chart.plotWidth : 0) :
  4749. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  4750. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  4751. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  4752. if (ignoreZones) {
  4753. translatedFrom = translatedTo =
  4754. axis.toPixels(extremes.max);
  4755. }
  4756. pxRange = Math.abs(translatedFrom - translatedTo);
  4757. pxPosMin = Math.min(translatedFrom, translatedTo);
  4758. pxPosMax = Math.max(translatedFrom, translatedTo);
  4759. if (axis.isXAxis) {
  4760. clipAttr = {
  4761. x: inverted ? pxPosMax : pxPosMin,
  4762. y: 0,
  4763. width: pxRange,
  4764. height: chartSizeMax
  4765. };
  4766. if (!horiz) {
  4767. clipAttr.x = chart.plotHeight - clipAttr.x;
  4768. }
  4769. }
  4770. else {
  4771. clipAttr = {
  4772. x: 0,
  4773. y: inverted ? pxPosMax : pxPosMin,
  4774. width: chartSizeMax,
  4775. height: pxRange
  4776. };
  4777. if (horiz) {
  4778. clipAttr.y = chart.plotWidth - clipAttr.y;
  4779. }
  4780. }
  4781. // VML SUPPPORT
  4782. if (inverted && renderer.isVML) {
  4783. if (axis.isXAxis) {
  4784. clipAttr = {
  4785. x: 0,
  4786. y: reversed ? pxPosMin : pxPosMax,
  4787. height: clipAttr.width,
  4788. width: chart.chartWidth
  4789. };
  4790. }
  4791. else {
  4792. clipAttr = {
  4793. x: (clipAttr.y -
  4794. chart.plotLeft -
  4795. chart.spacingBox.x),
  4796. y: 0,
  4797. width: clipAttr.height,
  4798. height: chart.chartHeight
  4799. };
  4800. }
  4801. }
  4802. // END OF VML SUPPORT
  4803. if (clips[i]) {
  4804. clips[i].animate(clipAttr);
  4805. }
  4806. else {
  4807. clips[i] = renderer.clipRect(clipAttr);
  4808. }
  4809. // when no data, graph zone is not applied and after setData
  4810. // clip was ignored. As a result, it should be applied each
  4811. // time.
  4812. zoneArea = series['zone-area-' + i];
  4813. zoneGraph = series['zone-graph-' + i];
  4814. if (graph && zoneGraph) {
  4815. zoneGraph.clip(clips[i]);
  4816. }
  4817. if (area && zoneArea) {
  4818. zoneArea.clip(clips[i]);
  4819. }
  4820. // if this zone extends out of the axis, ignore the others
  4821. ignoreZones = threshold.value > extremes.max;
  4822. // Clear translatedTo for indicators
  4823. if (series.resetZones && translatedTo === 0) {
  4824. translatedTo = void 0;
  4825. }
  4826. });
  4827. this.clips = clips;
  4828. }
  4829. else if (series.visible) {
  4830. // If zones were removed, restore graph and area
  4831. if (graph) {
  4832. graph.show(true);
  4833. }
  4834. if (area) {
  4835. area.show(true);
  4836. }
  4837. }
  4838. },
  4839. /**
  4840. * Initialize and perform group inversion on series.group and
  4841. * series.markerGroup.
  4842. *
  4843. * @private
  4844. * @function Highcharts.Series#invertGroups
  4845. * @param {boolean} [inverted]
  4846. * @return {void}
  4847. */
  4848. invertGroups: function (inverted) {
  4849. var series = this, chart = series.chart;
  4850. /**
  4851. * @private
  4852. */
  4853. function setInvert() {
  4854. ['group', 'markerGroup'].forEach(function (groupName) {
  4855. if (series[groupName]) {
  4856. // VML/HTML needs explicit attributes for flipping
  4857. if (chart.renderer.isVML) {
  4858. series[groupName].attr({
  4859. width: series.yAxis.len,
  4860. height: series.xAxis.len
  4861. });
  4862. }
  4863. series[groupName].width = series.yAxis.len;
  4864. series[groupName].height = series.xAxis.len;
  4865. // If inverted polar, don't invert series group
  4866. series[groupName].invert(series.isRadialSeries ? false : inverted);
  4867. }
  4868. });
  4869. }
  4870. // Pie, go away (#1736)
  4871. if (!series.xAxis) {
  4872. return;
  4873. }
  4874. // A fixed size is needed for inversion to work
  4875. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  4876. // Do it now
  4877. setInvert();
  4878. // On subsequent render and redraw, just do setInvert without
  4879. // setting up events again
  4880. series.invertGroups = setInvert;
  4881. },
  4882. /**
  4883. * General abstraction for creating plot groups like series.group,
  4884. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  4885. * the group will only be adjusted to the updated plot size.
  4886. *
  4887. * @private
  4888. * @function Highcharts.Series#plotGroup
  4889. * @param {string} prop
  4890. * @param {string} name
  4891. * @param {string} visibility
  4892. * @param {number} [zIndex]
  4893. * @param {Highcharts.SVGElement} [parent]
  4894. * @return {Highcharts.SVGElement}
  4895. */
  4896. plotGroup: function (prop, name, visibility, zIndex, parent) {
  4897. var group = this[prop], isNew = !group, attrs = {
  4898. visibility: visibility,
  4899. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  4900. };
  4901. // Avoid setting undefined opacity, or in styled mode
  4902. if (typeof this.opacity !== 'undefined' &&
  4903. !this.chart.styledMode) {
  4904. attrs.opacity = this.opacity;
  4905. }
  4906. // Generate it on first call
  4907. if (isNew) {
  4908. this[prop] = group = this.chart.renderer
  4909. .g()
  4910. .add(parent);
  4911. }
  4912. // Add the class names, and replace existing ones as response to
  4913. // Series.update (#6660)
  4914. group.addClass(('highcharts-' + name +
  4915. ' highcharts-series-' + this.index +
  4916. ' highcharts-' + this.type + '-series ' +
  4917. (defined(this.colorIndex) ?
  4918. 'highcharts-color-' + this.colorIndex + ' ' :
  4919. '') +
  4920. (this.options.className || '') +
  4921. (group.hasClass('highcharts-tracker') ?
  4922. ' highcharts-tracker' :
  4923. '')), true);
  4924. // Place it on first and subsequent (redraw) calls
  4925. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  4926. return group;
  4927. },
  4928. /**
  4929. * Get the translation and scale for the plot area of this series.
  4930. *
  4931. * @function Highcharts.Series#getPlotBox
  4932. *
  4933. * @return {Highcharts.SeriesPlotBoxObject}
  4934. */
  4935. getPlotBox: function () {
  4936. var chart = this.chart, xAxis = this.xAxis, yAxis = this.yAxis;
  4937. // Swap axes for inverted (#2339)
  4938. if (chart.inverted) {
  4939. xAxis = yAxis;
  4940. yAxis = this.xAxis;
  4941. }
  4942. return {
  4943. translateX: xAxis ? xAxis.left : chart.plotLeft,
  4944. translateY: yAxis ? yAxis.top : chart.plotTop,
  4945. scaleX: 1,
  4946. scaleY: 1
  4947. };
  4948. },
  4949. /**
  4950. * Removes the event handlers attached previously with addEvents.
  4951. *
  4952. * @private
  4953. * @function Highcharts.Series#removeEvents
  4954. * @param {boolean} [keepEventsForUpdate]
  4955. * @return {void}
  4956. */
  4957. removeEvents: function (keepEventsForUpdate) {
  4958. var series = this;
  4959. if (!keepEventsForUpdate) {
  4960. // remove all events
  4961. removeEvent(series);
  4962. }
  4963. else if (series.eventsToUnbind.length) {
  4964. // remove only internal events for proper update
  4965. // #12355 - solves problem with multiple destroy events
  4966. series.eventsToUnbind.forEach(function (unbind) {
  4967. unbind();
  4968. });
  4969. series.eventsToUnbind.length = 0;
  4970. }
  4971. },
  4972. /**
  4973. * Render the graph and markers. Called internally when first rendering
  4974. * and later when redrawing the chart. This function can be extended in
  4975. * plugins, but normally shouldn't be called directly.
  4976. *
  4977. * @function Highcharts.Series#render
  4978. *
  4979. * @return {void}
  4980. *
  4981. * @fires Highcharts.Series#event:afterRender
  4982. */
  4983. render: function () {
  4984. var series = this, chart = series.chart, group, options = series.options,
  4985. // Animation doesn't work in IE8 quirks when the group div is
  4986. // hidden, and looks bad in other oldIE
  4987. animDuration = (!series.finishedAnimating &&
  4988. chart.renderer.isSVG &&
  4989. animObject(options.animation).duration), visibility = series.visible ? 'inherit' : 'hidden', // #2597
  4990. zIndex = options.zIndex, hasRendered = series.hasRendered, chartSeriesGroup = chart.seriesGroup, inverted = chart.inverted;
  4991. fireEvent(this, 'render');
  4992. // the group
  4993. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  4994. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  4995. // initiate the animation
  4996. if (animDuration && series.animate) {
  4997. series.animate(true);
  4998. }
  4999. // SVGRenderer needs to know this before drawing elements (#1089,
  5000. // #1795)
  5001. group.inverted = series.isCartesian || series.invertable ?
  5002. inverted : false;
  5003. // Draw the graph if any
  5004. if (series.drawGraph) {
  5005. series.drawGraph();
  5006. series.applyZones();
  5007. }
  5008. // Draw the points
  5009. if (series.visible) {
  5010. series.drawPoints();
  5011. }
  5012. /* series.points.forEach(function (point) {
  5013. if (point.redraw) {
  5014. point.redraw();
  5015. }
  5016. }); */
  5017. // Draw the data labels
  5018. if (series.drawDataLabels) {
  5019. series.drawDataLabels();
  5020. }
  5021. // In pie charts, slices are added to the DOM, but actual rendering
  5022. // is postponed until labels reserved their space
  5023. if (series.redrawPoints) {
  5024. series.redrawPoints();
  5025. }
  5026. // draw the mouse tracking area
  5027. if (series.drawTracker &&
  5028. series.options.enableMouseTracking !== false) {
  5029. series.drawTracker();
  5030. }
  5031. // Handle inverted series and tracker groups
  5032. series.invertGroups(inverted);
  5033. // Initial clipping, must be defined after inverting groups for VML.
  5034. // Applies to columns etc. (#3839).
  5035. if (options.clip !== false &&
  5036. !series.sharedClipKey &&
  5037. !hasRendered) {
  5038. group.clip(chart.clipRect);
  5039. }
  5040. // Run the animation
  5041. if (animDuration && series.animate) {
  5042. series.animate();
  5043. }
  5044. // Call the afterAnimate function on animation complete (but don't
  5045. // overwrite the animation.complete option which should be available
  5046. // to the user).
  5047. if (!hasRendered) {
  5048. series.animationTimeout = syncTimeout(function () {
  5049. series.afterAnimate();
  5050. }, animDuration || 0);
  5051. }
  5052. // Means data is in accordance with what you see
  5053. series.isDirty = false;
  5054. // (See #322) series.isDirty = series.isDirtyData = false; // means
  5055. // data is in accordance with what you see
  5056. series.hasRendered = true;
  5057. fireEvent(series, 'afterRender');
  5058. },
  5059. /**
  5060. * Redraw the series. This function is called internally from
  5061. * `chart.redraw` and normally shouldn't be called directly.
  5062. *
  5063. * @private
  5064. * @function Highcharts.Series#redraw
  5065. * @return {void}
  5066. */
  5067. redraw: function () {
  5068. var series = this, chart = series.chart,
  5069. // cache it here as it is set to false in render, but used after
  5070. wasDirty = series.isDirty || series.isDirtyData, group = series.group, xAxis = series.xAxis, yAxis = series.yAxis;
  5071. // reposition on resize
  5072. if (group) {
  5073. if (chart.inverted) {
  5074. group.attr({
  5075. width: chart.plotWidth,
  5076. height: chart.plotHeight
  5077. });
  5078. }
  5079. group.animate({
  5080. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  5081. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  5082. });
  5083. }
  5084. series.translate();
  5085. series.render();
  5086. if (wasDirty) { // #3868, #3945
  5087. delete this.kdTree;
  5088. }
  5089. },
  5090. kdAxisArray: ['clientX', 'plotY'],
  5091. /**
  5092. * @private
  5093. * @function Highcharts.Series#searchPoint
  5094. * @param {Highcharts.PointerEventObject} e
  5095. * @param {boolean} [compareX]
  5096. * @return {Highcharts.Point}
  5097. */
  5098. searchPoint: function (e, compareX) {
  5099. var series = this, xAxis = series.xAxis, yAxis = series.yAxis, inverted = series.chart.inverted;
  5100. return this.searchKDTree({
  5101. clientX: inverted ?
  5102. xAxis.len - e.chartY + xAxis.pos :
  5103. e.chartX - xAxis.pos,
  5104. plotY: inverted ?
  5105. yAxis.len - e.chartX + yAxis.pos :
  5106. e.chartY - yAxis.pos
  5107. }, compareX, e);
  5108. },
  5109. /**
  5110. * Build the k-d-tree that is used by mouse and touch interaction to get
  5111. * the closest point. Line-like series typically have a one-dimensional
  5112. * tree where points are searched along the X axis, while scatter-like
  5113. * series typically search in two dimensions, X and Y.
  5114. *
  5115. * @private
  5116. * @function Highcharts.Series#buildKDTree
  5117. * @param {Highcharts.PointerEventObject} [e]
  5118. * @return {void}
  5119. */
  5120. buildKDTree: function (e) {
  5121. // Prevent multiple k-d-trees from being built simultaneously
  5122. // (#6235)
  5123. this.buildingKdTree = true;
  5124. var series = this, dimensions = series.options.findNearestPointBy
  5125. .indexOf('y') > -1 ? 2 : 1;
  5126. /**
  5127. * Internal function
  5128. * @private
  5129. */
  5130. function _kdtree(points, depth, dimensions) {
  5131. var axis, median, length = points && points.length;
  5132. if (length) {
  5133. // alternate between the axis
  5134. axis = series.kdAxisArray[depth % dimensions];
  5135. // sort point array
  5136. points.sort(function (a, b) {
  5137. return a[axis] - b[axis];
  5138. });
  5139. median = Math.floor(length / 2);
  5140. // build and return nod
  5141. return {
  5142. point: points[median],
  5143. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  5144. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  5145. };
  5146. }
  5147. }
  5148. /**
  5149. * Start the recursive build process with a clone of the points
  5150. * array and null points filtered out. (#3873)
  5151. * @private
  5152. */
  5153. function startRecursive() {
  5154. series.kdTree = _kdtree(series.getValidPoints(null,
  5155. // For line-type series restrict to plot area, but
  5156. // column-type series not (#3916, #4511)
  5157. !series.directTouch), dimensions, dimensions);
  5158. series.buildingKdTree = false;
  5159. }
  5160. delete series.kdTree;
  5161. // For testing tooltips, don't build async. Also if touchstart, we
  5162. // may be dealing with click events on mobile, so don't delay
  5163. // (#6817).
  5164. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  5165. },
  5166. /**
  5167. * @private
  5168. * @function Highcharts.Series#searchKDTree
  5169. * @param {Highcharts.KDPointSearchObject} point
  5170. * @param {boolean} [compareX]
  5171. * @param {Highcharts.PointerEventObject} [e]
  5172. * @return {Highcharts.Point|undefined}
  5173. */
  5174. searchKDTree: function (point, compareX, e) {
  5175. var series = this, kdX = this.kdAxisArray[0], kdY = this.kdAxisArray[1], kdComparer = compareX ? 'distX' : 'dist', kdDimensions = series.options.findNearestPointBy
  5176. .indexOf('y') > -1 ? 2 : 1;
  5177. /**
  5178. * Set the one and two dimensional distance on the point object.
  5179. * @private
  5180. */
  5181. function setDistance(p1, p2) {
  5182. var x = (defined(p1[kdX]) &&
  5183. defined(p2[kdX])) ?
  5184. Math.pow(p1[kdX] - p2[kdX], 2) :
  5185. null, y = (defined(p1[kdY]) &&
  5186. defined(p2[kdY])) ?
  5187. Math.pow(p1[kdY] - p2[kdY], 2) :
  5188. null, r = (x || 0) + (y || 0);
  5189. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  5190. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  5191. }
  5192. /**
  5193. * @private
  5194. */
  5195. function _search(search, tree, depth, dimensions) {
  5196. var point = tree.point, axis = series.kdAxisArray[depth % dimensions], tdist, sideA, sideB, ret = point, nPoint1, nPoint2;
  5197. setDistance(search, point);
  5198. // Pick side based on distance to splitting point
  5199. tdist = search[axis] - point[axis];
  5200. sideA = tdist < 0 ? 'left' : 'right';
  5201. sideB = tdist < 0 ? 'right' : 'left';
  5202. // End of tree
  5203. if (tree[sideA]) {
  5204. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  5205. ret = (nPoint1[kdComparer] <
  5206. ret[kdComparer] ?
  5207. nPoint1 :
  5208. point);
  5209. }
  5210. if (tree[sideB]) {
  5211. // compare distance to current best to splitting point to
  5212. // decide wether to check side B or not
  5213. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  5214. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  5215. ret = (nPoint2[kdComparer] <
  5216. ret[kdComparer] ?
  5217. nPoint2 :
  5218. ret);
  5219. }
  5220. }
  5221. return ret;
  5222. }
  5223. if (!this.kdTree && !this.buildingKdTree) {
  5224. this.buildKDTree(e);
  5225. }
  5226. if (this.kdTree) {
  5227. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  5228. }
  5229. },
  5230. /**
  5231. * @private
  5232. * @function Highcharts.Series#pointPlacementToXValue
  5233. * @return {number}
  5234. */
  5235. pointPlacementToXValue: function () {
  5236. var _a = this, _b = _a.options, pointPlacement = _b.pointPlacement, pointRange = _b.pointRange, axis = _a.xAxis;
  5237. var factor = pointPlacement;
  5238. // Point placement is relative to each series pointRange (#5889)
  5239. if (factor === 'between') {
  5240. factor = axis.reversed ? -0.5 : 0.5; // #11955
  5241. }
  5242. return isNumber(factor) ?
  5243. factor * pick(pointRange, axis.pointRange) :
  5244. 0;
  5245. },
  5246. /**
  5247. * @private
  5248. * @function Highcharts.Series#isPointInside
  5249. * @param {Highcharts.Point} point
  5250. * @return {boolean}
  5251. */
  5252. isPointInside: function (point) {
  5253. var isInside = typeof point.plotY !== 'undefined' &&
  5254. typeof point.plotX !== 'undefined' &&
  5255. point.plotY >= 0 &&
  5256. point.plotY <= this.yAxis.len && // #3519
  5257. point.plotX >= 0 &&
  5258. point.plotX <= this.xAxis.len;
  5259. return isInside;
  5260. }
  5261. }); // end Series prototype
  5262. /**
  5263. * A line series displays information as a series of data points connected by
  5264. * straight line segments.
  5265. *
  5266. * @sample {highcharts} highcharts/demo/line-basic/
  5267. * Line chart
  5268. * @sample {highstock} stock/demo/basic-line/
  5269. * Line chart
  5270. *
  5271. * @extends plotOptions.series
  5272. * @product highcharts highstock
  5273. * @apioption plotOptions.line
  5274. */
  5275. /**
  5276. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  5277. * of a line graph. Round means that lines are rounded in the ends and
  5278. * bends.
  5279. *
  5280. * @type {Highcharts.SeriesLinecapValue}
  5281. * @default round
  5282. * @since 3.0.7
  5283. * @apioption plotOptions.line.linecap
  5284. */
  5285. /**
  5286. * A `line` series. If the [type](#series.line.type) option is not
  5287. * specified, it is inherited from [chart.type](#chart.type).
  5288. *
  5289. * @extends series,plotOptions.line
  5290. * @excluding dataParser,dataURL
  5291. * @product highcharts highstock
  5292. * @apioption series.line
  5293. */
  5294. /**
  5295. * An array of data points for the series. For the `line` series type,
  5296. * points can be given in the following ways:
  5297. *
  5298. * 1. An array of numerical values. In this case, the numerical values will be
  5299. * interpreted as `y` options. The `x` values will be automatically
  5300. * calculated, either starting at 0 and incremented by 1, or from
  5301. * `pointStart` and `pointInterval` given in the series options. If the axis
  5302. * has categories, these will be used. Example:
  5303. * ```js
  5304. * data: [0, 5, 3, 5]
  5305. * ```
  5306. *
  5307. * 2. An array of arrays with 2 values. In this case, the values correspond to
  5308. * `x,y`. If the first value is a string, it is applied as the name of the
  5309. * point, and the `x` value is inferred.
  5310. * ```js
  5311. * data: [
  5312. * [0, 1],
  5313. * [1, 2],
  5314. * [2, 8]
  5315. * ]
  5316. * ```
  5317. *
  5318. * 3. An array of objects with named values. The following snippet shows only a
  5319. * few settings, see the complete options set below. If the total number of
  5320. * data points exceeds the series'
  5321. * [turboThreshold](#series.line.turboThreshold),
  5322. * this option is not available.
  5323. * ```js
  5324. * data: [{
  5325. * x: 1,
  5326. * y: 9,
  5327. * name: "Point2",
  5328. * color: "#00FF00"
  5329. * }, {
  5330. * x: 1,
  5331. * y: 6,
  5332. * name: "Point1",
  5333. * color: "#FF00FF"
  5334. * }]
  5335. * ```
  5336. *
  5337. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  5338. * additional declaration to allow custom data types:
  5339. * ```ts
  5340. * declare module `highcharts` {
  5341. * interface PointOptionsObject {
  5342. * custom: Record<string, (boolean|number|string)>;
  5343. * }
  5344. * }
  5345. * ```
  5346. *
  5347. * @sample {highcharts} highcharts/chart/reflow-true/
  5348. * Numerical values
  5349. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  5350. * Arrays of numeric x and y
  5351. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  5352. * Arrays of datetime x and y
  5353. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  5354. * Arrays of point.name and y
  5355. * @sample {highcharts} highcharts/series/data-array-of-objects/
  5356. * Config objects
  5357. *
  5358. * @declare Highcharts.PointOptionsObject
  5359. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  5360. * @apioption series.line.data
  5361. */
  5362. /**
  5363. * An additional, individual class name for the data point's graphic
  5364. * representation.
  5365. *
  5366. * @type {string}
  5367. * @since 5.0.0
  5368. * @product highcharts gantt
  5369. * @apioption series.line.data.className
  5370. */
  5371. /**
  5372. * Individual color for the point. By default the color is pulled from
  5373. * the global `colors` array.
  5374. *
  5375. * In styled mode, the `color` option doesn't take effect. Instead, use
  5376. * `colorIndex`.
  5377. *
  5378. * @sample {highcharts} highcharts/point/color/
  5379. * Mark the highest point
  5380. *
  5381. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5382. * @product highcharts highstock gantt
  5383. * @apioption series.line.data.color
  5384. */
  5385. /**
  5386. * A specific color index to use for the point, so its graphic representations
  5387. * are given the class name `highcharts-color-{n}`. In styled mode this will
  5388. * change the color of the graphic. In non-styled mode, the color by is set by
  5389. * the `fill` attribute, so the change in class name won't have a visual effect
  5390. * by default.
  5391. *
  5392. * @type {number}
  5393. * @since 5.0.0
  5394. * @product highcharts gantt
  5395. * @apioption series.line.data.colorIndex
  5396. */
  5397. /**
  5398. * A reserved subspace to store options and values for customized functionality.
  5399. * Here you can add additional data for your own event callbacks and formatter
  5400. * callbacks.
  5401. *
  5402. * @sample {highcharts} highcharts/point/custom/
  5403. * Point and series with custom data
  5404. *
  5405. * @type {Highcharts.Dictionary<*>}
  5406. * @apioption series.line.data.custom
  5407. */
  5408. /**
  5409. * Individual data label for each point. The options are the same as
  5410. * the ones for [plotOptions.series.dataLabels](
  5411. * #plotOptions.series.dataLabels).
  5412. *
  5413. * @sample highcharts/point/datalabels/
  5414. * Show a label for the last value
  5415. *
  5416. * @declare Highcharts.DataLabelsOptions
  5417. * @extends plotOptions.line.dataLabels
  5418. * @product highcharts highstock gantt
  5419. * @apioption series.line.data.dataLabels
  5420. */
  5421. /**
  5422. * A description of the point to add to the screen reader information
  5423. * about the point.
  5424. *
  5425. * @type {string}
  5426. * @since 5.0.0
  5427. * @requires modules/accessibility
  5428. * @apioption series.line.data.description
  5429. */
  5430. /**
  5431. * An id for the point. This can be used after render time to get a
  5432. * pointer to the point object through `chart.get()`.
  5433. *
  5434. * @sample {highcharts} highcharts/point/id/
  5435. * Remove an id'd point
  5436. *
  5437. * @type {string}
  5438. * @since 1.2.0
  5439. * @product highcharts highstock gantt
  5440. * @apioption series.line.data.id
  5441. */
  5442. /**
  5443. * The rank for this point's data label in case of collision. If two
  5444. * data labels are about to overlap, only the one with the highest `labelrank`
  5445. * will be drawn.
  5446. *
  5447. * @type {number}
  5448. * @apioption series.line.data.labelrank
  5449. */
  5450. /**
  5451. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  5452. *
  5453. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  5454. *
  5455. * @sample {highcharts} highcharts/series/data-array-of-objects/
  5456. * Point names
  5457. *
  5458. * @type {string}
  5459. * @apioption series.line.data.name
  5460. */
  5461. /**
  5462. * Whether the data point is selected initially.
  5463. *
  5464. * @type {boolean}
  5465. * @default false
  5466. * @product highcharts highstock gantt
  5467. * @apioption series.line.data.selected
  5468. */
  5469. /**
  5470. * The x value of the point. For datetime axes, the X value is the timestamp
  5471. * in milliseconds since 1970.
  5472. *
  5473. * @type {number}
  5474. * @product highcharts highstock
  5475. * @apioption series.line.data.x
  5476. */
  5477. /**
  5478. * The y value of the point.
  5479. *
  5480. * @type {number|null}
  5481. * @product highcharts highstock
  5482. * @apioption series.line.data.y
  5483. */
  5484. /**
  5485. * The individual point events.
  5486. *
  5487. * @extends plotOptions.series.point.events
  5488. * @product highcharts highstock gantt
  5489. * @apioption series.line.data.events
  5490. */
  5491. /**
  5492. * Options for the point markers of line-like series.
  5493. *
  5494. * @declare Highcharts.PointMarkerOptionsObject
  5495. * @extends plotOptions.series.marker
  5496. * @product highcharts highstock
  5497. * @apioption series.line.data.marker
  5498. */
  5499. ''; // include precedent doclets in transpilat