# linearInterpolation

Import from `@pibbl/core/viz`. Returns an ordinary linear interpolation function.

`linearInterpolation()` returns `(beforeY, afterY, fraction) => number`. Pass it as interpolateX's interpolation function or supply your own synchronous function. It estimates in data space before scales map the result. Inputs and output must be finite.

## API details from source

<span id="api-linearInterpolation"></span>

### linearInterpolation

Returns a plain data-space linear interpolation function.

```ts
linearInterpolation: () => HoverInterpolation
```

Related API: [linearInterpolation](/reference/functions/linear-interpolation/), [HoverInterpolation](/reference/functions/linear-interpolation/).

#### Returns

A linear interpolator for values bracketing a sample position. See
[HoverInterpolation](/reference/functions/linear-interpolation/) .

#### See also

[HoverInterpolation](/reference/functions/linear-interpolation/)

[View source — packages/core/src/features/viz/lib/hover-queries.ts:159](/source/packages/core/src/features/viz/lib/hover-queries-ts/#L159)

<span id="api-HoverInterpolation"></span>

### HoverInterpolation

Interpolates between two y values at a normalized position between samples.

```ts
type HoverInterpolation = (
  beforeY: number,
  afterY: number,
  fraction: number,
) => number
```

Related API: [HoverInterpolation](/reference/functions/linear-interpolation/).

#### Parameters

- **`beforeY`** — Vertical value before the sample position.

- **`afterY`** — Vertical value after the sample position.

- **`fraction`** — Fraction of the distance from the before point to the after point.

#### Returns

The interpolated vertical value.

#### See also

[InterpolateXOptions](/reference/functions/interpolate-x/)

[linearInterpolation](/reference/functions/linear-interpolation/)

[View source — packages/core/src/features/viz/lib/hover-types.ts:227](/source/packages/core/src/features/viz/lib/hover-types-ts/#L227)

## Implementation guidance for agents

Read the [Data visualization companion](/agents/topics/visualization/) for ownership, adaptation, failure modes, and verification. [Agent start](/agents/) provides the version-selection workflow.

## Complete minimal examples

- [Hover query helpers](/minimal-examples/viz/hover-queries/): Run closest-point, closest-x, and interpolated-x queries against a scale context. [Plain source](/minimal/viz/hover-queries.ts)
## Documentation version

Documentation built with @pibbl/core 0.0.2, revision 272a94a. ALPHA — NOT FOR PRODUCTION USE.
