Series.js 208 KB

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