spec = ({
$schema: 'https://vega.github.io/schema/vega-lite/v3.json',
data: {
url: 'https://vega.github.io/vega-datasets/data/seattle-weather.csv',
format: {
parse: {date: 'utc:"%Y/%m/%d"'}
}
},
transform: [
{filter: "datum.date <= utc(2012, 0, 7)"},
{
calculate: "utcFormat(datum.date, '%Y-%m-%d')",
as: "formattedDate"
}
],
mark: "point",
encoding: {
x: {field: "date", type: "temporal", scale: {type: "utc"}},
y: {field: "temp_max", type: "quantitative"},
tooltip: [
{field: "formattedDate", type: "nominal", title: "date"}
]
}
})