Skip to content

Instantly share code, notes, and snippets.

@JackyLiu97
Created September 24, 2019 18:53
Show Gist options
  • Save JackyLiu97/294b70ba0b782cca5b072a0ea03eb000 to your computer and use it in GitHub Desktop.
Save JackyLiu97/294b70ba0b782cca5b072a0ea03eb000 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Lab 4",
"data": {"url": "https://raw.githubusercontent.com/hvo/datasets/master/nyc_grads.csv"},
"transform":[
{"filter": {"field": "Cohort", "oneOf": ["2002","2004","2006"]}},
{"filter": {"field": "Type", "equal": "Borough Total"}},
{"calculate": "datum.Advanced/datum.Total*100", "as": "PAdvanced"},
{"calculate": "datum.DroppedOut/datum.Total*100", "as": "PDroppedOut"}
],
"mark": {
"type": "circle",
"opacity": 1,
"stroke": "black",
"strokeWidth": 0.5,
"size": 64
},
"encoding": {
"x": {"field": "PAdvanced", "type": "quantitative",
"scale": {"domain": [0,30]},
"axis": {"title": "Advanced (%)", "grid": false}
},
"y": {"field": "PDroppedOut", "type": "quantitative",
"scale": {"domain":[0,30]},
"axis": {"title": "Dropped Out (%)", "grid":false}
},
"color": {"field": "Cohort", "type": "nominal",
"scale": {"range": ["SteelBlue", "SeaGreen", "IndianRed"]}}
}
}
<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_Lab3.vg.json");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment