Skip to content

Instantly share code, notes, and snippets.

@peterschretlen
Last active December 27, 2017 19:31
Show Gist options
  • Save peterschretlen/1c3cdf591bd7acc6e2ff483f673d932b to your computer and use it in GitHub Desktop.
Save peterschretlen/1c3cdf591bd7acc6e2ff483f673d932b to your computer and use it in GitHub Desktop.
Record Count Example
license: mit
height: 300
scrolling: no
border: no
{
"$schema": "https://vega.github.io/schema/vega/v3.0.json",
"width": 600,
"height": 300,
"padding": 5,
"data": [
{
"name": "timeseries",
"url": "https://us-central1-groupby-demos.cloudfunctions.net/usage/records?start=20171203&end=20171210",
"format": {
"type": "json",
"property" : "timeseries",
"parse" :{
"datetime": "date",
"count" : "number"
}
}
}
],
"scales": [
{
"name": "x",
"type": "utc",
"range": "width",
"nice": "day",
"domain": {"data": "timeseries", "field": "datetime"}
},
{
"name": "y",
"type": "linear",
"range": "height",
"nice": true,
"zero": true,
"domain": {"data": "timeseries", "field": "count"}
}
],
"axes": [
{
"orient": "bottom",
"format" : " %b%e - %H:00",
"scale": "x",
"encode" : {
"labels": {
"interactive": true,
"update": {
"angle": {"value": 40},
"fontSize": {"value": 12},
"align": {"value": "left"},
"baseline": {"value": "middle"}
}
}
}
},
{
"title": "Record Count",
"orient": "left",
"scale": "y"
}
],
"marks": [
{
"type": "area", "from": {"data": "timeseries"},
"encode": {
"enter": {
"x": {"scale": "x", "field": "datetime"},
"y": {"scale": "y", "field": "count"},
"fill": { "value": "#666" },
"y2": { "scale": "y", "value": 0 }
}
}
}
]
}
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega/3.0.8/vega.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vega-embed/3.0.0-rc7/vega-embed.js"></script>
<style>
body {
font-family: sans-serif;
}
.vega-actions a {
padding: 0.2em;
}
</style>
</head>
<body>
<div id="vis"></div>
<script>
const spec = "chart.vega.json";
vegaEmbed('#vis', spec, {actions: false});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment