# All files / utils getLineHoverPoints.ts

25% Statements 2/8
0% Branches 0/2
0% Functions 0/2
28.57% Lines 2/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29

    1x

    1x

     import {LineLayerSpec, LinePosition, Scale} from '../types'

    import {FILL} from '../constants/columnKeys'

    export const getLineHoverPoints = (
      position: LinePosition,
      spec: LineLayerSpec,
      hoverRowIndices: number[],
      xColKey: string,
      yColKey: string,
      xScale: Scale<number, number>,
      yScale: Scale<number, number>,
      fillScale: Scale<number, string>
    ): Array<{x: number; y: number; fill: string}> => {
      const {table} = spec
      const xColData = table.getColumn(xColKey, 'number')
      const yColData =
        position === 'stacked'
          ? spec.stackedDomainValueColumn
          : table.getColumn(yColKey, 'number')
      const groupColData = table.getColumn(FILL, 'number')

      return hoverRowIndices.map(i => ({
        x: xScale(xColData[i]),
        y: yScale(yColData[i]),
        fill: fillScale(groupColData[i]),
      }))
    }