Skip to content

Reduce for line/area values? #724

Closed
@Fil

Description

@Fil

In lines and areas, the stroke, fill, fillOpacity, strokeOpacity, strokeWidth, title, and ariaLabel channels are reduced to the first element of the series in

export function applyGroupedChannelStyles(selection, {target}, {ariaLabel: AL, title: T, fill: F, fillOpacity: FO, stroke: S, strokeOpacity: SO, strokeWidth: SW, opacity: O, href: H}) {

It would be interesting to be allowed to customize this reducer, in particular for title and ariaLabel, where we might want to display something like "10 data points with a mean of 3.3".

But this requires a structural change, because at present the scales are applied before the call to mark.render, and the grouping is done in render.

A solution could be to make any mark that needs grouping request that grouping (by z and by facet), by adding a "group: true" option for the mark, a grouper: true option for the grouping channel (z), and a grouped: true option on the channels which must be reduced (currently all defined in style.js). Then we could imagine that a line mark would be defined as

Plot.line(data, {x, y, z, ariaLabel: { value: "name", reduce: "mode" }})

or

Plot.line(data, {x, y, z, ariaLabel: { value: "name", reduce: series => some stats about the series }})

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