Published
Edited
Dec 30, 2021
Insert cell
data = FileAttachment("final.csv").csv()
Insert cell
viewof emdia = {
const brush = vl.selectInterval()
.encodings('x'); // limit selection to x-axis (year) values
// 动态查询直方图
const MEDV = vl.markBar({width: 4})
.data(data)
.params(brush)
.encode(
vl.x().fieldQ('table').title('table'),
vl.y().count().title(null)
)
.width(600)
.height(50);
// 散点图
const ratings = vl.markCircle()
.data(data)
.encode(
vl.x().fieldQ('carat'),
vl.y().fieldQ('price'),
vl.tooltip(['carat','clarity','color','cut','depth','name','price','table','x','y','z']),
vl.opacity().if(brush, vl.value(0.75)).value(0.25)
)
.width(600)
.height(400);

return vl.vconcat(MEDV, ratings).spacing(5).render();
}
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