question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Responsive sizing on width or weight

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
jakevdpcommented, Oct 17, 2019

The "container" option will be added in Vega-Lite 4.0, which has not yet been released (The Vega-Lite team keeps their docs pinned to unreleased development versions, which leads to a dozen or so questions like this in every release cycle).

Once Vega-Lite 4.0 is released, we will work on releasing Altair 4.0, at which point this feature will be supported.

0reactions
jakevdpcommented, May 10, 2020

In that case, try putting the chart in div with a set width. If the div has no width specified, the browser will set its width based on the content. When the content in turn is setting its width based on the width of its container, the result is not generally ideal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to set weight and height in Css with responsive when ...
Simply define the image as a percent of its parent. Below the image is 40% width of the page and will consequently scale...
Read more >
Screen sizes and breakpoints - Windows apps - Microsoft Learn
This table describes the different size classes and breakpoints. Responsive design breakpoints. Size class, Breakpoints, Typical screen size ...
Read more >
How To Create Responsive Images - W3Schools
Responsive images will automatically adjust to fit the size of the screen. ... on responsiveness, set the CSS width property to 100% and...
Read more >
Mobile Responsive Screen Sizes - AccessAlly
Get the latest mobile responsive screen sizes so you can design mobile friendly web pages and ... The average phone width in pixels...
Read more >
LESSON 8. Responsive Sizing For Different Devices In Divi
In this lesson of our free mini-course on making Divi responsive, we are looking into all the responsive settings in the Design tab...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found