# All files / utils drawLineHoverData.ts

2.94% Statements 1/34
0% Branches 0/3
0% Functions 0/1
3.57% Lines 1/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

     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

      Iif (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()
      }

      Iif (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()
        }
      }
    }