Published
Edited
Sep 27, 2022
Insert cell
Insert cell
Insert cell
Insert cell
cars = data['cars.json']()
Insert cell
Inputs.table(cars)
Insert cell
Insert cell
// escreva aqui a sua resposta
aggregatedBarChar = {
const aggregatedBarChar = vl.markBar()
.data(cars)
.encode(
vl.x().average('Weight_in_lbs').title('Média dos pesos'),
vl.y().fieldT('Year').timeUnit('year').title('Ano')
.sort(vl.average('Weight_in_lbs').order('descending'))
)
.width(width/2)
.height(400)
return aggregatedBarChar.render()
}
Insert cell
Insert cell
// escreva aqui a sua resposta
scatterplot = {
const scatterPlotUSA = vl.markPoint()
.data(cars)
.transform(
vl.filter('datum.Origin == "USA"')
)
.encode(
vl.x().fieldQ('Horsepower').title('Cavalos'),
vl.y().fieldQ('Miles_per_Gallon').title('Milhas por Galão'),
)
.width(width/4)
.height(300)

const scatterPlotJapan = vl.markPoint()
.data(cars)
.transform(
vl.filter('datum.Origin == "Japan"')
)
.encode(
vl.x().fieldQ('Horsepower').title('Cavalos'),
vl.y().fieldQ('Miles_per_Gallon').title('Milhas por Galão'),
)
.width(width/4)
.height(300)

const scatterPlotEurope = vl.markPoint()
.data(cars)
.transform(
vl.filter('datum.Origin == "Europe"')
)
.encode(
vl.x().fieldQ('Horsepower').title('Cavalos'),
vl.y().fieldQ('Miles_per_Gallon').title('Milhas por Galão'),
)
.width(width/4)
.height(300)
return vl.hconcat(scatterPlotJapan, scatterPlotUSA, scatterPlotEurope).render()
}
Insert cell
Insert cell
https://danielreboucas.github.io/Vega-Lite-Api-Exercicios/
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