Skip to content

Deviation normalization renders missing values as zeros for constant series #2482

Open

Description

@peterolkhov

normalizeY("deviation") converts missing values into valid zeros when the non-missing series is constant. This creates extra observations in the rendered chart.

Reproduced in native Chromium from source at 2245188895e95ef2043f0ad12c2f900d6e48ef1a (package version 0.6.19):

const data = [2, 2, NaN];
const chart = Plot.plot({
  marks: [
    Plot.dot(data, Plot.normalizeY("deviation", {
      x: (_, i) => i,
      y: (d) => d
    }))
  ]
});
document.body.append(chart);
console.log(chart.querySelectorAll("circle").length); // 3, expected 2

The two valid constant values should normalize to zero; the missing value should remain missing. Replacing NaN with undefined also produces three dots. With [NaN, undefined, null], the chart renders two observations instead of none.

Passing controls: [2, 2, null] and [2, 4, NaN] each render two dots, and [2, 2, 2] correctly renders three.

In normalizeDeviation, the S[i] === null guard preserves null but not NaN/undefined. When deviation is zero or undefined, those values reach the fallback 0 instead of staying missing. I checked the related open #487 and #2155; they address broader nonnumeric validation and BigInt normalization, while this case involves numeric series with missing values.

No source changes yet; reporting first under the contribution guidelines.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions