'use strict' ; import type SplinePoint from './SplinePoint' ; import type SplineSeriesOptions from './SplineSeriesOptions' ; import type SVGPath from '../../Core/Renderer/SVG/SVGPath' ; import SeriesRegistry from '../../Core/Series/SeriesRegistry.js' ; const { seriesTypes : { line : LineSeries } } = SeriesRegistry ; import U from '../../Core/Utilities.js' ; const { merge , pick } = U ; private class SplineSeries extends LineSeries { sample sample extends plotOptions . series excluding product optionparent public static defaultOptions : SplineSeriesOptions = merge ( LineSeries . defaultOptions ) ; public data : Array < SplinePoint > = void 0 as any ; public options : SplineSeriesOptions = void 0 as any ; public points : Array < SplinePoint > = void 0 as any ; private function public getPointSpline ( points , point , i ) { let smoothing = 1.5 , denom = smoothing + 1 , plotX = point . plotX || 0 , plotY = point . plotY || 0 , lastPoint = points [ i - 1 ] , nextPoint = points [ i + 1 ] , leftContX , leftContY , rightContX , rightContY , ret ; private function doCurve ( otherPoint ) { return otherPoint && ! otherPoint . isNull && otherPoint . doCurve !== false && ! point . isCliff ; } if ( doCurve ( lastPoint ) && doCurve ( nextPoint ) ) { let lastX = lastPoint . plotX || 0 , lastY = lastPoint . plotY || 0 , nextX = nextPoint . plotX || 0 , nextY = nextPoint . plotY || 0 , correction = 0 ; leftContX = ( smoothing * plotX + lastX ) / denom ; leftContY = ( smoothing * plotY + lastY ) / denom ; rightContX = ( smoothing * plotX + nextX ) / denom ; rightContY = ( smoothing * plotY + nextY ) / denom ; if ( rightContX !== leftContX ) { correction = ( ( ( rightContY - leftContY ) * ( rightContX - plotX ) ) / ( rightContX - leftContX ) + plotY - rightContY ) ; } leftContY += correction ; rightContY += correction ; if ( leftContY > lastY && leftContY > plotY ) { leftContY = Math . max ( lastY , plotY ) ; rightContY = 2 * plotY - leftContY ; } else if ( leftContY < lastY && leftContY < plotY ) { leftContY = Math . min ( lastY , plotY ) ; rightContY = 2 * plotY - leftContY ; } if ( rightContY > nextY && rightContY > plotY ) { rightContY = Math . max ( nextY , plotY ) ; leftContY = 2 * plotY - rightContY ; } else if ( rightContY < nextY && rightContY < plotY ) { rightContY = Math . min ( nextY , plotY ) ; leftContY = 2 * plotY - rightContY ; } point . rightContX = rightContX ; point . rightContY = rightContY ; } ret = [ 'C' , pick ( lastPoint . rightContX , lastPoint . plotX , 0 ) , pick ( lastPoint . rightContY , lastPoint . plotY , 0 ) , pick ( leftContX , plotX , 0 ) , pick ( leftContY , plotY , 0 ) , plotX , plotY ] ; lastPoint . rightContX = lastPoint . rightContY = void 0 ; return ret ; } } interface SplineSeries { pointClass : typeof SplinePoint ; } declare module '../../Core/Series/SeriesType' { interface SeriesTypeRegistry { spline : typeof SplineSeries ; } } SeriesRegistry . registerSeriesType ( 'spline' , SplineSeries ) ; export default SplineSeries ; extends series excluding product apioption sample sample sample sample sample type { Array < number | Array < ( number | string ) , ( number | null ) > | null | * > } extends series . line . data product apioption '' ;