Series.js 216 KB

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