Public
Edited
May 14
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
Insert cell
// Construindo o gráfico de barras
exercicio1 = vl.markBar()
.data(countries)
// Fazendo filtragem de dados
// Obs.: Escolhi como critério 3 anos (1980, 1990 e 2000), de acordo com a questão 2, para evitar poluição visual no gráfico
.transform(
vl.filter("datum.year == 1980 || datum.year == 1990 || datum.year == 2000")
)
.encode(
// Definindo os valores que vão aparecer nos eixos
vl.x().fieldN("country").title("Coutry").sort("-y") ,
vl.y().fieldQ("life_expect").title("Life Expectancy"),

// Configurando o gráfico para realizar as barras agregadas
vl.color().fieldN("year").title("Year").legend({ orient: "left" }), // Colocando a legenda na esquerda pra ser vista assim que o gráfico é carregado
vl.xOffset().fieldN("year")
)
.render()
Insert cell
Insert cell
// Construindo o scatterplot
exercicio2 = vl.markPoint()
.data(countries)

// Fazendo a filtragem dos dados (semelhante à questão anterior)
.transform(
vl.filter("datum.year == 1980 || datum.year == 1990 || datum.year == 2000")
)

// Construindo o scatterplot
.encode(
vl.x().fieldQ('fertility').title("Fertility"),
vl.y().fieldQ('life_expect').title("Life Expectancy"),
vl.column().fieldN("year").title("Year") // Fazendo os 3 scatterplots, um do lado do outro
)

.render()
Insert cell
Insert cell
https://davi44128552.github.io/Visualizacao-Dados/
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