Skip to content

How to aggregate other channels when grouping? #265

Closed
@mbostock

Description

@mbostock

This works, the definition of the text channel is awkward:

untitled-46

Plot.plot({
  marks: [
    Plot.barX(penguins, Plot.stackX(Plot.groupZX({fill: "species", normalize: true}))),
    Plot.text(penguins, Plot.stackXMid(Plot.groupZX({text: ([d]) => d.species, z: "species", normalize: true}))),
    Plot.ruleX([0, 100])
  ]
})

I’d prefer something like this:

Plot.plot({
  marks: [
    Plot.barX(penguins, Plot.stackX(Plot.groupZX({fill: "species", normalize: true}))),
    Plot.text(penguins, Plot.stackXMid(Plot.groupZX({text: "species", z: "species", normalize: true}))),
    Plot.ruleX([0, 100])
  ]
})

But this would require that the group transform know that text is a channel, and to aggregate it (by selecting the first value, presumably). And currently the group transform doesn’t need to know how to interpret the passed-in options, other than the ones that are specifically eligible for grouping (namely x, y, z, fill, stroke).

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions