'use strict' ; import type LinePoint from './LinePoint' ; import type LineSeriesOptions from './LineSeriesOptions' ; import type SplineSeries from '../Spline/SplineSeries' ; import type SplinePoint from '../Spline/SplinePoint' ; import type SVGAttributes from '../../Core/Renderer/SVG/SVGAttributes' ; import type SVGPath from '../../Core/Renderer/SVG/SVGPath' ; import { Palette } from '../../Core/Color/Palettes.js' ; import Series from '../../Core/Series/Series.js' ; import SeriesRegistry from '../../Core/Series/SeriesRegistry.js' ; import U from '../../Core/Utilities.js' ; const { defined , merge } = U ; private class LineSeries extends Series { optionparent public static defaultOptions : LineSeriesOptions = merge ( Series . defaultOptions , { } as LineSeriesOptions ) ; public data : Array < LinePoint > = void 0 as any ; public options : LineSeriesOptions = void 0 as any ; public points : Array < LinePoint > = void 0 as any ; function public drawGraph ( ) { const series = this , options = this . options , graphPath = ( this . gappedPath || this . getGraphPath ) . call ( this ) , styledMode = this . chart . styledMode ; let props = [ [ 'graph' , 'highcharts-graph' ] ] ; if ( ! styledMode ) { props [ 0 ] . push ( ( options . lineColor || this . color || Palette . neutralColor20 ) as any , options . dashStyle as any ) ; } props = series . getZonesGraphs ( props ) ; props . forEach ( function ( prop , i ) : void { const graphKey = prop [ 0 ] ; let attribs , graph = ( series as any ) [ graphKey ] ; const verb = graph ? 'animate' : 'attr' ; if ( graph ) { graph . endX = series . preventGraphAnimation ? null : graphPath . xMap ; graph . animate ( { d : graphPath } ) ; } else if ( graphPath . length ) { name type { Highcharts . SVGElement | undefined } name type { Highcharts . SVGElement | undefined } ( series as any ) [ graphKey ] = graph = series . chart . renderer . path ( graphPath ) . addClass ( prop [ 1 ] ) . attr ( { zIndex : 1 } ) . add ( series . group ) ; } if ( graph && ! styledMode ) { attribs = { 'stroke' : prop [ 2 ] , 'stroke-width' : options . lineWidth , 'fill' : ( series . fillGraph && series . color ) || 'none' } ; if ( prop [ 3 ] ) { attribs . dashstyle = prop [ 3 ] as any ; } else if ( options . linecap !== 'square' ) { attribs [ 'stroke-linecap' ] = attribs [ 'stroke-linejoin' ] = 'round' ; } graph [ verb ] ( attribs ) . shadow ( ( i < 2 ) && options . shadow ) ; } if ( graph ) { graph . startX = graphPath . xMap ; graph . isArea = graphPath . isArea ; } } ) ; } private public getGraphPath ( points ? , nullsAsZeroes ? , connectCliffs ? ) { const series = this , options = series . options , graphPath = [ ] as SVGPath , xMap = [ ] as Array < ( number | null ) > ; let gap , step = options . step as any ; points = points || series . points ; const reversed = ( points as any ) . reversed ; if ( reversed ) { points . reverse ( ) ; } step = ( { right : 1 , center : 2 } as Record < string , number > ) [ step as any ] || ( step && 3 ) ; if ( step && reversed ) { step = 4 - step ; } points = this . getValidPoints ( points , false , ! ( options . connectNulls && ! nullsAsZeroes && ! connectCliffs ) ) as Array < LinePoint > ; points . forEach ( function ( point , i ) : void { const plotX = point . plotX , plotY = point . plotY , lastPoint = ( points as any ) [ i - 1 ] ; let pathToPoint ; if ( ( point . leftCliff || ( lastPoint && lastPoint . rightCliff ) ) && ! connectCliffs ) { gap = true ; } if ( point . isNull && ! defined ( nullsAsZeroes ) && i > 0 ) { gap = ! options . connectNulls ; } else if ( point . isNull && ! nullsAsZeroes ) { gap = true ; } else { if ( i === 0 || gap ) { pathToPoint = [ [ 'M' , point . plotX as any , point . plotY as any ] ] ; } else if ( ( series as unknown as Partial < SplineSeries > ) . getPointSpline ) { pathToPoint = [ ( series as unknown as SplineSeries ) . getPointSpline ( points as Array < SplinePoint > , point as SplinePoint , i ) ] ; } else if ( step ) { if ( step === 1 ) { pathToPoint = [ [ 'L' , lastPoint . plotX as any , plotY as any ] ] ; } else if ( step === 2 ) { pathToPoint = [ [ 'L' , ( ( lastPoint . plotX as any ) + plotX ) / 2 , lastPoint . plotY as any ] , [ 'L' , ( ( lastPoint . plotX as any ) + plotX ) / 2 , plotY as any ] ] ; } else { pathToPoint = [ [ 'L' , plotX as any , lastPoint . plotY as any ] ] ; } pathToPoint . push ( [ 'L' , plotX as any , plotY as any ] ) ; } else { pathToPoint = [ [ 'L' , plotX as any , plotY as any ] ] ; } xMap . push ( point . x ) ; if ( step ) { xMap . push ( point . x ) ; if ( step === 2 ) { xMap . push ( point . x ) ; } } graphPath . push . apply ( graphPath , pathToPoint ) ; gap = false ; } } ) ; ( graphPath as any ) . xMap = xMap ; series . graphPath = graphPath ; return graphPath ; } private public getZonesGraphs ( props ) { this . zones . forEach ( function ( zone , i ) : void { const propset = [ 'zone-graph-' + i , 'highcharts-graph highcharts-zone-graph-' + i + ' ' + ( zone . className || '' ) ] ; if ( ! this . chart . styledMode ) { propset . push ( ( zone . color || this . color ) as any , ( zone . dashStyle || this . options . dashStyle ) as any ) ; } props . push ( propset ) ; } , this ) ; return props ; } } interface LineSeries { pointClass : typeof LinePoint ; } declare module '../../Core/Series/SeriesType' { interface SeriesTypeRegistry { line : typeof LineSeries ; } } SeriesRegistry . registerSeriesType ( 'line' , LineSeries ) ; export default LineSeries ; sample sample extends plotOptions . series product apioption type { Highcharts . SeriesLinecapValue } default since apioption extends series excluding product apioption sample sample sample sample sample declare type { Array < number | Array < ( number | string ) , ( number | null ) > | null | * > } apioption type { string } since product apioption sample type { Highcharts . ColorString | Highcharts . GradientColorObject | Highcharts . PatternObject } product apioption type { number } since product apioption sample type { Highcharts . Dictionary < * > } apioption sample declare extends plotOptions . line . dataLabels product apioption type { string } since requires apioption sample type { string } since product apioption type { number } apioption see sample type { string } apioption type { boolean } default product apioption type { number } product apioption type { number | null } product apioption extends plotOptions . series . point . events product apioption declare extends plotOptions . series . marker product apioption '' ;