Published unlisted
Edited
Jan 6, 2020
1 star
Insert cell
Insert cell
Insert cell
vegalite({
title: 'Comparing Ratings across Genre',
data: {values: movies},
width: 300,
mark: 'bar',
transform: [
{filter: {'field': 'genre', 'oneOf': ['Comedy', 'Drama']}}
],
encoding: {
column: {field: 'genre', type: 'ordinal'},
x: {bin: true, field: 'rating', type: 'quantitative'},
y: {aggregate: 'count', type: 'quantitative'},
color: {field: 'genre', type: 'nominal'}
}
})
Insert cell
Insert cell
vegalite({
title: 'Comparing Variance of User Ratings across Genre',
data: {values: movies},
width: 300,
mark: 'bar',
transform: [
{filter: {'field': 'genre', 'oneOf': ['Comedy', 'Drama']}},
{
'aggregate': [{'op':'variance', 'field':'rating', 'as':'user_variance'}],
'groupby': ['user', 'genre']
}
],
encoding: {
column: {field: 'genre', type: 'ordinal'},
x: {bin: true, field: 'user_variance', type: 'quantitative'},
y: {aggregate: 'count', type: 'quantitative'},
color: {field: 'genre', type: 'nominal'}
}
})
Insert cell
Insert cell
vegalite({
title: 'How do users rate dramas vs. comedies?',
data: {values: user_ratings},
width: 400,
height: 400,
mark: 'circle',
encoding: {
x: {field: 'drama', type: 'quantitative'},
y: {field: 'comedy', type: 'quantitative'},
size: {field: 'total', type: 'quantitative', scale: {range: [30,1400]}},
opacity: {value: 0.3}
}
})
Insert cell
Insert cell
movies = FileAttachment('movies.json').json()
Insert cell
Insert cell
Insert cell
Insert cell
vegalite = require("@observablehq/vega-lite@0.2")
Insert cell
d3 = require('d3@5')
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