Altair chart inside a (panel) Flexbox with "container" width #3327
Unanswered
bertcoerver
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I'm trying to put some Altair charts inside a flexbox, having the width of the charts adjust to the available space. I'm using Panel to set up the flexbox, like this:
Which gives me flex-items that always fill up the available space on the row and never get smaller than 200px. For example (the white boxes are the Altair charts):
When the viewport is small, every item is on a single row:
![](https://private-user-images.githubusercontent.com/18460767/303285339-285df32f-3719-43bb-8592-6945b3d965ec.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODkwNzMsIm5iZiI6MTczOTU4ODc3MywicGF0aCI6Ii8xODQ2MDc2Ny8zMDMyODUzMzktMjg1ZGYzMmYtMzcxOS00M2JiLTg1OTItNjk0NWIzZDk2NWVjLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDAzMDYxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZkMjc2NmVkNzE5MWY4NzcwNWQyZjQ5Njk1ZWJhYzQ0MDdhMzc4NGFmNDk3OThjYzRiODUxNzM5NWRiYzA2YzQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.jCz0M5pXOrNJ6b_WFNJzxumxkACRAZ3I4DfYqxKHnoA)
As the viewport gets larger multiple items are places on a row:
![](https://private-user-images.githubusercontent.com/18460767/303285969-b460f7dd-409c-4e35-ba5f-8d25aaec4e29.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODkwNzMsIm5iZiI6MTczOTU4ODc3MywicGF0aCI6Ii8xODQ2MDc2Ny8zMDMyODU5NjktYjQ2MGY3ZGQtNDA5Yy00ZTM1LWJhNWYtOGQyNWFhZWM0ZTI5LmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDAzMDYxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBjZDE4MGNlNWMxMmE3NGMzZDgwNTY4YzQ4MGQ0YWViNmRiYTM0Y2QwODVkZTdmYjEwNDcwODg3ZTkyN2MyNDEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.rxN_axKD2BgNWIWr58rsEXmHzaiBiR6tmUOQlWPfcUw)
And even wider:
![3](https://private-user-images.githubusercontent.com/18460767/303286044-a582387b-4125-49be-90e3-2bd580b8d75b.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1ODkwNzMsIm5iZiI6MTczOTU4ODc3MywicGF0aCI6Ii8xODQ2MDc2Ny8zMDMyODYwNDQtYTU4MjM4N2ItNDEyNS00OWJlLTkwZTMtMmJkNTgwYjhkNzViLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE1VDAzMDYxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgwNjI3ODBhYzhmZjljNjFiZTJhZTM0N2M4OGVkZWRiYjJmYmQ3YTkxNzc2ZmZhMTYwNmQ2OGMwMmY2ODdlMGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8uSJmYP0RsbD_0VrglgWPsD_NIaTyaKHZ-LmPPMlxoA)
Now I want the charts to adapt their size to its parent (i.e. the green box). But as soon as I turn on
width = "container"
on the chart, the flexbox behaviour breaks: the flex-items still fill up the width of the viewport, but they never get grouped together on a row anymore (there is always only 1 item per row).Any ideas on how to fix this?
Regards,
Bert
Beta Was this translation helpful? Give feedback.
All reactions