# All files / utils drawLineHoverData.ts

85.29% Statements 29/34
66.66% Branches 2/3
100% Functions 1/1
82.14% Lines 23/28

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
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49

    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x

    1x

    1x
    1x
    1x
    1x
    1x
    1x

    1x

    1x
    1x
    1x
    1x
    1x
    1x

     interface DrawLinePointOptions {
      context: CanvasRenderingContext2D
      width: number
      height: number
      crosshairX: number | null
      crosshairY: number | null
      crosshairColor: string
      points: Array<{x: number; y: number; fill: string}> | null
      radius: number
    }

    export const drawLineHoverData = ({
      context,
      width,
      height,
      crosshairX,
      crosshairY,
      crosshairColor,
      points,
      radius,
    }: DrawLinePointOptions): void => {
      context.strokeStyle = crosshairColor

      if (crosshairX !== null) {
        context.lineWidth = 1
        context.beginPath()
        context.moveTo(crosshairX, 0)
        context.lineTo(crosshairX, height)
        context.stroke()
      }

      Iif (crosshairY !== null) {
        context.lineWidth = 1
        context.beginPath()
        context.moveTo(0, crosshairY)
        context.lineTo(width, crosshairY)
        context.stroke()
      }

      if (points !== null) {
        for (const {x, y, fill} of points) {
          context.beginPath()
          context.arc(x, y, radius, 0, 2 * Math.PI)
          context.fillStyle = fill
          context.fill()
        }
      }
    }