import { ScaleType } from '../../../scales/constants' ; import { getSpecsById } from '../state/utils/spec' ; import { fitFunction } from './fit_function' ; import { DataSeries } from './series' ; import { isAreaSeriesSpec , isLineSeriesSpec , SeriesSpecs , BasicSeriesSpec } from './specs' ; internal export const applyFitFunctionToDataSeries = ( dataSeries , seriesSpecs , xScaleType ) : DataSeries [ ] => { return dataSeries . map ( ( { specId , data , ... rest } ) => { const spec = getSpecsById < BasicSeriesSpec > ( seriesSpecs , specId ) ; if ( spec !== null && spec !== undefined && ( isAreaSeriesSpec ( spec ) || isLineSeriesSpec ( spec ) ) && spec . fit !== undefined ) { const fittedData = fitFunction ( data , spec . fit , xScaleType ) ; return { specId , ... rest , data : fittedData , } ; } return { specId , data , ... rest } ; } ) ; } ;