# All files / components/geo/processing toolTips.ts

8.33% Statements 2/24
0% Branches 0/12
0% Functions 0/5
10.53% Lines 2/19

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

    1x

    1x

     // Types
    import {Axis} from '../../../types/geo'

    export const formatValue = (
      key: string,
      defaultLabel: string,
      value: number,
      dimension: Axis = {}
    ) => {
      const {prefix = '', suffix = ''} = dimension
      const formattedValue = `${prefix}${value}${suffix}`
      if (value !== undefined && value !== null) {
        return {
          key: key,
          name: defaultLabel,
          type: 'string',
          values: [formattedValue],
        }
      }
    }

    export const defineToolTipEffect = (markerRefs, setToolTip) => {
      return () => {
        for (let i = 0; i < markerRefs.length; i++) {
          const {markerRef, rowInfo} = markerRefs[i]
          const marker = markerRef.current.leafletElement
          let mouseEntered = false
          marker.on('mouseover', () => {
            if (!mouseEntered) {
              setToolTip(rowInfo)
              mouseEntered = true
            }
          })
          marker.on('mouseout', () => {
            mouseEntered = false
            setToolTip(null)
          })
        }
      }
    }