Skip to content

Instantly share code, notes, and snippets.

@sacundim
Created June 17, 2020 05:24
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 sacundim/c257cf8b95faad2bf4636d574cbefdca to your computer and use it in GitHub Desktop.
Save sacundim/c257cf8b95faad2bf4636d574cbefdca to your computer and use it in GitHub Desktop.
Vega-Lite: Negative values in the size channel
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.8.1.json",
"title": "Negative values in the size channel",
"data": {
"values": [-4, -3, -2, -1, 0, 1, 2, 3, 4]
},
"transform": [
{"calculate": "abs(datum.data)", "as": "abs"}
],
"repeat": ["data", "abs"],
"spec": {
"mark": "circle",
"encoding": {
"x": {
"type": "ordinal",
"field": "data"
},
"size": {
"type": "quantitative",
"field": {"repeat": "repeat"}
},
"color": {
"condition": {
"test": "datum['data'] < 0",
"value": "red"
},
"value": "blue"
}
}
},
"resolve": {
"scale": {"size": "independent"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment