Skip to content

Responsive sizing on width or weight #1734

@romainmartinez

Description

@romainmartinez

To enable responsive sizing on width or weight, vega-lite allow the "container" option.

However, Altair throws an error:

source = pd.DataFrame(
    {
        "a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
        "b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
    }
)
chart = (
    alt.Chart(source, width="container", height=120)
    .mark_bar()
    .encode(x="a", y="b")
    .to_json()
)

'container' is not of type 'number'.

Is there a way to allow responsive size in Altair?

As a side note, I use altair with vega-embed to display vega-lite plot on a Flask app.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions