Published
Edited
Oct 23, 2019
Insert cell
md`# Monthly Hours of Sunshine in Major U.S. Cities`
Insert cell
import {uniqueValid} from '@uwdata/data-utilities'
Insert cell
import {data} from '@adamperer/hours-of-sunshine';
Insert cell
citys = ["All"].concat(uniqueValid(data, d => d.city))
Insert cell
VegaLite = require("vega-embed@5")
Insert cell
VegaLite({
title: "Hours of Sunshine",
width: 500,
height: 300,
data: {values: data},
selection: {
select: {
type: "single",
fields: ["city"],
bind: {"input": "select", "options": citys}
}
},
mark: {type: "line", point: true},
encoding: {
x: { field: "month", type: "nominal", "sort": {"op": "sum", "field": "monthnum"}},
y: {field: "sunshine", type: "quantitative"},
color: {
condition: {
selection: "select",
field: "city", type: "nominal"
},
value: "grey"
}
}
})
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