Skip to content

feature: y1 default to 0 for Area #97

Description

@jamesscottbrown

This example gives an error, because y1 is not explicitly set for the Area mark:

<Plot
    height={300}
    marginLeft={60}
    y={{ axis: null }}
    x={{ nice: true }}
    fy={{ domain: ['FEMALE', 'MALE'] }}
    color={{ legend: true }}
    facet={{ data: penguins, y: 'sex' }}>
    <AreaY
        {...binX(
            {
                data: penguins,
                x: 'culmen_length_mm',
                fill: 'species',
                fillOpacity: '.',
                thresholds: '',
                curve: 'natural',
            },
            { y2: 'count' }
        )} />
</Plot>

Whereas it works if y1: 0 is added:

<Plot
    height={300}
    marginLeft={60}
    y={{ axis: null }}
    x={{ nice: true }}
    fy={{ domain: ['FEMALE', 'MALE'] }}
    color={{ legend: true }}
    facet={{ data: penguins, y: 'sex' }}>
    <AreaY
        {...binX(
            {
                data: penguins,
                x: 'culmen_length_mm',
                fill: 'species',
                fillOpacity: '.',
                thresholds: '',
                curve: 'natural',
                y1: 0
            },
            { y2: 'count' }
        )} />
</Plot>

It also works if I specify y rather than y1:

<Plot
    height={300}
    marginLeft={60}
    y={{ axis: null }}
    x={{ nice: true }}
    fy={{ domain: ['FEMALE', 'MALE'] }}
    color={{ legend: true }}
    facet={{ data: penguins, y: 'sex' }}>
    <AreaY
        {...binX(
            {
                data: penguins,
                x: 'culmen_length_mm',
                fill: 'species',
                fillOpacity: '.',
                thresholds: '',
                curve: 'natural',
            },
            { y: 'count' }
        )} />
</Plot>

In Observable Plot, setting just y2 works (as in this example).

(this is one of the issues surfaced by #72)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions