In this case, I have used the changeset insert()
method with new tuples, and the remove()
method with vega.truthy
; things work as I expect. However, in another case, I used remove()
with the existing tuple; it does not work.
Last active
December 13, 2018 23:42
-
-
Save ijlyttle/98e622c958d5ebec1d62ee7d2dee1216 to your computer and use it in GitHub Desktop.
vega-view changeset works as expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit | |
height: 500 | |
scrolling: yes | |
border: yes | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<!-- uploaded using vegawidget --> | |
<script src="https://cdn.jsdelivr.net/npm/vega@4"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@3.0.0-rc10"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
</head> | |
<body> | |
<div id="chart"></div> | |
<script type="text/javascript"> | |
const spec = "spec.json"; | |
const opt = {"defaultStyle":true,"renderer":"canvas"}; | |
vegaEmbed('#chart', spec, opt).then(result => { | |
// access view as result.view | |
let changeset = vega.changeset() | |
.insert([{a: "b", b: 2}, {a: "c", b: 3}]) | |
.remove(vega.truthy); | |
result.view.change("source", changeset).run(); | |
}).catch(console.error); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://vega.github.io/schema/vega-lite/v2.json", | |
"datasets": { | |
"source": [ | |
{ | |
"a": "a", | |
"b": 1 | |
} | |
] | |
}, | |
"data": { | |
"name": "source" | |
}, | |
"mark": "bar", | |
"encoding": { | |
"x": { | |
"field": "a", | |
"type": "ordinal" | |
}, | |
"y": { | |
"field": "b", | |
"type": "quantitative" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment