Skip to content

Instantly share code, notes, and snippets.

@nyurik
Created July 10, 2018 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nyurik/713eec64a4a5553f54a1d074615b01ad to your computer and use it in GitHub Desktop.
Save nyurik/713eec64a4a5553f54a1d074615b01ad to your computer and use it in GitHub Desktop.
vega with conditional image (centered and stretched to the largest size preserving aspect ration)
{
"$schema": "https://vega.github.io/schema/vega/v4.json",
"width": 200,
"height": 200,
"padding": 5,
"marks": [
{
"type": "image",
"encode": {
"enter": {
"url": [
{
"test": "false",
"value": "https://www.maxpixel.net/static/photo/1x/Ailurus-Fulgens-Red-Panda-Panda-Fire-Fox-Bear-Cat-3040830.jpg"
},
{
"value": "https://www.thelocal.de/userdata/images/article/fa6fd5014ccbd8f4392f716473ab6ff354f871505d9128820bbb0461cce1d645.jpg"
}
],
"x": {"signal": "width/2"},
"y": {"signal": "height/2"},
"width": {"signal": "width"},
"height": {"signal": "height"},
"align": {"value": "center"},
"baseline": {"value": "middle"}
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment