import { line } from 'd3-shape' ; import { Color } from '../../../common/colors' ; import { Scale } from '../../../scales' ; import { CurveType , getCurveFactory } from '../../../utils/curves' ; import { Dimensions } from '../../../utils/dimensions' ; import { LineGeometry } from '../../../utils/geometry' ; import { LineSeriesStyle } from '../../../utils/themes/theme' ; import { IndexedGeometryMap } from '../utils/indexed_geometry_map' ; import { DataSeries , DataSeriesDatum } from '../utils/series' ; import { PointStyleAccessor } from '../utils/specs' ; import { renderPoints } from './points' ; import { getClippedRanges , getY1ScaledValueFn , getYDatumValueFn , isYValueDefinedFn , MarkSizeOptions } from './utils' ; internal export function renderLine ( shift , dataSeries , xScale , yScale , panel , color , curve , hasY0Accessors , xScaleOffset , seriesStyle , markSizeOptions , hasFit , pointStyleAccessor ? ) { const y1Fn = getY1ScaledValueFn ( yScale ) ; const definedFn = isYValueDefinedFn ( yScale , xScale ) ; const y1Accessor = getYDatumValueFn ( ) ; const pathGenerator = line < DataSeriesDatum > ( ) . x ( ( { x } ) => xScale . scale ( x ) - xScaleOffset ) . y ( y1Fn ) . defined ( ( datum ) => definedFn ( datum , y1Accessor ) ) . curve ( getCurveFactory ( curve ) ) ; const { pointGeometries , indexedGeometryMap } = renderPoints ( shift - xScaleOffset , dataSeries , xScale , yScale , panel , color , seriesStyle . point , hasY0Accessors , markSizeOptions , false , pointStyleAccessor ) ; const clippedRanges = getClippedRanges ( dataSeries . data , xScale , xScaleOffset ) ; const lineGeometry = { line : pathGenerator ( dataSeries . data ) || '' , points : pointGeometries , color , transform : { x : shift , y : 0 , } , seriesIdentifier : { key : dataSeries . key , specId : dataSeries . specId , yAccessor : dataSeries . yAccessor , splitAccessors : dataSeries . splitAccessors , seriesKeys : dataSeries . seriesKeys , smHorizontalAccessorValue : dataSeries . smHorizontalAccessorValue , smVerticalAccessorValue : dataSeries . smVerticalAccessorValue , } , style : seriesStyle , clippedRanges , shouldClip : hasFit , } ; return { lineGeometry , indexedGeometryMap , } ; }