Public
Edited
May 9
Insert cell
Insert cell
Insert cell
Insert cell
countries = data['countries.json']()
Insert cell
countries
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
// escreva aqui a sua resposta

bar_chart = {
const bars = vl.markBar()
.data(countries)
.encode(
vl.x().fieldN('country').sort('-y').title('País').axis({ labelAngle: 45 }),
vl.y().aggregate('mean').field('life_expect').title('Expectativa de vida média')
)
.width(900)
.height(300)
.title('Expectativa média de vida por país')
return bars.render()
}


Insert cell
Insert cell
point_plot = {
const scatter_plot = vl.data(countries)
.facet(vl.column().fieldN('year'))
.transform(
vl.filter('datum.year == 1980 || datum.year == 1990 || datum.year == 2000')
)
.spec(
vl
.markPoint()
.encode(
vl.x().fieldQ('fertility').title('Fertilidade'),
vl.y().fieldQ('life_expect').title('Expectativa de vida'),
vl.tooltip(['country', 'year', 'fertility', 'life_expect'])
)
.width(300)
.height(300)
)
.title('Expectativa de Vida vs Fertilidade (1980, 1990, 2000)')

return scatter_plot.render()}


Insert cell
Insert cell
Insert cell
import {vl} from '@vega/vega-lite-api-v5'
Insert cell
data = require('vega-datasets')
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