# All files / utils getBandHoverPoints.ts

23.08% Statements 3/13
0% Branches 0/6
0% Functions 0/2
23.08% Lines 3/13

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
    30
    31
    32
    1x
    1x

    1x

     import {LineData, Scale, Table} from '../types'
    import {FILL} from '../constants/columnKeys'
    import {isNumber} from '../utils/isNumber'

    export const getBandHoverPoints = (
      table: Table,
      hoverRowIndices: number[],
      xColKey: string,
      yColKey: string,
      xScale: Scale<number, number>,
      yScale: Scale<number, number>,
      lineData: LineData
    ): Array<{x: number; y: number; fill: string}> => {
      const xColData = table.getColumn(xColKey, 'number')
      const yColData = table.getColumn(yColKey, 'number')
      const groupColData = table.getColumn(FILL, 'number')
      const lines = lineData || {}

      return hoverRowIndices.map(hoverIndex => {
        let color = ''
        const lineIndex = groupColData[hoverIndex]
        if (isNumber(lineIndex) && lines[lineIndex]) {
          color = lines[lineIndex].fill
        }
        return {
          x: xScale(xColData[hoverIndex]),
          y: yScale(yColData[hoverIndex]),
          fill: color,
        }
      })
    }