# interpolateX

Import from `@pibbl/core/viz`. Creates a query for an exact observation or a data-space estimate at x.

`interpolateX({series,x,xScale,yScale,interpolation,maxGap?,duplicateX?})` returns a function for HoverData. Source x must be nondecreasing; missing/undefined rows break segments. Duplicates error unless explicitly resolved with first/last. There is no extrapolation or gap bridging; maxGap limits bracketing intervals in domain units. Results distinguish exact original observations from interpolated values with before/after source records, indices, fraction, and mapped anchor.

## API details from source

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

### interpolateX

Samples sorted recorded observations without bridging explicit data gaps.

```ts
interpolateX: <D>(options: InterpolateXOptions<D>) => HoverQuery<HoverSample<D>>
```

Related API: [interpolateX](/reference/functions/interpolate-x/), [InterpolateXOptions](/reference/functions/interpolate-x/), [HoverQuery](/reference/components/hover-data/), [HoverSample](/reference/functions/interpolate-x/).

#### Parameters

- **`options`** — Series, horizontal sampling, and interpolation policy. See
[InterpolateXOptions](/reference/functions/interpolate-x/) .

#### Returns

A query producing an interpolated sample, or undefined when sampling is unavailable.
See [HoverQuery](/reference/components/hover-data/) , [HoverSample](/reference/functions/interpolate-x/) .

#### See also

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

[HoverQuery](/reference/components/hover-data/)

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

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

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

### InterpolateXOptions

Interpolation, gap, and duplicate-x policies for sampling a series at a requested x.

```ts
interface InterpolateXOptions<D> extends Omit<ClosestXOptions<D>, "maxDelta">
```

Related API: [InterpolateXOptions](/reference/functions/interpolate-x/), [ClosestXOptions](/reference/functions/closest-x/).

#### See also

[ClosestXOptions](/reference/functions/closest-x/)

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

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

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

#### Properties and methods

<span id="api-InterpolateXOptions-interpolation"></span>
<details>
<summary>interpolation</summary>


```ts
readonly interpolation: HoverInterpolation
```

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

Computes y between the neighboring samples at the requested fraction. See HoverInterpolation.

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

</details>

<span id="api-InterpolateXOptions-maxGap"></span>
<details>
<summary>maxGap (optional)</summary>


```ts
readonly maxGap?: number | undefined
```

Maximum gap between neighboring samples that permits interpolation. See
InterpolateXOptions.

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

</details>

<span id="api-InterpolateXOptions-duplicateX"></span>
<details>
<summary>duplicateX (optional)</summary>


```ts
readonly duplicateX?: "error" | "first" | "last" | undefined
```

Policy for resolving samples with the same x coordinate. See InterpolateXOptions.

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

</details>

<span id="api-InterpolateXOptions-series"></span>
<details>
<summary>series</summary>


```ts
readonly series: HoverSeries<D>
```

Related API: [HoverSeries](/reference/functions/define-series/).

The named series or series collection participating in the query. See HoverSeries.

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

</details>

<span id="api-InterpolateXOptions-x"></span>
<details>
<summary>x</summary>


```ts
readonly x: SignalValue<number | null>
```

Related API: [SignalValue](/reference/types/signal-inputs/#signalvalue).

Horizontal coordinate or displacement in the containing coordinate system. See
SignalValue.

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

</details>

<span id="api-InterpolateXOptions-xScale"></span>
<details>
<summary>xScale</summary>


```ts
readonly xScale: ScaleId
```

Related API: [ScaleId](/reference/components/scale/).

The scale used to map horizontal data coordinates. See ScaleId.

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

</details>

<span id="api-InterpolateXOptions-yScale"></span>
<details>
<summary>yScale</summary>


```ts
readonly yScale: ScaleId
```

Related API: [ScaleId](/reference/components/scale/).

The scale used to map vertical data coordinates. See ScaleId.

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

</details>

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

### HoverSample

An exact datum hit or an interpolated value with its neighboring data and anchor.

<details>
<summary>Full type declaration</summary>

```ts
type HoverSample<D> = | (HoverHit<D> & {
      /** Selects the kind of geometry, material, or result. See {@link HoverSample}. */
      readonly kind: "exact";
    })
  | {
      /** Selects the kind of geometry, material, or result. See {@link HoverSample}. */
      readonly kind: "interpolated";
      /**
       * Horizontal coordinate or displacement in the containing coordinate system. See
       * {@link HoverSample}.
       */
      readonly x: number;
      /**
       * Vertical coordinate or displacement in the containing coordinate system. See
       * {@link HoverSample}.
       */
      readonly y: number;
      /** Source datum preceding the interpolated x coordinate. See {@link HoverSample}. */
      readonly before: D;
      /** Source datum following the interpolated x coordinate. See {@link HoverSample}. */
      readonly after: D;
      /** Source index of the sample before the interpolated position. See {@link HoverSample}. */
      readonly beforeIndex: number;
      /** Source index of the sample after the interpolated position. See {@link HoverSample}. */
      readonly afterIndex: number;
      /** Normalized share or position represented by this value. See {@link HoverSample}. */
      readonly fraction: number;
      /** Logical point to which the content or result is anchored. See {@link HoverPoint}. */
      readonly anchor: HoverPoint;
    }
```

</details>

Related API: [HoverSample](/reference/functions/interpolate-x/), [HoverHit](/reference/functions/closest-point/), [displacement](/reference/types/filters/#displacement), [HoverPoint](/reference/functions/closest-point/).

#### See also

[HoverHit](/reference/functions/closest-point/)

[HoverPoint](/reference/functions/closest-point/)

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

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

#### Properties and methods

<span id="api-HoverSample-kind"></span>
<details>
<summary>kind</summary>


```ts
readonly kind: "exact" | "interpolated"
```

Selects the kind of geometry, material, or result. See HoverSample.

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

</details>

<span id="api-HoverSample-x"></span>
<details>
<summary>x</summary>


```ts
readonly x: number
```

Horizontal coordinate or displacement in the containing coordinate system. See
HoverSample.
Horizontal coordinate or displacement in the containing coordinate system. See
HoverHit.

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

</details>

<span id="api-HoverSample-y"></span>
<details>
<summary>y</summary>


```ts
readonly y: number
```

Vertical coordinate or displacement in the containing coordinate system. See
HoverSample.
Vertical coordinate or displacement in the containing coordinate system. See HoverHit
.

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

</details>

<span id="api-HoverSample-anchor"></span>
<details>
<summary>anchor</summary>


```ts
readonly anchor: HoverPoint
```

Related API: [HoverPoint](/reference/functions/closest-point/).

Logical point to which the content or result is anchored. See HoverPoint.

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

</details>

## 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.
