Public
Edited
Nov 26, 2018
1 star
Insert cell
Insert cell
viewof view = embed({
"config": {"view": {"width": 400, "height": 300}},
"layer": [
{
"data": {
"url": "https://vega.github.io/vega-datasets/data/us-employment.csv",
"format": {"type": "csv"}
},
"mark": "bar",
"encoding": {
"color": {
"condition": {
"value": "steelblue",
"test": "(datum.nonfarm_change > 0)"
},
"value": "orange"
},
"x": {"type": "temporal", "axis": {"title": ""}, "field": "month"},
"y": {
"type": "quantitative",
"axis": {"title": "Change in non-farm employment (in thousands)"},
"field": "nonfarm_change"
}
},
"title": "The U.S. employment crash during the Great Recession"
},
{
"data": {"name": "data-4464eab5de1054f6c3b8d89b9e0a031a"},
"mark": {"type": "rule", "color": "black", "strokeWidth": 2},
"encoding": {"x": {"type": "temporal", "field": "end"}},
"transform": [{"filter": "(datum.president === 'Bush')"}]
},
{
"data": {"name": "data-4464eab5de1054f6c3b8d89b9e0a031b"},
"mark": {
"type": "text",
"align": "left",
"baseline": "middle",
"dx": 7,
"dy": -135,
"size": 11
},
"encoding": {
"color": {"value": "#000000"},
"text": {"type": "nominal", "field": "president"},
"x": {"type": "temporal", "field": "start"},
"x2": {"type": "temporal", "field": "end"}
}
}
],
"width": 600,
"$schema": "https://vega.github.io/schema/vega-lite/v2.6.0.json",
"datasets": {
"data-4464eab5de1054f6c3b8d89b9e0a031a": [
{"end": "2009-01-19", "president": "Bush", "start": "2006-01-01"},
{"end": "2015-12-31", "president": "Obama", "start": "2009-01-20"}
],

"data-4464eab5de1054f6c3b8d89b9e0a031b": [
{"end": "2009-01-19", "president": "Bush", "start": "2006-01-01"},
{"end": "2015-12-31", "president": "Obama", "start": "2009-01-20"}
]
}
})
Insert cell
embed = require("vega-embed@3")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more