Skip to content

A transform to consolidate ordinal values outside the top n into an “other” category, perhaps in conjunction with the group transform. #144

Open
@mbostock

Description

@mbostock

e.g., https://next.observablehq.com/d/0e0c0dcb66d6714e

function other(valueof, domain, unknown) {
  if (typeof valueof !== "function") valueof = field(valueof);
  domain = new Set(domain);
  return (d, i, data) => {
    const value = valueof(d, i, data);
    return domain.has(value) ? value : unknown;
  };
}

function field(x) {
  return d => d[x];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions