Created
April 17, 2018 03:17
-
-
Save lingyielia/b14901b060bbdd574eb58df7e96a2d34 to your computer and use it in GitHub Desktop.
Working with Vega-lite
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", | |
"data": { | |
"url": "https://raw.githubusercontent.com/hvo/datasets/master/nyc_restaurants_by_cuisine.json", | |
"format": { "type": "json" } | |
}, | |
"transform": [ | |
{"filter": "datum._vgsid_<=25"} | |
], | |
"selection": { | |
"search": { | |
"bind": { | |
"input": "input" | |
}, | |
"empty": "none", | |
"on": "mouseover", | |
"fields": ["term"], | |
"type": "single" | |
}, | |
"highlight": { | |
"type": "single", | |
"on": "mouseover", | |
"empty": "none" } | |
}, | |
"mark": { | |
"type": "bar", | |
"stroke": "black" | |
}, | |
"encoding": { | |
"color": { | |
"condition": { | |
"test": "(indexof(lower(datum.cuisine), lower(search.term))>=0)||(highlight._vgsid_==datum._vgsid_) ", | |
"value": "SteelBlue" | |
}, | |
"value": "LightGrey" | |
}, | |
"y": { | |
"field": "cuisine", | |
"type": "ordinal", | |
"sort": {"field": "total", "op": "argmax"} | |
}, | |
"x": { | |
"field": "total", | |
"type": "quantitative", | |
"axis": { | |
"title": "Restaurants" | |
} | |
} | |
} | |
} |
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> | |
<script src="https://cdn.jsdelivr.net/npm/vega@3"></script> | |
<script src="https://cdn.jsdelivr.net/npm/vega-lite@2"></script> <script src="https://cdn.jsdelivr.net/npm/vega-embed@3"></script> | |
</head> | |
<body> | |
<div id="vis"></div> | |
<script type="text/javascript"> vegaEmbed('#vis', "DV_Lab7.vg.json"); </script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment