Skip to content

Instantly share code, notes, and snippets.

@domoritz
Last active April 7, 2020 00:47
Show Gist options
  • Save domoritz/d5dfd5d195aa7dc838999a25f2dfae02 to your computer and use it in GitHub Desktop.
Save domoritz/d5dfd5d195aa7dc838999a25f2dfae02 to your computer and use it in GitHub Desktop.
Vega updates not queued
license: mit
<head>
<script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
<script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
</head>
<body>
<div id="view"></div>
<script>
vegaEmbed(
'#view',
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"padding": 5,
"width": 200,
"height": 200,
"data": [{"name": "foo"}],
"marks": [
{
"type": "symbol",
"from": {"data": "foo"},
"encode": {
"update": {
"fill": {"value": "#4c78a8"},
"x": {"scale": "x", "field": "a"},
"width": {"value": 5},
"y": {"scale": "y", "field": "b"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {"data": "foo", "field": "a"},
"range": [0, {"signal": "width"}]
},
{
"name": "y",
"type": "linear",
"domain": {"data": "foo", "field": "b"},
"range": [{"signal": "height"}, 0]
}
],
"axes": [{
"scale": "x",
"orient": "bottom"
}]
}
).then(async (result) => {
const view = result.view;
for (const i of [1,2,3,4,5,6,7,8,9,10]) {
view.insert("foo", [{a: i, b: i}]).runAsync()
}
view.resize().runAsync()
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment