Series.js 212 KB

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