-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make charts responsive #145
Comments
To support parent container resize detector you can't do it with vega-spec. As you said in the previous link explain how to adjust size to window size but not to the container size. |
I'm not following.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 400,
"height": 200,
"padding": 5,
"signals": [
{
"name": "size",
"update": "containerSize()",
"on": [
{
"events": {
"source": "window",
"type": "resize"
},
"update": "containerSize()"
}
]
}
],
"marks": [
{
"type": "text",
"encode": {
"enter": {
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "black"}
},
"update": {
"x": {"signal": "width", "mult": 0.5},
"y": {"signal": "height", "mult": 0.5},
"text": {"signal": "'size: ' + size"}
}
}
}
]
} Having said that, a better option may be to just use the autosize feature with |
What's about that? vega/vega#755 (comment) |
I tried before without any kind of javascript code using only containerSize as described in vega but it not work for me. |
I think that was before If it doesn't work we can use JavaScript but I'd like to avoid it. Does this sound like a good plan to you? |
Yes i tried the latter but won't work. I don't like to do that using Javascript but i think there isn't another way to do that. Please approve it! You make my life easier. |
By adding a signal to listen to changes of https://vega.github.io/vega/docs/expressions/#containerSize or (probably better) use
autosize: 'fit'
.The text was updated successfully, but these errors were encountered: