Skip to content

Weighted group? #241

@mbostock

Description

@mbostock

Currently the groupY transform populates the x channel as the frequency of observations in each group, optionally normalized. But sometimes each observation has a different weight, and you want to sum the weights to compute the x value. That can be done outside of the group transform, like so:

Plot.barX(data, {...Plot.groupY({y: "name"}), x: d => d3.sum(d, d => d.weight)})

but it would be nice if there were a way to do this directly in the group transform, say by passing a x channel into the group transform, where the default x channel definition is unity (one).

Plot.barX(data, Plot.groupY({y: "name", x: "weight"}))

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