Skip to content

Instantly share code, notes, and snippets.

@dmesquita
Created November 30, 2020 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmesquita/c9ba9027397cff505e75ac77e5f923d3 to your computer and use it in GitHub Desktop.
Save dmesquita/c9ba9027397cff505e75ac77e5f923d3 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 600,
"height": 200,
"data":[
{ "name": "visualization_libraries",
"format": {
"type": "json",
"parse": {
"release": "date:'%Y'"
}
},
"values": [
{"name":"vega", "release":"2013"},
{"name":"d3","release":"2011"},
{"name":"plotly","release":"2012"}
]
}
],
"scales": [
{
"name": "x_scale",
"type": "time",
"domain": {"data": "visualization_libraries","field": "release"},
"range": [0, 600],
"nice": "year"
}
],
"marks":[
{
"type": "rect",
"name": "rectangles",
"from": {"data": "visualization_libraries"},
"encode": {
"enter": {
"width": {"value": 60},
"height": {"value": 20},
"x": {
"signal": "scale('x_scale', datum.release)"
},
"y": {"value": 10}
}
}
},
{
"type": "text",
"name": "labels",
"from": {"data": "rectangles"},
"encode": {
"enter": {
"text": {"signal": "datum.datum.name"},
"x": {
"signal": "datum.x+30"
},
"y": {"value": 20},
"align": {"value": "center"},
"baseline": {"value": "middle"},
"fontWeight": {"value": "bold"},
"fill": {"value": "black"}
}
}
},
{
"type": "rule",
"name": "lines",
"from": {"data": "labels"},
"encode": {
"enter": {
"x": {"signal": "datum.x"},
"x2": {"signal": "datum.x"},
"y": {"signal": "datum.y+10"},
"y2": {"signal": "height"}
}
}
}
],
"axes":[
{
"scale": "x_scale",
"orient": "bottom",
"format": "%b/%Y"
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment