Published
Edited
Sep 17, 2019
11 forks
38 stars
Insert cell
Insert cell
data = d3.csv("https://vega.github.io/vega-lite/data/seattle-weather.csv")
Insert cell
vegalite({
data: {values: data},
mark: "tick",
encoding: {
x: {field: "precipitation", type: "quantitative"}
}
})
Insert cell
vegalite({
data: {values: data},
mark: "bar",
encoding: {
x: {bin: true, field: "precipitation", type: "quantitative"},
y: {aggregate: "count", field: "*", type: "quantitative"}
}
})
Insert cell
vegalite({
data: {values: data},
mark: "line",
encoding: {
x: {timeUnit: "month", field: "date", type: "temporal"},
y: {aggregate: "mean", field: "precipitation", type: "quantitative"}
}
})
Insert cell
vegalite({
data: {values: data},
transform: [{calculate: "datum.temp_max - datum.temp_min", as: "temp_range"}],
mark: "line",
encoding: {
x: {timeUnit: "month", field: "date", type: "temporal"},
y: {aggregate: "mean", field: "temp_range", type: "quantitative"}
}
})
Insert cell
vegalite({
data: {values: data},
mark: "bar",
encoding: {
x: {timeUnit: "month", field: "date", type: "ordinal"},
y: {aggregate: "count", field: "*", type: "quantitative"},
color: {field: "weather", type: "nominal"}
}
})
Insert cell
vegalite({
data: {values: data},
mark: "bar",
encoding: {
x: {
timeUnit: "month",
field: "date",
type: "ordinal",
axis: {
title: "Month"
}
},
y: {
aggregate: "count",
field: "*",
type: "quantitative",
axis: {
title: "Number of Days"
}
},
color: {
field: "weather",
type: "nominal",
scale: {
domain: ["sun", "fog", "drizzle", "rain", "snow"],
range: ["#e7ba52", "#c7c7c7", "#aec7e8", "#1f77b4", "#9467bd"]
},
legend: {
title: "Weather"
}
}
}
})
Insert cell
vegalite = require("@observablehq/vega-lite@0.2")
Insert cell
d3 = require("d3-fetch@1")
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