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.

Width of Altair vconcat chart not correct

See original GitHub issue

Summary

I am trying to implement multiple concatenated charts with same x-axis to share a selection functionality. When adding them to streamlit one at a time, the width seems to adjust to the container automatically, but something goes wrong when adding the concatenated charts.

Steps to reproduce

Code snippet:

import pandas as pd
import numpy as np
import altair as alt
import streamlit as st

st.set_page_config( layout='wide')

x = np.linspace(10,100, 10)
y1 = 5*x
y2 = 1/x

df1 = pd.DataFrame.from_dict({'x': x,'y1': y1, 'y2': y2})

c1 = alt.Chart(df1).mark_line(
).encode(
    alt.X('x'),
    alt.Y('y1')
)

c2 = alt.Chart(df1).mark_line(
).encode(
    alt.X('x'),
    alt.Y('y2')
)

#Individual, Static Charts
st.altair_chart(c1, use_container_width = True)
st.altair_chart(c2, use_container_width = True)

#Concatenated Charts with shared zoom function
zoom = alt.selection_interval(bind = 'scales', encodings = ['x'])
st.altair_chart(c1.add_selection(zoom) & c2.add_selection(zoom), use_container_width = True)

Expected behavior:

Concatenated charts of full width with zoom functionality.

Actual behavior:

Concatenated charts of standard width with zoom functionality

Is this a regression?

No.

Debug info

  • Streamlit version: 0.76.0
  • Python version: 3.8.5
  • Using PipEnv
  • OS version: macOS Mojave
  • Browser version: Chrome

Additional information

Skærmbillede 2021-02-07 kl  04 48 58

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:8

github_iconTop GitHub Comments

5reactions
quantoidcommented, Jul 22, 2021

Hi, any update on this, like a target release date?

2reactions
StefanRingercommented, Apr 24, 2022

Would also be happy about a fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compound Charts: Layer, HConcat, VConcat, Repeat, Facet
Along with the basic Chart object, Altair provides a number of compound plot ... width=200, height=200 ).interactive() chart = alt.vconcat(data=iris) for ...
Read more >
How should I use use_container_width with vconcat-ed charts?
But with altair charts, width of vconcat-ed charts is not handled well. I'm using streamlit 0.71.0, and just upgraded to 0.72.0.
Read more >
Is there a way to customize the placement of concatenated ...
import altair as alt from vega_datasets import data source ... Chart(source, height=200, width=200).mark_circle(size=60).encode( ...
Read more >
altair.ConcatChart — Altair 4.1.0 documentation
A chart with horizontally-concatenated facets Mapping(required=[concat]). Attributes ... the general (wrappable) concat operator (not hconcat / vconcat ).
Read more >
altair line up concatenated charts into a grid - You.com
I have this so far but this is not working : ... brush.ref() ).properties( width=700, height=300, selection=click ) con = alt.vconcat(stopline, secondline, ...
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